[6.0] constraints on one2many validated too early

Bug #1030864 reported by Marco Dieckhoff
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Expired
Undecided
Unassigned

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.

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Marco Dieckhoff ,

I have checked this issue with trunk ,6.1 as well as 6.0.But I did not face any problem
like yours.I have applyed test case with res.partner for address
field and hr_department for member_ids field as yous.for 6.1 it not
working with partner because of lp:980529 and for hr constriant working fine and constrint is execute after saving a record.As per your bug discription constraint is execute before a saving record.
So would you please provide detail information regarding this issue.

Thanks and waiting for reply!

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in openobject-server:
status: Incomplete → Expired
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.