Simplify domains and states of commission to use Function fields instead of _parent

This commit is contained in:
Cédric Krier committed 2024-08-23 01:17:21 +02:00
1 parent 44e98af02b
commit 767e1cf8d2
2 files changed
+4 -7

No files matched your search

+3 -6
View File
@@ -6,7 +6,7 @@ from itertools import groupby
from trytond.model import ModelView, Workflow, fields
from trytond.modules.product import round_price
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Bool, Eval, If
from trytond.pyson import Eval
from trytond.tools import grouped_slice
from trytond.transaction import Transaction
@@ -130,13 +130,10 @@ class InvoiceLine(metaclass=PoolMeta):
principal = fields.Many2One('commission.agent', 'Commission Principal',
domain=[
('type_', '=', 'principal'),
('company', '=', Eval('_parent_invoice', {}).get('company',
Eval('company', -1))),
('company', '=', Eval('company', -1)),
],
states={
'invisible': If(Bool(Eval('_parent_invoice')),
Eval('_parent_invoice', {}).get('type') == 'in',
Eval('invoice_type') == 'in'),
'invisible': Eval('invoice_type') == 'in',
'readonly': Eval('invoice_state') != 'draft',
},
help="The principal who pays a commission for the invoice line.")
+1 -1
View File
@@ -78,7 +78,7 @@ class Line(metaclass=PoolMeta):
principal = fields.Many2One('commission.agent', 'Commission Principal',
domain=[
('type_', '=', 'principal'),
('company', '=', Eval('_parent_sale', {}).get('company', -1)),
('company', '=', Eval('company', -1)),
],
depends={'sale'},
help="The principal who pays a commission for the line.")