[7.0 ] context is not passed to constraints function

Bug #1152204 reported by Nicolas Bessi - Camptocamp
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

when you redefine a constraint function used in _constraints property of Model Class. The context passed to the CRUD function is not transmitted to constraint functions. It is probabely the same if the function in redefined.

Regards

Nicolas

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

Hello Nicolas,

I think this one is a duplicate of some invalid bug. Indeed, model constraints apply to the persistent data in OpenERP philosophy. That is you could just pull the data from the database and apply constraint validation upon these data with no context.
Whereas context is something related to the transient context of the user interaction (menu, time etc...).
So I think it's a bit normal I think.

Now, yes, OpenObject (remember it's supposed to be a framework) totally lacks handy object life cycle hooks like a validate method that would validate data before saving both for write and create and considering the context. Well, you can always roll your own one, it's just ugly but ultimately it get the job done.

Hope this helps. Then eventually one could invalidate that bug.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Yes, it's lp:891592. I still support it for various reasons, such as being able to raise translatable errors from the constraint itself or being able to import slightly corrupt data for migration purposes (by means of checking for a custom context key that is passed at import time).

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.