changeset 173e32a6b419 in modules/commission:default
details: 
https://hg.tryton.org/modules/commission?cmd=changeset&node=173e32a6b419
description:
        Send only the required fields when fetching a readonly view definition

        issue11134
        review380081002
diffstat:

 commission.py           |  25 ++++++++-----------------
 commission_reporting.py |   6 ++----
 invoice.py              |   2 --
 sale.py                 |   3 +--
 4 files changed, 11 insertions(+), 25 deletions(-)

diffs (168 lines):

diff -r c3730c2d1d58 -r 173e32a6b419 commission.py
--- a/commission.py     Wed Apr 06 23:37:42 2022 +0200
+++ b/commission.py     Fri Apr 08 19:07:13 2022 +0200
@@ -33,7 +33,7 @@
         context={
             'company': Eval('company', -1),
             },
-        depends=['company'],
+        depends={'company'},
         help="The party for whom the commission is calculated.")
     type_ = fields.Selection([
             ('agent', 'Agent Of'),
@@ -154,7 +154,6 @@
                 ('start_date', '<=', Eval('end_date')),
                 ()),
             ],
-        depends=['end_date'],
         help="The first date that the agent will be considered for selection.")
     end_date = fields.Date(
         "End Date",
@@ -163,22 +162,20 @@
                 ('end_date', '>=', Eval('start_date')),
                 ()),
             ],
-        depends=['start_date'],
         help="The last date that the agent will be considered for selection.")
     party = fields.Many2One(
         'party.party', "Party", ondelete='CASCADE', select=True,
         context={
             'company': Eval('company', -1),
             },
-        depends=['company'])
+        depends={'company'})
     company = fields.Function(fields.Many2One('company.company', "Company"),
         'on_change_with_company', searcher='search_company')
     employee = fields.Many2One(
         'company.employee', "Employee", select=True,
         domain=[
             ('company', '=', Eval('company')),
-            ],
-        depends=['company'])
+            ])
 
     @classmethod
     def __setup__(cls):
@@ -334,26 +331,23 @@
     _readonly_states = {
         'readonly': Bool(Eval('invoice_line')),
         }
-    _readonly_depends = ['invoice_line']
     origin = fields.Reference('Origin', selection='get_origin', select=True,
         readonly=True,
         help="The source of the commission.")
     date = fields.Date('Date', select=True, states=_readonly_states,
-        depends=_readonly_depends,
         help="When the commission is due.")
     agent = fields.Many2One('commission.agent', 'Agent', required=True,
-        states=_readonly_states, depends=_readonly_depends)
+        states=_readonly_states)
     product = fields.Many2One('product.product', 'Product', required=True,
-        states=_readonly_states, depends=_readonly_depends,
+        states=_readonly_states,
         help="The product that is used on the invoice line.")
     base_amount = Monetary(
         "Base Amount", currency='currency', digits='currency',
-        states=_readonly_states,
-        depends=_readonly_depends)
+        states=_readonly_states)
     amount = Monetary(
         "Amount", currency='currency', required=True, digits=price_digits,
         domain=[('amount', '!=', 0)],
-        states=_readonly_states, depends=_readonly_depends)
+        states=_readonly_states)
     currency = fields.Function(fields.Many2One('currency.currency',
             'Currency'), 'on_change_with_currency')
     type_ = fields.Function(fields.Selection([
@@ -361,7 +355,7 @@
                 ('out', 'Outgoing'),
                 ], 'Type'), 'on_change_with_type_')
     invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line',
-        readonly=True, depends=['amount', 'type_'])
+        readonly=True)
     invoice_state = fields.Function(fields.Selection([
                 ('', ''),
                 ('invoiced', 'Invoiced'),
@@ -586,14 +580,12 @@
             If(Eval('to') & Eval('from_'), [('from_', '<=', Eval('to'))],
                 []),
             ],
-        depends=['to'],
         help="Limit to commissions from this date.")
     to = fields.Date('To',
         domain=[
             If(Eval('from_') & Eval('to'), [('to', '>=', Eval('from_'))],
                 []),
             ],
-        depends=['from_'],
         help="Limit to commissions to this date.")
     type_ = fields.Selection([
             ('in', 'Incoming'),
@@ -609,7 +601,6 @@
             If(Eval('type_') == 'out',
                 ('type_', '=', 'agent'), ()),
         ],
-        depends=['type_'],
         help="Limit to commissions for these agents.\n"
         "If empty all agents of the selected type are used.")
 
diff -r c3730c2d1d58 -r 173e32a6b419 commission_reporting.py
--- a/commission_reporting.py   Wed Apr 06 23:37:42 2022 +0200
+++ b/commission_reporting.py   Fri Apr 08 19:07:13 2022 +0200
@@ -200,15 +200,13 @@
             If(Eval('to_date') & Eval('from_date'),
                 ('from_date', '<=', Eval('to_date')),
                 ()),
-            ],
-        depends=['to_date'])
+            ])
     to_date = fields.Date("To Date",
         domain=[
             If(Eval('from_date') & Eval('to_date'),
                 ('to_date', '>=', Eval('from_date')),
                 ()),
-            ],
-        depends=['from_date'])
+            ])
     period = fields.Selection([
             ('year', "Year"),
             ('month', "Month"),
diff -r c3730c2d1d58 -r 173e32a6b419 invoice.py
--- a/invoice.py        Wed Apr 06 23:37:42 2022 +0200
+++ b/invoice.py        Fri Apr 08 19:07:13 2022 +0200
@@ -22,7 +22,6 @@
             'invisible': Eval('type') == 'in',
             'readonly': Eval('state', '') != 'draft',
             },
-        depends=['type', 'company', 'state'],
         help="The agent who receives a commission for the invoice.")
 
     @classmethod
@@ -130,7 +129,6 @@
                 Eval('_parent_invoice', {}).get('type') == 'in',
                 Eval('invoice_type') == 'in'),
             },
-        depends=['invoice_type', 'company', 'invoice'],
         help="The principal who pays a commission for the invoice line.")
     commissions = fields.One2Many('commission', 'origin', 'Commissions',
         readonly=True,
diff -r c3730c2d1d58 -r 173e32a6b419 sale.py
--- a/sale.py   Wed Apr 06 23:37:42 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:13 2022 +0200
@@ -18,7 +18,6 @@
         states={
             'readonly': ~Eval('state').in_(['draft', 'quotation']),
             },
-        depends=['state', 'company'],
         help="The agent who receives a commission for the sale.")
 
     def create_invoice(self):
@@ -81,7 +80,7 @@
             ('type_', '=', 'principal'),
             ('company', '=', Eval('_parent_sale', {}).get('company', -1)),
             ],
-        depends=['sale'],
+        depends={'sale'},
         help="The principal who pays a commission for the line.")
 
     def get_invoice_line(self):

Reply via email to