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

        issue11134
        review380081002
diffstat:

 configuration.py |   3 +-
 party.py         |   4 +-
 product.py       |  15 ++++------
 purchase.py      |  81 ++++++++++++++++++++-----------------------------------
 stock.py         |   6 +--
 5 files changed, 40 insertions(+), 69 deletions(-)

diffs (388 lines):

diff -r 5e347d0dfbb5 -r 9aef2dd55217 configuration.py
--- a/configuration.py  Wed Apr 06 23:37:43 2022 +0200
+++ b/configuration.py  Fri Apr 08 19:07:13 2022 +0200
@@ -70,8 +70,7 @@
             ('company', 'in', [Eval('company', -1), None]),
             ('sequence_type', '=',
                 Id('purchase', 'sequence_type_purchase')),
-            ],
-        depends=['company'])
+            ])
 
     @classmethod
     def __register__(cls, module_name):
diff -r 5e347d0dfbb5 -r 9aef2dd55217 party.py
--- a/party.py  Wed Apr 06 23:37:43 2022 +0200
+++ b/party.py  Fri Apr 08 19:07:13 2022 +0200
@@ -39,7 +39,7 @@
         context={
             'company': Eval('company', -1),
             },
-        depends=['company'])
+        depends={'company'})
     customer_code = fields.Char('Customer Code')
 
 
@@ -51,7 +51,7 @@
         context={
             'company': Eval('company', -1),
             },
-        depends=['company'])
+        depends={'company'})
     supplier_lead_time = fields.TimeDelta("Lead Time")
 
 
diff -r 5e347d0dfbb5 -r 9aef2dd55217 product.py
--- a/product.py        Wed Apr 06 23:37:43 2022 +0200
+++ b/product.py        Fri Apr 08 19:07:13 2022 +0200
@@ -30,14 +30,12 @@
             },
         domain=[
             If(~Eval('active'), ('active', '=', False), ()),
-            ],
-        depends=['purchasable', 'active'])
+            ])
     purchase_uom = fields.Many2One('product.uom', 'Purchase UOM', states={
             'invisible': ~Eval('purchasable'),
             'required': Eval('purchasable', False),
             },
-        domain=[('category', '=', Eval('default_uom_category'))],
-        depends=['purchasable', 'default_uom_category'])
+        domain=[('category', '=', Eval('default_uom_category'))])
 
     @fields.depends('default_uom', 'purchase_uom', 'purchasable')
     def on_change_default_uom(self):
@@ -127,8 +125,7 @@
         states={
             'invisible': (~Eval('purchasable', False)
                 | ~Eval('context', {}).get('company')),
-            },
-        depends=['template', 'purchasable', 'active'])
+            })
     purchase_price_uom = fields.Function(fields.Numeric(
             "Purchase Price", digits=price_digits), 'get_purchase_price_uom')
 
@@ -262,7 +259,7 @@
         context={
             'company': Eval('company', -1),
             },
-        depends=['product', 'active', 'company'])
+        depends={'company'})
     product = fields.Many2One(
         'product.product', "Variant", select=True,
         domain=[
@@ -274,14 +271,14 @@
         context={
             'company': Eval('company', -1),
             },
-        depends=['template', 'active', 'company'])
+        depends={'company'})
     party = fields.Many2One(
         'party.party', 'Supplier', required=True, ondelete='CASCADE',
         select=True,
         context={
             'company': Eval('company', -1),
             },
-        depends=['company'])
+        depends={'company'})
     name = fields.Char('Name', size=None, translate=True, select=True)
     code = fields.Char('Code', size=None, select=True)
     prices = fields.One2Many('purchase.product_supplier.price',
diff -r 5e347d0dfbb5 -r 9aef2dd55217 purchase.py
--- a/purchase.py       Wed Apr 06 23:37:43 2022 +0200
+++ b/purchase.py       Fri Apr 08 19:07:13 2022 +0200
@@ -73,7 +73,6 @@
     _states = {
         'readonly': Eval('state') != 'draft',
         }
-    _depends = ['state']
 
     company = fields.Many2One(
         'company.company', "Company", required=True, select=True,
@@ -83,24 +82,20 @@
                 | Eval('lines', [0])
                 | Eval('party', True)
                 | Eval('invoice_party', True)),
-            },
-        depends=['state'])
+            })
     number = fields.Char('Number', size=None, readonly=True, select=True)
     reference = fields.Char('Reference', select=True)
