diff options
Diffstat (limited to 'addons/analytic_user_function')
| -rw-r--r-- | addons/analytic_user_function/analytic_user_function.py | 12 | ||||
| -rw-r--r-- | addons/analytic_user_function/analytic_user_function_view.xml | 53 |
2 files changed, 6 insertions, 59 deletions
diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index c0e3c7f9c88..bd3d70e5de7 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -53,9 +53,9 @@ class account_analytic_line(osv.osv): # Look in account, if no value for the user => look in parent until there is no more parent to look # Take the first found... if nothing found => return False - def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id, context): - user_function_id = self.pool.get('analytic.user.funct.grid').search(cr, uid, [('user_id', '=', user_id), ('account_id', '=', account_id)]) - account = self.pool['account.analytic.account'].browse(cr, uid, account_id) + def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id, context=None): + user_function_id = self.pool.get('analytic.user.funct.grid').search(cr, uid, [('user_id', '=', user_id), ('account_id', '=', account_id)], context=context) + account = self.pool['account.analytic.account'].browse(cr, uid, account_id, context=context) if user_function_id: return user_function_id elif account.parent_id: @@ -68,16 +68,16 @@ class account_analytic_line(osv.osv): if not (account_id): return res if not (user_id): - return super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, is_timesheet, context) + return super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount, is_timesheet, context) # get the browse record related to user_id and account_id user_function_id = self._get_related_user_account_recursiv(cr, uid, user_id, account_id, context) if not user_function_id: # if there isn't any record for this user_id and account_id - return super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, is_timesheet, context) + return super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount, is_timesheet, context) else: # get the old values from super and add the value from the new relation analytic_user_funct_grid - res['value'] = super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, is_timesheet, context)['value'] + res['value'] = super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount, is_timesheet, context)['value'] res['value'].update(self._get_values_based_on_user_function(cr, uid, ids, user_function_id, unit_amount, context=context)) return res diff --git a/addons/analytic_user_function/analytic_user_function_view.xml b/addons/analytic_user_function/analytic_user_function_view.xml index 6010970b0ce..ff434cdd437 100644 --- a/addons/analytic_user_function/analytic_user_function_view.xml +++ b/addons/analytic_user_function/analytic_user_function_view.xml @@ -58,64 +58,11 @@ </field> </record> - <!-- hr_timesheet_sheet.sheet inherited view --> - <record model="ir.ui.view" id="hr_timesheet_sheet_form_inherit"> - <field name="name">hr.timesheet.sheet.form.tree</field> - <field name="model">hr_timesheet_sheet.sheet</field> - <field name="priority" eval="18"/> - <field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='timesheet_ids']/tree/field[@name='account_id']" position="attributes"> - <attribute name="on_change">on_change_account_id(account_id, user_id, unit_amount, is_timesheet, context)</attribute> - </xpath> - </field> - </record> - - <!-- hr_timesheet_sheet.sheet inherited view --> - <record model="ir.ui.view" id="hr_timesheet_sheet_form_inherit1"> - <field name="name">hr.timesheet.sheet.form.form</field> - <field name="model">hr_timesheet_sheet.sheet</field> - <field name="priority" eval="19"/> - <field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='timesheet_ids']/form/field[@name='account_id']" position="attributes"> - <attribute name="on_change">on_change_account_id(account_id, user_id, unit_amount, is_timesheet, context)</attribute> - <attribute name="context">{'default_invoice_on_timesheets': 1}</attribute> - </xpath> - </field> - </record> - - <!-- hr.analytic.timesheet inherited views --> - <record model="ir.ui.view" id="hr_timesheet_line_form_inherit"> - <field name="name">account.analytic.line.form</field> - <field name="model">account.analytic.line</field> - <field name="inherit_id" ref="hr_timesheet_invoice.hr_timesheet_line_form"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='account_id']" position="attributes"> - <attribute name="on_change">on_change_account_id(account_id, user_id, unit_amount, is_timesheet, context)</attribute> - </xpath> - </field> - </record> - - <record model="ir.ui.view" id="hr_timesheet_line_form_inherit_2"> - <field name="name">account.analytic.line.form</field> - <field name="model">account.analytic.line</field> - <field name="inherit_id" ref="hr_timesheet_invoice.hr_timesheet_line_form"/> - <field name="arch" type="xml"> - <xpath expr="//field[@name='user_id']" position="replace"> - <field name="user_id" required="1" on_change="on_change_user_id(user_id, unit_amount, account_id, is_timesheet, context)"/> - </xpath> - </field> - </record> - <record model="ir.ui.view" id="hr_timesheet_line_tree_inherit"> <field name="name">account.analytic.line.tree</field> <field name="model">account.analytic.line</field> <field name="inherit_id" ref="hr_timesheet_invoice.hr_timesheet_line_tree"/> <field name="arch" type="xml"> - <xpath expr="/tree/field[@name='account_id']" position="attributes"> - <attribute name="on_change">on_change_account_id(account_id, user_id, unit_amount, is_timesheet, context)</attribute> - </xpath> <xpath expr="/tree/field[@name='user_id']" position="replace"> <field name="user_id" required="1" on_change="on_change_user_id(user_id, unit_amount, account_id, is_timesheet, context)" context="{'default_groups_ref': ['base.group_user']}"/> </xpath> |
