changeset f9a88afb2a3f in modules/stock:6.0
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=f9a88afb2a3f
description:
Fully set product domain of move on setup
When modify in __setup__ the domain of a field defined in the same
class, this
alter the original copy of the field. So the domain is appended to
itself on
each __setup__ call (each time the model is extended by another module).
issue10406
review336241002
(grafted from 3670b1a582ecf41612f1f84b73b8ab68f8bf8b1b)
diffstat:
move.py | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diffs (36 lines):
diff -r e6510e90397d -r f9a88afb2a3f move.py
--- a/move.py Mon May 03 15:42:55 2021 +0200
+++ b/move.py Sat May 15 09:20:43 2021 +0200
@@ -172,16 +172,10 @@
_order_name = 'product'
product = fields.Many2One("product.product", "Product", required=True,
select=True, states=STATES,
- domain=[
- If(Bool(Eval('product_uom_category'))
- & ~Eval('state').in_(['done', 'cancelled']),
- ('default_uom_category', '=', Eval('product_uom_category')),
- ())
- ],
context={
'company': Eval('company', -1),
},
- depends=DEPENDS + ['product_uom_category', 'company'],
+ depends=DEPENDS + ['company'],
help="The product that the move is associated with.")
product_uom_category = fields.Function(
fields.Many2One('product.uom.category', 'Product Uom Category'),
@@ -305,9 +299,13 @@
def __setup__(cls):
super(Move, cls).__setup__()
cls.product.domain = [
- cls.product.domain,
+ If(Bool(Eval('product_uom_category'))
+ & ~Eval('state').in_(['done', 'cancelled']),
+ ('default_uom_category', '=', Eval('product_uom_category')),
+ ()),
('type', 'in', cls.get_product_types()),
]
+ cls.product.depends += ['product_uom_category']
cls._deny_modify_assigned = set(['product', 'uom', 'quantity',
'from_location', 'to_location', 'company', 'currency'])
cls._deny_modify_done_cancel = (cls._deny_modify_assigned