default value passed through context (in m2o field) can't override default value defined in its class
Bug #925622 reported by
Cuong
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Web (MOVED TO GITHUB) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hi,
I face an issue like this. For example,
in product class, it has a field "type". I set its default value is 'consu' type. Now in another class, I define a m2o field to product class, named 'product_id'.
===
'product_id': fields.
===
Then, when I create a product directly within form view of my class, it will pop up product dialog, 'type' field with default value of 'consu', not 'product'.
Thanks,
To post a comment you must log in.
Hi,
You're not giving any versioning information, so I take it you are reporting this for trunk.
Default values passed through the context *do* override the defaults defined in the model, but that works only when the context really contains those values! To double-check this and convince yourself, try adding the default_type value to the context of the menu action from which you reach the form view, and see how it works.
Now what you see could be a bug or simply an unsupported feature... I don't see any example of a m2o fields having a literal context passed in its declaration in the 6.1 standard addons (but there are a few one2many cases)
You may want to try the following: many2one( ...., context= "{'default_ type': 'product'}")
- set the context in the view of the model containing the product_id m2o (at XML-level) instead of doing it in Python
- use a string literal for the context instead of a python dict, e.g:
'product_id': fields.
BTW, was this working in 6.0 on both Web and GTK clients?
Thanks,