[ADD] hr_timesheet_invoice: Account Analytic Profit=> Osv memory convert
bzr revid: mra@tinyerp.com-20100422063601-16jjmsd0ryzlx6yt
This commit is contained in:
parent
dc4346dc43
commit
7dd22ed545
|
@ -40,6 +40,7 @@ reports, eso.""",
|
|||
'report/report_analytic_view.xml',
|
||||
'report/hr_timesheet_invoice_report_view.xml',
|
||||
'wizard/hr_timesheet_invoice_analytic_cost_ledger_view.xml',
|
||||
'wizard/hr_timesheet_analytic_profit_view.xml',
|
||||
],
|
||||
'demo_xml': ['hr_timesheet_invoice_demo.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
rml="hr_timesheet_invoice/report/account_analytic_profit.rml"
|
||||
string="Timesheet Profit"/>
|
||||
|
||||
<wizard
|
||||
<!--<wizard
|
||||
id="account_analytic_profit"
|
||||
menu="False"
|
||||
model="account.analytic.line"
|
||||
|
@ -36,7 +36,7 @@
|
|||
id="print_account_analytic_profit"
|
||||
parent="menu_hr_reporting_timesheet_invoice"
|
||||
type="wizard"
|
||||
groups="hr.group_hr_manager"/>
|
||||
groups="hr.group_hr_manager"/>-->
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
import hr_timesheet_invoice_create
|
||||
import account_analytic_profit
|
||||
import hr_timesheet_analytic_profit
|
||||
import hr_timesheet_final_invoice_create
|
||||
import hr_timesheet_analytic_cost_ledger_report
|
||||
|
||||
|
|
|
@ -1,99 +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 wizard
|
||||
import datetime
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
form='''<?xml version="1.0"?>
|
||||
<form string="Choose">
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="journal_ids" colspan="4"/>
|
||||
<field name="employee_ids" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
def _date_from(*a):
|
||||
return datetime.datetime.today().strftime('%Y-%m-1')
|
||||
|
||||
def _date_to(*a):
|
||||
return datetime.datetime.today().strftime('%Y-%m-%d')
|
||||
|
||||
def _check(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
line_obj = pool.get('account.analytic.line')
|
||||
product_obj = pool.get('product.product')
|
||||
price_obj = pool.get('product.pricelist')
|
||||
ids = line_obj.search(cr, uid, [
|
||||
('date', '>=', data['form']['date_from']),
|
||||
('date', '<=', data['form']['date_to']),
|
||||
('journal_id', 'in', data['form']['journal_ids'][0][2]),
|
||||
('user_id', 'in', data['form']['employee_ids'][0][2]),
|
||||
])
|
||||
if not ids:
|
||||
raise wizard.except_wizard(_('Data Insufficient!'), _('No Records Found for Report!'))
|
||||
|
||||
return data['form']
|
||||
|
||||
|
||||
fields={
|
||||
'date_from':{
|
||||
'string':'From',
|
||||
'type':'date',
|
||||
'required':True,
|
||||
'default':_date_from,
|
||||
},
|
||||
'date_to':{
|
||||
'string':'To',
|
||||
'type':'date',
|
||||
'required':True,
|
||||
'default':_date_to,
|
||||
},
|
||||
'journal_ids':{
|
||||
'string':'Journal',
|
||||
'type':'many2many',
|
||||
'relation':'account.analytic.journal',
|
||||
'required':True,
|
||||
},
|
||||
'employee_ids':{
|
||||
'string':'Employee',
|
||||
'type':'many2many',
|
||||
'relation':'res.users',
|
||||
'required':True,
|
||||
},
|
||||
}
|
||||
|
||||
states={
|
||||
'init':{
|
||||
'actions':[],
|
||||
'result':{'type':'form', 'arch':form, 'fields':fields, 'state':[('end', 'Cancel', 'gtk-cancel'), ('report', 'Print', 'gtk-ok')]}
|
||||
},
|
||||
'report':{
|
||||
'actions':[_check],
|
||||
'result':{'type':'print', 'report':'account.analytic.profit', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_report('account.analytic.profit')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
# -*- 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 datetime
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class account_analytic_profit(osv.osv_memory):
|
||||
_name = 'hr.timesheet.analytic.profit'
|
||||
_description = 'Print Timesheet Profit'
|
||||
_columns = {
|
||||
'date_from': fields.date('From', required=True),
|
||||
'date_to': fields.date('To', required=True),
|
||||
'journal_ids': fields.many2many('account.analytic.journal', 'analytic_profit_journal_rel', 'analytic_id', 'journal_id', 'Journal', required=True),
|
||||
'employee_ids': fields.many2many('res.users', 'analytic_profit_emp_rel', 'analytic_id', 'emp_id', 'Employee', required=True),
|
||||
}
|
||||
|
||||
def _date_from(*a):
|
||||
return datetime.datetime.today().strftime('%Y-%m-1')
|
||||
|
||||
def _date_to(*a):
|
||||
return datetime.datetime.today().strftime('%Y-%m-%d')
|
||||
|
||||
_defaults = {
|
||||
'date_from': _date_from,
|
||||
'date_to': _date_to
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
line_obj = self.pool.get('account.analytic.line')
|
||||
product_obj = self.pool.get('product.product')
|
||||
price_obj = self.pool.get('product.pricelist')
|
||||
data = {}
|
||||
data['form'] = self.read(cr, uid , ids, [], context=context)[0]
|
||||
if context is None:
|
||||
context = {}
|
||||
ids_chk = line_obj.search(cr, uid, [
|
||||
('date', '>=', data['form']['date_from']),
|
||||
('date', '<=', data['form']['date_to']),
|
||||
('journal_id', 'in', data['form']['journal_ids']),
|
||||
('user_id', 'in', data['form']['employee_ids']),
|
||||
])
|
||||
if not ids_chk:
|
||||
raise osv.except_osv(_('Data Insufficient!'), _('No Records Found for Report!'))
|
||||
|
||||
data['form']['journal_ids'] = [(6, 0, data['form']['journal_ids'])] # Improve me => Change the rml/sxw so that it can support withou [0][2]
|
||||
data['form']['employee_ids'] = [(6, 0, data['form']['employee_ids'])]
|
||||
datas = {
|
||||
'ids': [],
|
||||
'model': 'account.analytic.line',
|
||||
'form': data['form']
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.analytic.profit',
|
||||
'datas': datas,
|
||||
}
|
||||
|
||||
account_analytic_profit()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_hr_timesheet_analytic_profit" model="ir.ui.view">
|
||||
<field name="name">Timesheet Profit</field>
|
||||
<field name="model">hr.timesheet.analytic.profit</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Timesheet Profit">
|
||||
<group col="4" colspan="6">
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="journal_ids" colspan="4"/>
|
||||
<field name="employee_ids" colspan="4"/>
|
||||
</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_analytic_profit" model="ir.actions.act_window">
|
||||
<field name="name">Timesheet Profit</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hr.timesheet.analytic.profit</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_hr_timesheet_analytic_profit"
|
||||
id="menu_hr_timesheet_analytic_profit"
|
||||
parent="menu_hr_reporting_timesheet_invoice" groups="hr.group_hr_manager" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue