changeset fb0bd2475b32 in modules/stock_quantity_early_planning:default
details: 
https://hg.tryton.org/modules/stock_quantity_early_planning?cmd=changeset&node=fb0bd2475b32
description:
        Use dictionary as domain for Reference field

        issue11074
        review383911002
diffstat:

 stock.py |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r db14ed384667 -r fb0bd2475b32 stock.py
--- a/stock.py  Sun Jan 23 13:34:13 2022 +0100
+++ b/stock.py  Thu Feb 03 23:05:47 2022 +0100
@@ -21,9 +21,20 @@
         'company.company', "Company", required=True, select=True)
     origin = fields.Reference(
         "Origin", 'get_origins', required=True,
-        domain=[
-            ('company', '=', Eval('company', -1)),
-            ],
+        domain={
+            'stock.move': [
+                ('company', '=', Eval('company', -1)),
+                ],
+            'stock.shipment.out': [
+                ('company', '=', Eval('company', -1)),
+                ],
+            'stock.shipment.in.return': [
+                ('company', '=', Eval('company', -1)),
+                ],
+            'stock.shipment.internal': [
+                ('company', '=', Eval('company', -1)),
+                ],
+            },
         depends=['company'])
     planned_date = fields.Function(
         fields.Date("Planned Date"),
@@ -471,6 +482,13 @@
     __name__ = 'stock.quantity.early_plan'
 
     @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.origin.domain['production'] = [
+            ('company', '=', Eval('company', -1)),
+            ]
+
+    @classmethod
     def _get_origins(cls):
         return super()._get_origins() + ['production']
 

Reply via email to