[ADD] hr_timesheet_invoice: Cost ledger on analytic account=> osv memory

bzr revid: mra@tinyerp.com-20100421131101-xt6wjm2eazq0gydy
This commit is contained in:
mra (Open ERP) 2010-04-21 18:41:01 +05:30
parent 18bf93851d
commit a6fc37e008
5 changed files with 100 additions and 55 deletions

View File

@ -39,6 +39,7 @@ reports, eso.""",
'hr_timesheet_invoice_report.xml',
'report/report_analytic_view.xml',
'report/hr_timesheet_invoice_report_view.xml',
'wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml',
],
'demo_xml': ['hr_timesheet_invoice_demo.xml'],
'installable': True,

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,14 +15,14 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import hr_timesheet_invoice_create
import account_analytic_profit
import hr_timesheet_final_invoice_create
import wizard_account_analytic_cost_ledger_report
import hr_timesheet_analytic_cost_ledger_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from osv import osv, fields
class hr_timesheet_analytic_cost_ledger(osv.osv_memory):
_name = 'hr.timesheet.analytic.cost.ledger'
_description = 'hr.timesheet.analytic.cost.ledger'
_columns = {
'date1': fields.date('Start of period', required=True),
'date2': fields.date('End of period', required=True)
}
_defaults = {
'date1': lambda *a: time.strftime('%Y-01-01'),
'date2': lambda *a: time.strftime('%Y-%m-%d')
}
def print_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
datas = {
'ids': 'active_ids' in context and context['active_ids'] or [],
'model': 'account.analytic.account',
'form': self.read(cr, uid, ids)[0]
}
return {
'type': 'ir.actions.report.xml',
'report_name': 'hr.timesheet.invoice.account.analytic.account.cost_ledger',
'datas': datas,
}
hr_timesheet_analytic_cost_ledger()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hr_timesheet_invoice_cost_ledger" model="ir.ui.view">
<field name="name">Cost Ledger</field>
<field name="model">hr.timesheet.analytic.cost.ledger</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Period">
<group col="4" colspan="6">
<field name="date1"/>
<field name="date2"/>
</group>
<separator colspan="4"/>
<group col="2" colspan="4">
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
<button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/>
</group>
</form>
</field>
</record>
<record id="action_hr_timesheet_invoice_cost_ledger" model="ir.actions.act_window">
<field name="name">Cost Ledger</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.timesheet.analytic.cost.ledger</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.values" id="hr_timesheet_invoice_cost_ledger_values">
<field name="model_id" ref="model_account_analytic_account" />
<field name="object" eval="1" />
<field name="name">Cost Ledger</field>
<field name="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_timesheet_invoice_cost_ledger'))" />
<field name="key">action</field>
<field name="model">account.analytic.account</field>
</record>
</data>
</openerp>

View File

@ -1,52 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date1"/>
<field name="date2"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
class wizard_report(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'report': {
'actions': [],
'result': {'type':'print', 'report':'hr.timesheet.invoice.account.analytic.account.cost_ledger', 'state':'end'}
}
}
wizard_report('hr.timesheet.invoice.account.analytic.account.cost_ledger.report')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: