object_timesheet : Wrong type definition of the hr_analytic_timesheet_id of the object project.task.work

Bug #591736 reported by Sam http://www.smile.fr
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned

Bug Description

Hi!!
In the object_timesheet module :
The hr_analytic_timesheet_id of the object "project.task.work" is defined as an integer otherwise a many2one to point to an hr_analytic_timesheet project. Indeed, when a hr_analytic_timesheet is deleted the "project.task.work" continue to point to this one. So when we try to call the write function the following bug is returned:

Traceback (most recent call last):
  File "/home/sarac/workspace/ertus/trunk/server/bin/netsvc.py", line 245, in dispatch
    result = LocalService(service_name)(method, *params)
  File "/home/sarac/workspace/ertus/trunk/server/bin/netsvc.py", line 74, in __call__
    return getattr(self, method)(*params)
  File "/home/sarac/workspace/ertus/trunk/server/bin/service/web_services.py", line 576, in execute
    res = service.execute(db, uid, object, method, *args)
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/osv.py", line 58, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/osv.py", line 119, in execute
    res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/osv.py", line 111, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/sarac/workspace/ertus/trunk/addons/project_timesheet/project_timesheet.py", line 162, in write
    hr_anlytic_timesheet.write(cr, uid, [line_id], vals_line, {})
  File "/home/sarac/workspace/ertus/trunk/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 425, in write
    self._check(cr, uid, ids)
  File "/home/sarac/workspace/ertus/trunk/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 430, in _check
    if att.sheet_id and att.sheet_id.state not in ('draft', 'new'):
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/orm.py", line 240, in __getattr__
    return self[name]
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/orm.py", line 189, in __getitem__
    datas = self._table.read(self._cr, self._uid, ids, fffields, context=self._context, load="_classic_write")
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/orm.py", line 2225, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/orm.py", line 2361, in _read_flat
    res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
  File "/home/sarac/workspace/ertus/trunk/server/bin/osv/fields.py", line 650, in get
    res = self._fnct(obj, cr, user, ids, name, self._arg, context)
  File "/home/sarac/workspace/ertus/trunk/addons/hr_timesheet_sheet/hr_timesheet_sheet.py", line 337, in _sheet
    GROUP BY l.id')
  File "/home/sarac/workspace/ertus/trunk/server/bin/sql_db.py", line 77, in wrapper
    return f(self, *args, **kwargs)
  File "/home/sarac/workspace/ertus/trunk/server/bin/sql_db.py", line 122, in execute
    res = self._obj.execute(query, params)
ProgrammingError: ERREUR: erreur de syntaxe sur ou près de « ) »
LINE 1: ...r_id = al.user_id) WHERE l.id in () ...
                                                             ^

Furthermore, the write function of the project.task.work is corrupted :

vals_line = {}

        task = self.pool.get('project.task.work').browse(cr, uid, ids)[0]
        line_id = task.hr_analytic_timesheet_id
        # in case,if a record is deleted from timesheet,but we change it from tasks!
        list_avail_ids = self.pool.get('hr.analytic.timesheet').search(cr, uid, [])
        if line_id in list_avail_ids:
            obj = self.pool.get('hr.analytic.timesheet')
            if 'name' in vals:
                vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/')
            if 'user_id' in vals:
                vals_line['user_id'] = vals['user_id']
                result = self.get_user_related_details(cr, uid, vals['user_id'])
                vals_line['product_id'] = result['product_id']
                vals_line['general_account_id'] = result['general_account_id']
                vals_line['journal_id'] = result['journal_id']
                vals_line['product_uom_id'] = result['product_uom_id']
            if 'date' in vals:
                vals_line['date'] = vals['date'][:10]
            if 'hours' in vals:
                vals_line['unit_amount'] = vals['hours']
                vals_line['amount'] = (-1) * vals['hours'] * obj.browse(cr, uid, line_id).product_id.standard_price
            obj.write(cr, uid, [line_id], vals_line, {})

        return super(project_work,self).write(cr, uid, ids, vals, context)

We need to process all the ids wherease juste the first one is treated before calling super(project_work,self).write(cr, uid, ids, vals, context).

Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) wrote :

Hello Sam,

This has been fixed by subsequent commits.
Thanks for your interest.

Changed in openobject-addons:
status: New → Fix Released
Changed in openobject-addons:
milestone: none → 6.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.