Skip to Content
Menu
This question has been flagged
6 Replies
2189 Views

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)

Avatar
Discard

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.?

Author

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

Author

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.

Author

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

Best Answer

Please try by passing context=None at all where in your python script wherever you are using or calling on_change_user_id.
like for example: def on_change_user_id(self, cr, uid, ids, user_id,context=None): 

Avatar
Discard
Author

Still its giving the same error.Actually there is some issue in timesheet_task module only. if i uninstall that i am able to add work summary Please help in identifying the error!

pls check this:

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)

here, we are having two parameters user_id, account_id but while calling super there is user_id only,may be this could be the reason.

Which module is having this file:analytic_user_function.py, i didn't find at timesheet_task module.

Author

In addons analytic_user_function module is having this file

Author

Due to my office timing am leaving by now But please let me know the solution if you found.i would make use of it by tomorrow morning.Thank You for your response sir.

i have installed these modules at my instance:

analytic_user_function

hr_timesheet_invoice

timesheet_task

but unfortunately, I did'nt get any issue.

Author

But for me this error is appearing .the list of modules that i have installed are:

hr_timesheet_employee

hr

hr_timesheet

hr_timesheet_sheet

hr_applicant_document

hr_recruitment

hr_holidays

hr_expense

hr_evaluation

hr_payroll

analytic_contract_hr_expense

hr_attendance

hr_contract

hr_gamification

l10n_in_hr_payroll

project_issue_sheet

project_timesheet

timesheet_task

hr_timesheet_task

Author

Hi Raaj could you please go thru this link for knowing what error am exactly saying:

https://github.com/OCA/hr-timesheet/issues/34

Here they have discussed the same error but i cant find the solution.

Hi Saranya,I have also installed some of the modules you listed to replicate the issue and found the solution.

At analytic_user_function module, search for the on_change_user_id method in analytic_user_function.py file and there at method signature pass account_id as False, will resolve your issue.

Ex : def on_change_user_id(self, cr, uid, ids, user_id, account_id = False, unit_amount=0):

Author

Thank You so much for the answer it works fine!