-    description = fields.Char('Description', size=None, states=_states,
-        depends=_depends)
+    description = fields.Char('Description', size=None, states=_states)
     purchase_date = fields.Date('Purchase Date',
         states={
             'readonly': ~Eval('state').in_(['draft', 'quotation']),
             'required': ~Eval('state').in_(
                 ['draft', 'quotation', 'cancelled']),
-            },
-        depends=['state'])
+            })
     payment_term = fields.Many2One('account.invoice.payment_term',
         'Payment Term', states={
             'readonly': ~Eval('state').in_(['draft', 'quotation']),
-            },
-        depends=['state'])
+            })
     party = fields.Many2One('party.party', 'Party', required=True,
         states={
             'readonly': ((Eval('state') != 'draft')
@@ -109,7 +104,7 @@
         context={
             'company': Eval('company', -1),
             },
-        select=True, depends=['state', 'company'])
+        select=True, depends={'company'})
     party_lang = fields.Function(fields.Char('Party Language'),
         'on_change_with_party_lang')
     contact = fields.Many2One(
@@ -120,7 +115,7 @@
         search_context={
             'related_party': Eval('party'),
             },
-        depends=['party', 'company'])
+        depends={'company'})
     invoice_party = fields.Many2One('party.party', "Invoice Party",
         states={
             'readonly': ((Eval('state') != 'draft')
@@ -132,7 +127,7 @@
         search_context={
             'related_party': Eval('party'),
             },
-        depends=['state', 'party', 'company'])
+        depends={'company'})
     invoice_address = fields.Many2One('party.address', 'Invoice Address',
         domain=[
             ('party', '=', If(Bool(Eval('invoice_party')),
@@ -142,19 +137,16 @@
             'readonly': Eval('state') != 'draft',
             'required': ~Eval('state').in_(
                 ['draft', 'quotation', 'cancelled']),
-            },
-        depends=['party', 'invoice_party', 'state'])
+            })
     warehouse = fields.Many2One('stock.location', 'Warehouse',
-        domain=[('type', '=', 'warehouse')], states=_states,
-        depends=_depends)
+        domain=[('type', '=', 'warehouse')], states=_states)
     currency = fields.Many2One('currency.currency', 'Currency', required=True,
         states={
             'readonly': ((Eval('state') != 'draft')
                 | (Eval('lines', [0]) & Eval('currency'))),
-            },
-        depends=['state'])
+            })
     lines = fields.One2Many('purchase.line', 'purchase', 'Lines',
-        states=_states, depends=_depends)
+        states=_states)
     comment = fields.Text('Comment')
     untaxed_amount = fields.Function(Monetary(
             "Untaxed", currency='currency', digits='currency'),
@@ -175,8 +167,7 @@
             ('manual', 'Manual'),
             ('order', 'Based On Order'),
             ('shipment', 'Based On Shipment'),
-            ], 'Invoice Method', required=True, states=_states,
-        depends=_depends)
+            ], 'Invoice Method', required=True, states=_states)
     invoice_state = fields.Selection([
             ('none', 'None'),
             ('waiting', 'Waiting'),
@@ -195,15 +186,13 @@
     origin = fields.Reference('Origin', selection='get_origin', select=True,
         states={
             'readonly': Eval('state') != 'draft',
-            },
-        depends=['state'])
+            })
     delivery_date = fields.Date(
         "Delivery Date",
         states={
             'readonly': Eval('state').in_([
                     'processing', 'done', 'cancelled']),
             },
-        depends=['state'],
         help="The default delivery date for each line.")
     shipment_state = fields.Selection([
             ('none', 'None'),
@@ -236,7 +225,7 @@
             ('cancelled', "Cancelled"),
             ], "State", readonly=True, required=True, sort=False)
 
-    del _states, _depends
+    del _states
 
     @classmethod
     def __setup__(cls):
@@ -1038,8 +1027,7 @@
         states={
             'readonly': ((Eval('purchase_state') != 'draft')
                 & Bool(Eval('purchase'))),
-            },
-        depends=['purchase_state'])
+            })
     type = fields.Selection([
         ('line', 'Line'),
         ('subtotal', 'Subtotal'),
@@ -1048,22 +1036,19 @@
         ], 'Type', select=True, required=True,
         states={
             'readonly': Eval('purchase_state') != 'draft',
-            },
-        depends=['purchase_state'])
+            })
     quantity = fields.Float(
         "Quantity", digits='unit',
         states={
             'invisible': Eval('type') != 'line',
             'required': Eval('type') == 'line',
             'readonly': Eval('purchase_state') != 'draft',
-            },
-        depends=['type', 'purchase_state'])
+            })
     actual_quantity = fields.Float(
         "Actual Quantity", digits='unit', readonly=True,
         states={
             'invisible': Eval('type') != 'line',
-            },
-        depends=['type'])
+            })
     unit = fields.Many2One('product.uom', 'Unit',
         ondelete='RESTRICT',
         states={
@@ -1075,8 +1060,7 @@
             If(Bool(Eval('product_uom_category')),
                 ('category', '=', Eval('product_uom_category')),
                 ('category', '!=', -1)),
-            ],
-        depends=['product', 'type', 'product_uom_category', 'purchase_state'])
+            ])
     product = fields.Many2One('product.product', 'Product',
         ondelete='RESTRICT',
         domain=[
@@ -1107,7 +1091,7 @@
             'taxes': Eval('taxes', []),
             'quantity': Eval('quantity'),
             },
-        depends=['type', 'purchase_state', 'product_supplier', 'company'])
+        depends={'company'})
     product_supplier = fields.Many2One(
         'purchase.product_supplier', "Supplier's Product",
         ondelete='RESTRICT',
@@ -1126,8 +1110,7 @@
         states={
             'invisible': Eval('type') != 'line',
             'readonly': Eval('purchase_state') != 'draft',
-            },
-        depends=['product', 'type', 'purchase_state', 'purchase'])
+            })
     product_uom_category = fields.Function(
         fields.Many2One('product.uom.category', 'Product Uom Category'),
         'on_change_with_product_uom_category')
