← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 798190] Re: hr_timesheet_sheet: can not write attendance

 

Hi Vishal,
Thank you for the video ;-) I guess my description was really incomplete. 

It does throw an exception when you call the write method from another
inherited object (in my case: project.task.work). I could not reproduce
it yet, but I think I may know the source of the "problem" now.

When you call object.browse(cr, uid, ids) sometimes you get back an
object of type openerp.osv.orm.browse_record which does then throw an
exception in a for loop (no list) instead of an object of type
openerp.osv.orm.browse_record_list which is the intended object for a
loop.

I do not know if this behavior of the general method browse is correct but it does stop the code flow under certain conditions (probably when there are no results) which happened somewhere else in my code as well.
I solved it for myself to check before looping an object if it is an instance of osv.orm.browse_record_list.

Is it correct that you can get back an object of type
osv.orm.browse_record when you call self.browse?

If so what is the advantage to get back such an object?

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/798190

Title:
  hr_timesheet_sheet: can not write attendance

Status in OpenERP Modules (addons):
  Incomplete

Bug description:
  Exception is thrown when there is no sheet_id linked

      def write(self, cr, uid, ids, vals, context=None):
          if context is None:
              context = {}
          self._check(cr, uid, ids) <-- exception
          res = super(hr_attendance,self).write(cr, uid, ids, vals, context=context)
          .
          .
          .

  _check should be adapted like other methods

      def _check(self, cr, uid, ids, context=None):
          if context is None:
              context = {}
          if 'sheet_id' in context:
              for att in self.browse(cr, uid, ids, context=context):
                  if att.sheet_id and att.sheet_id.state not in ('draft', 'new'):
                      raise osv.except_osv(_('Error !'), _('You cannot modify an entry in a confirmed timesheet !'))
          return True

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/798190/+subscriptions


References