_constraints problem with inheritance (trunk)

Bug #330427 reported by Dukai Gábor
2
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Invalid
Undecided
Unassigned

Bug Description

Hi!
Trunk version.
I start with an example. In the original module stock.move has 2 constraints for the field 'prodlot_id'. When using _inherit with stock.move. in theory additional constraints could be defined. But it's not possible to add one more constraint with the same field, 'prodlot_id' because the code in osv.createInstance() messes up _constraints. It is not able to handle 2 or more constraints with the same fields.

Look at the code in osv.createInstance():
                    if s=='_constraints':
                        for c in cls.__dict__.get(s, []):
                            exist = False
                            for c2 in range(len(new)):
                                if new[c2][2]==c[2]:
                                    new[c2] = c
                                    exist = True
                                    break
                            if not exist:
                                new.append(c)

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hey,

I'm not alone! I confirm this bug. That's why I had to comment out the extra constraints I put in the extra-addons/mrp_prodlot_autosplit module! I think I remember that if I activate my new constraint, then the original constraints won't be checked. A major issue for module implementers, hope you find a fix.

Raphaël Valyi.

Revision history for this message
Dukai Gábor (gdukai) wrote :

It looks like the list of fields that has to be defined for a constraint is only used for display purposes. As a workaround, change the list of fields to something different than the one in the original module and it should work.

Revision history for this message
Bruno Hostalery (istf) wrote :

Hello,
module actually in the trunk can't be install without modify your comment (openerp says comment is not terminate).

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

prodlot_id is not the name of the field, but the name of the constraint. Just use another name.

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