@@ -1137,18 +1120,17 @@
             'invisible': Eval('type') != 'line',
             'required': Eval('type') == 'line',
             'readonly': Eval('purchase_state') != 'draft',
-            }, depends=['type', 'purchase_state'])
+            })
     amount = fields.Function(Monetary(
             "Amount", currency='currency', digits='currency',
             states={
                 'invisible': ~Eval('type').in_(['line', 'subtotal']),
-                },
-            depends=['type']), 'get_amount')
+                }),
+        'get_amount')
     description = fields.Text('Description', size=None,
         states={
             'readonly': Eval('purchase_state') != 'draft',
-            },
-        depends=['purchase_state'])
+            })
     summary = fields.Function(fields.Char('Summary'), 'on_change_with_summary')
     note = fields.Text('Note')
     taxes = fields.Many2Many('purchase.line-account.tax',
@@ -1163,8 +1145,7 @@
         states={
             'invisible': Eval('type') != 'line',
             'readonly': Eval('purchase_state') != 'draft',
-            },
-        depends=['type', 'purchase_state', 'purchase'])
+            })
     invoice_lines = fields.One2Many('account.invoice.line', 'origin',
         'Invoice Lines', readonly=True)
     moves = fields.One2Many('stock.move', 'origin', 'Moves', readonly=True)
@@ -1185,8 +1166,7 @@
                     | (Eval('delivery_date_edit', False)
                         & ~Eval('purchase_state').in_(
                             ['processing', 'done', 'cancelled']))),
-                },
-            depends=['type', 'delivery_date_edit', 'purchase_state']),
+                }),
         'on_change_with_delivery_date')
     delivery_date_edit = fields.Boolean(
         "Edit Delivery Date",
@@ -1195,7 +1175,6 @@
             'readonly': Eval('purchase_state').in_([
                     'processing', 'done', 'cancelled']),
             },
-        depends=['type', 'purchase_state'],
         help="Check to edit the delivery date.")
     delivery_date_store = fields.Date(
         "Delivery Date",
@@ -1206,8 +1185,7 @@
                     ['processing', 'done', 'cancelled'])),
             'readonly': Eval('purchase_state').in_([
                     'processing', 'done', 'cancelled']),
-            },
-        depends=['type', 'delivery_date_edit', 'purchase_state'])
+            })
     purchase_state = fields.Function(
         fields.Selection('get_purchase_states', 'Purchase State'),
         'on_change_with_purchase_state')
@@ -1878,7 +1856,7 @@
     __name__ = 'purchase.handle.shipment.exception.ask'
     recreate_moves = fields.Many2Many(
         'stock.move', None, None, 'Recreate Moves',
-        domain=[('id', 'in', Eval('domain_moves'))], depends=['domain_moves'],
+        domain=[('id', 'in', Eval('domain_moves'))],
         help=('The selected moves will be recreated. '
             'The other ones will be ignored.'))
     domain_moves = fields.Many2Many(
@@ -1942,7 +1920,6 @@
     recreate_invoices = fields.Many2Many(
         'account.invoice', None, None, 'Recreate Invoices',
         domain=[('id', 'in', Eval('domain_invoices'))],
-        depends=['domain_invoices'],
         help=('The selected invoices will be recreated. '
             'The other ones will be ignored.'))
     domain_invoices = fields.Many2Many(
diff -r 5e347d0dfbb5 -r 9aef2dd55217 stock.py
--- a/stock.py  Wed Apr 06 23:37:43 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:13 2022 +0200
@@ -50,8 +50,7 @@
                 add_remove,
                 cls.incoming_moves.add_remove,
                 ]
-        if 'supplier' not in cls.incoming_moves.depends:
-            cls.incoming_moves.depends.append('supplier')
+        cls.incoming_moves.depends.add('supplier')
 
     @classmethod
     @ModelView.button
@@ -170,7 +169,7 @@
             context={
                 'company': Eval('company', -1),
                 },
-            depends=['company']),
+            depends={'company'}),
         'get_supplier', searcher='search_supplier')
     purchase_exception_state = fields.Function(fields.Selection([
         ('', ''),
@@ -274,5 +273,4 @@
             ('type', '=', 'storage'),
             ('parent', 'child_of', [Eval('id', -1)]),
             ],
-        depends=['type', 'id'],
         help='If empty the Storage location is used.')

Reply via email to