← Back to team overview

openerp-india team mailing list archive

[Bug 1030864] Re: [6.0] constraints on one2many validated too early

 

[Expired for OpenERP Server because there has been no activity for 60
days.]

** Changed in: openobject-server
       Status: Incomplete => Expired

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1030864

Title:
  [6.0] constraints on one2many validated too early

Status in OpenERP Server:
  Expired

Bug description:
  I have a one2many "sub objects" embedded in the related "parent
  object" form view.

  As "required" does not work on one2many (compare bug 1013636), I have
  a constraint checking that at least one item exists in this relation:

  def _check_related(self, cr, uid, ids):
          for i in self.browse(cr, uid, ids):
                  if (len(i.related_ids)<1):
                      return False
          return True
      _constraints = [
          (_check_related, 'You need to set at least one related object.', ['related_ids']),
      ]

  
  But when creating a new parent object, and inline creating new related sub objects, the constraint is checked before the sub objects are stored and therefore returns an error, as i.related_ids is still empty.

  Constraint checking should be applied to the content that would be
  stored to the database if all is ok, not to an intermediate state
  somewhere in between.

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


References