diff --git a/move.py b/move.py index c378285f2a..2fdb9f69bd 100644 --- a/move.py +++ b/move.py @@ -245,14 +245,11 @@ class Move(Workflow, ModelSQL, ModelView): ('cancelled', 'Cancelled'), ], 'State', select=True, readonly=True, help="The current state of the stock move.") - company = fields.Many2One('company.company', 'Company', required=True, + company = fields.Many2One( + 'company.company', "Company", required=True, states={ 'readonly': Eval('state') != 'draft', }, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], depends=['state'], help="The company the stock move is associated with.") unit_price = fields.Numeric('Unit Price', digits=price_digits, diff --git a/period.py b/period.py index 70bcf6753f..54e5f4bd92 100644 --- a/period.py +++ b/period.py @@ -6,7 +6,7 @@ from sql import Literal, For from trytond.i18n import gettext from trytond.model import Workflow, ModelView, ModelSQL, fields -from trytond.pyson import Eval, If +from trytond.pyson import Eval from trytond.transaction import Transaction from trytond.pool import Pool from trytond.tools import grouped_slice @@ -21,11 +21,8 @@ class Period(Workflow, ModelSQL, ModelView): 'readonly': Eval('state') == 'closed', }, depends=['state'], help="When the stock period ends.") - company = fields.Many2One('company.company', 'Company', required=True, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], + company = fields.Many2One( + 'company.company', "Company", required=True, help="The company the stock period is associated with.") caches = fields.One2Many('stock.period.cache', 'period', 'Caches', readonly=True) diff --git a/shipment.py b/shipment.py index 4b4df948a3..887367cdba 100644 --- a/shipment.py +++ b/shipment.py @@ -128,14 +128,11 @@ class ShipmentIn(ShipmentMixin, Workflow, ModelSQL, ModelView): 'readonly': Eval('state') != 'draft', }, depends=['state'], help="When the stock is expected to be received.") - company = fields.Many2One('company.company', 'Company', required=True, + company = fields.Many2One( + 'company.company', "Company", required=True, states={ 'readonly': Eval('state') != 'draft', }, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], depends=['state'], help="The company the shipment is associated with.") reference = fields.Char("Reference", size=None, select=True, @@ -576,14 +573,11 @@ class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): 'readonly': Eval('state') != 'draft', }, depends=['state'], help="When the stock is expected to be returned.") - company = fields.Many2One('company.company', 'Company', required=True, + company = fields.Many2One( + 'company.company', "Company", required=True, states={ 'readonly': Eval('state') != 'draft', }, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], depends=['state'], help="The company the shipment is associated with.") number = fields.Char('Number', size=None, select=True, readonly=True, @@ -944,14 +938,11 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): 'readonly': Eval('state') != 'draft', }, depends=['state'], help="When the stock is expected to be sent.") - company = fields.Many2One('company.company', 'Company', required=True, + company = fields.Many2One( + 'company.company', "Company", required=True, states={ 'readonly': Eval('state') != 'draft', }, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], depends=['state'], help="The company the shipment is associated with.") customer = fields.Many2One('party.party', 'Customer', required=True, @@ -1592,14 +1583,11 @@ class ShipmentOutReturn(ShipmentMixin, Workflow, ModelSQL, ModelView): 'readonly': Eval('state') != 'draft', }, depends=['state'], help="When the stock is expected to be returned.") - company = fields.Many2One('company.company', 'Company', required=True, + company = fields.Many2One( + 'company.company', "Company", required=True, states={ 'readonly': Eval('state') != 'draft', }, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], depends=['state'], help="The company the shipment is associated with.") customer = fields.Many2One('party.party', 'Customer', required=True, @@ -2029,14 +2017,11 @@ class ShipmentInternal(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): }, depends=['state'], help="When the stock is expected to be sent.") - company = fields.Many2One('company.company', 'Company', required=True, + company = fields.Many2One( + 'company.company', "Company", required=True, states={ 'readonly': ~Eval('state').in_(['request', 'draft']), }, - domain=[ - ('id', If(Eval('context', {}).contains('company'), '=', '!='), - Eval('context', {}).get('company', -1)), - ], depends=['state'], help="The company the shipment is associated with.") number = fields.Char('Number', size=None, select=True, readonly=True,