o2m and m2m validator class have an attribute initialized to a mutable value!
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Web Client |
Confirmed
|
Low
|
OpenERP Publisher's Warranty Team |
Bug Description
The code below is dangerous and I've come into a nasty bug because of it. It can even silently add unwanted values in other fields (that's why I've checked the security box).
openerp-
class one2many(
if_empty = []
and openerp-
class many2many(
if_empty = [(6, 0, [])]
If you just get the default empty values in your code and append elements into it, you'll get the appended elements in all the other fields of the same type (m2m or o2m).
The correct fix is to replace :
if_empty = []
with :
@property
def if_empty(self):
return []
and :
if_empty = [(6, 0, [])]
with :
@property
def if_empty(self):
return [(6, 0, [])]
(or alternatively you can initialize the value in the __init__ method).
Related branches
- OpenERP Core Team: Pending requested
-
Diff: 25 lines (+6/-2)1 file modifiedaddons/openerp/validators.py (+6/-2)
visibility: | private → public |
Here is the branch that fixes the bug: /code.launchpad .net/~anybox/ openobject- client- web/6.0- bug-906449
https:/