Hello,
When trying to enter spent time on a project task (Project>Tasks>Select a task>Edit>Add an item) I get the following error:
Odoo Server ErrorTraceback (most recent call last):
File "/home/next/workspace/Transform-Test/openerp/http.py", line 537, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/next/workspace/Transform-Test/openerp/http.py", line 574, in dispatch result = self._call_function(**self.params) File "/home/next/workspace/Transform-Test/openerp/http.py", line 310, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/next/workspace/Transform-Test/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) File "/home/next/workspace/Transform-Test/openerp/http.py", line 307, in checked_call return self.endpoint(*a, **kw) File "/home/next/workspace/Transform-Test/openerp/http.py", line 803, in __call__ return self.method(*args, **kw) File "/home/next/workspace/Transform-Test/openerp/http.py", line 403, in response_wrap response = f(*args, **kw) File "/home/next/workspace/Transform-Test/addons/web/controllers/main.py", line 935, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/next/workspace/Transform-Test/addons/web/controllers/main.py", line 927, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/home/next/workspace/Transform-Test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/next/workspace/Transform-Test/openerp/api.py", line 363, in old_api result = method(recs, *args, **kwargs) File "/home/next/workspace/Transform-Test/openerp/models.py", line 5864, in onchange record._onchange_eval(name, field_onchange[name], result) File "/home/next/workspace/Transform-Test/openerp/models.py", line 5782, in _onchange_eval method_res = getattr(self._model, method)(*args) File "/home/next/workspace/Transform-Test/openerp/api.py", line 241,
in wrapper return old_api(self, *args, **kwargs)
TypeError: on_change_user_id() takes at least 6 arguments (5 given)
Hi Saranya,are you having your own customized module where you are using on_change_user_id(), if yes, pls post the onchange method script with xml syntax. And also, which odoo version you are using.?
Hi Raaj, i am using odoo module hr_timesheet and timesheet_task module for bringing the work summary entered under every task into the employee's timesheet.After installation of this timesheet_task module while adding work summary under task am getting this error
Iam using Odoo 8.0
Hi Saranya, pls search for on_change_user_id() function at hr_timesheet and timesheet_task module and provide the python as well as xml syntax so that we can check.While talking about timesheet_task module is it a customized one or base module.This type of error will come generally if the number of paramerters mismatches among python script and xml syntax.
Hi Raaj timesheet_task is a module that i downloaded from odoo APP here i share the code:
XML File:
project_task_view.xml file in timesheet_task module:
<openerp>
<data>
<record id="view_task_form2" model="ir.ui.view">
<field name="name">project.task.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='work_ids']" position="replace">
<field colspan="4" name="work_ids" nolabel="1">
<tree string="Task Work" editable="top">
<field name="user_id" on_change="on_change_user_id(user_id)" required="1" invisible="1"/>
<field name="name"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice, parent.project_id)" sum="Total time" widget="float_time"/>
<field name="date" on_change="on_change_date(date)"/>
<field name="journal_id" invisible="1"/>
<field domain="[('type','=','normal')]" name="account_id" invisible="1"/>
<field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice, parent.project_id)" required="1" domain="[('type','=','service')]" invisible="1"/>
<field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice, parent.project_id)" invisible="1"/>
<field name="amount" sum="Total cost" invisible="1"/>
<field name="general_account_id" invisible="1"/>
<field name="to_invoice"/>
</tree>
<form string="Task Work" editable="top">
<field name="user_id" on_change="on_change_user_id(user_id)" required="1"/>
<field name="name" default_focus="1"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice, parent.project_id, context)" sum="Total time" widget="float_time"/>
<field name="date" on_change="on_change_date(date)"/>
<field name="journal_id" invisible="1"/>
<field domain="[('type','=','normal')]" name="account_id" invisible="1"/>
<field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice, parent.project_id)" required="1" domain="[('type','=','service')]" invisible="1"/>
<field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice, parent.project_id)" invisible="1"/>
<field name="amount" sum="Total cost" invisible="1"/>
<field name="general_account_id" invisible="1"/>
<field name="to_invoice"/>
</form>
</field>
</xpath>
</field>
</record>
</data>
</openerp>
Python file in hr_timesheet:
def on_change_user_id(self, cr, uid, ids, user_id):
if not user_id:
return {}
context = {'user_id': user_id}
return {'value': {
'product_id': self. _getEmployeeProduct(cr, uid, context),
'product_uom_id': self._getEmployeeUnit(cr, uid, context),
'general_account_id': self._getGeneralAccount(cr, uid, context),
'journal_id': self._getAnalyticJournal(cr, uid, context),
}}
python file in analytic_user_function.py
def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0):
res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids, user_id)
if account_id:
#get the browse record related to user_id and account_id
temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id)
if temp:
#add the value from the new relation analytic_user_funct_grid
r = self.pool.get('analytic.user.funct.grid').browse(cr, uid, temp)[0]
res['value']['product_id'] = r.product_id.id
#the change of product has to impact the amount, uom and general_account_id
a = r.product_id.property_account_expense.id
if not a:
a = r.product_id.categ_id.property_account_expense_categ.id
if not a:
raise osv.except_osv(_('Error!'),
_('There is no expense account defined ' \
'for this product: "%s" (id:%d)') % \
(r.product_id.name, r.product_id.id,))
# Compute based on pricetype
if unit_amount:
amount_unit = self.on_change_unit_amount(cr, uid, ids,
r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount']
amount = unit_amount * amount_unit
res ['value']['amount']= - round(amount, 2)
res ['value']['general_account_id']= a
return res