bugfix_350775
bzr revid: fp@tinyerp.com-20090406171957-d5obb4ykdrbitt3i
This commit is contained in:
parent
81f5738665
commit
328f7fe8f4
|
@ -48,26 +48,26 @@ class hr_analytic_timesheet(osv.osv):
|
|||
_inherit = "hr.analytic.timesheet"
|
||||
|
||||
|
||||
def on_change_account_id(self, cr, uid, ids,user_id, account_id, unit_amount=0, journal_id=0):
|
||||
def on_change_account_id(self, cr, uid, ids,account_id, user_id=False, unit_amount=0, journal_id=0):
|
||||
res = {}
|
||||
if not (account_id):
|
||||
#avoid a useless call to super
|
||||
return res
|
||||
|
||||
if not (journal_id):
|
||||
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,user_id, account_id, unit_amount)
|
||||
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id, user_id, unit_amount)
|
||||
|
||||
#get the browse record related to journal_id and account_id
|
||||
temp = self.pool.get('analytic_journal_rate_grid').search(cr, uid, [('journal_id', '=', journal_id),('account_id', '=', account_id) ])
|
||||
|
||||
if not temp:
|
||||
#if there isn't any record for this journal_id and account_id
|
||||
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,user_id, account_id, unit_amount)
|
||||
return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id,user_id, unit_amount)
|
||||
else:
|
||||
#get the old values from super and add the value from the new relation analytic_journal_rate_grid
|
||||
r = self.pool.get('analytic_journal_rate_grid').browse(cr, uid, temp)[0]
|
||||
res.setdefault('value',{})
|
||||
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,user_id, account_id,unit_amount)['value']
|
||||
res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id,user_id, unit_amount)['value']
|
||||
if r.rate_id.id:
|
||||
res['value']['to_invoice'] = r.rate_id.id
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='timesheet_ids']/tree/field[@name='account_id']" position="replace">
|
||||
<field name="account_id" domain="[('type','=','normal'),('state', '<>', 'close')]" on_change="on_change_account_id(user_id, account_id, unit_amount, journal_id)"/>
|
||||
<field name="account_id" domain="[('type','=','normal'),('state', '<>', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount, journal_id)"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -62,7 +62,7 @@
|
|||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/field[@name='account_id']" position="replace">
|
||||
<field name="account_id" domain="[('type','=','normal'),('state', '<>', 'close')]" on_change="on_change_account_id(user_id, account_id, unit_amount, journal_id)" select="1"/>
|
||||
<field name="account_id" domain="[('type','=','normal'),('state', '<>', 'close')]" on_change="on_change_account_id(account_id, user_id, unit_amount, journal_id)" select="1"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -66,7 +66,7 @@ class hr_analytic_timesheet(osv.osv):
|
|||
return False
|
||||
|
||||
|
||||
def on_change_account_id(self, cr, uid, ids, account_id, user_id, unit_amount=0):
|
||||
def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0):
|
||||
#{'value': {'to_invoice': False, 'amount': (-162.0,), 'product_id': 7, 'general_account_id': (5,)}}
|
||||
res = {}
|
||||
if not (account_id):
|
||||
|
@ -140,5 +140,3 @@ class hr_analytic_timesheet(osv.osv):
|
|||
|
||||
hr_analytic_timesheet()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
id="menu_hr_reporting"
|
||||
name="Reporting"
|
||||
parent="hr.menu_hr_root"
|
||||
sequence="40"
|
||||
groups="group_hr_manager"/>
|
||||
sequence="40" />
|
||||
<menuitem
|
||||
id="menu_hr_configuration"
|
||||
name="Configuration"
|
||||
|
|
|
@ -1,19 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<menuitem id="hr.menu_hr_reporting" name="Reporting" parent="hr.menu_hr_root" sequence="40"/>
|
||||
<report auto="False" id="report_user_timesheet" menu="False" model="hr.employee" name="hr.analytical.timesheet" string="Employee timesheet" xsl="hr_timesheet/report/user_timesheet.xsl"/>
|
||||
|
||||
<wizard id="wizard_hr_timesheet" menu="False" model="hr.employee" name="hr.analytical.timesheet" string="Employee Timesheet"/>
|
||||
<menuitem id="next_id_48" name="Timesheet" parent="hr.menu_hr_reporting"/><menuitem action="wizard_hr_timesheet" id="menu_wizard_hr_timesheet" parent="next_id_48" type="wizard"/>
|
||||
<menuitem id="next_id_48" name="Timesheet" parent="hr.menu_hr_reporting"/><menuitem action="wizard_hr_timesheet" id="menu_wizard_hr_timesheet" parent="next_id_48" type="wizard"
|
||||
groups="hr.group_hr_manager"
|
||||
/>
|
||||
|
||||
<wizard id="wizard_hr_timesheet_my" menu="False" model="hr.employee" name="hr.analytical.timesheet.my" string="Print My Timesheet"/>
|
||||
<menuitem action="wizard_hr_timesheet_my" id="menu_wizard_hr_timesheet_my" parent="hr_timesheet.next_id_48" type="wizard"/>
|
||||
<menuitem
|
||||
action="wizard_hr_timesheet_my"
|
||||
id="menu_wizard_hr_timesheet_my"
|
||||
parent="hr_timesheet.next_id_48"
|
||||
type="wizard"
|
||||
groups="hr.group_hr_user"
|
||||
/>
|
||||
|
||||
<report auto="False" id="report_users_timesheet" menu="False" model="hr.employee" name="hr.analytical.timesheet_users" string="Employees Timesheet" xsl="hr_timesheet/report/users_timesheet.xsl"/>
|
||||
|
||||
<wizard id="wizard_hr_timesheet_users" menu="False" model="hr.employee" name="hr.analytical.timesheet_users" string="Employees Timesheet"/>
|
||||
<menuitem action="wizard_hr_timesheet_users" id="menu_wizard_hr_timesheet_users" parent="hr_timesheet.next_id_48" type="wizard"/>
|
||||
<menuitem
|
||||
action="wizard_hr_timesheet_users"
|
||||
id="menu_wizard_hr_timesheet_users"
|
||||
groups="hr.group_hr_manager"
|
||||
parent="hr_timesheet.next_id_48" type="wizard"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
string="Timesheet Profit"
|
||||
groups="account.group_account_manager"/>
|
||||
|
||||
<menuitem action="account_analytic_profit" id="print_account_analytic_profit" parent="hr.menu_hr_reporting" type="wizard"/>
|
||||
<menuitem action="account_analytic_profit"
|
||||
id="print_account_analytic_profit"
|
||||
parent="hr.menu_hr_reporting"
|
||||
type="wizard"
|
||||
groups="hr.group_hr_manager"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -54,14 +54,18 @@ class project_work(osv.osv):
|
|||
a = emp.product_id.product_tmpl_id.property_account_expense.id
|
||||
if not a:
|
||||
a = emp.product_id.categ_id.property_account_expense_categ.id
|
||||
vals_line['general_account_id'] = a
|
||||
vals_line['journal_id'] = emp.journal_id.id
|
||||
|
||||
vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/')
|
||||
vals_line['user_id'] = vals['user_id']
|
||||
vals_line['date'] = vals['date'][:10]
|
||||
vals_line['unit_amount'] = vals['hours']
|
||||
vals_line['account_id'] = obj_task.project_id.category_id.id
|
||||
res = obj.on_change_account_id(cr, uid, False, obj_task.project_id.category_id.id)
|
||||
print 'Got', res
|
||||
if res.get('value'):
|
||||
vals_line.update(res['value'])
|
||||
vals_line['general_account_id'] = a
|
||||
vals_line['journal_id'] = emp.journal_id.id
|
||||
vals_line['amount'] = 00.0
|
||||
timeline_id = obj.create(cr, uid, vals_line, {})
|
||||
|
||||
|
|
Loading…
Reference in New Issue