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

        issue11074
        review383911002
diffstat:

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

diffs (38 lines):

diff -r 13af70cf373a -r 30ef9b8daf8e stock.py
--- a/stock.py  Sat Dec 18 16:34:36 2021 +0100
+++ b/stock.py  Thu Feb 03 23:05:47 2022 +0100
@@ -26,9 +26,17 @@
         'company.company', "Company", required=True, select=True)
     origin = fields.Reference(
         "Origin", 'get_origins', required=True,
-        domain=[
-            ('company', '=', Eval('company', -1)),
-            ],
+        domain={
+            '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"),
@@ -316,6 +324,13 @@
     __name__ = 'stock.quantity.issue'
 
     @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