diff --git a/inventory.py b/inventory.py
index be89bd81b5..2669051172 100644
--- a/inventory.py
+++ b/inventory.py
@@ -3,9 +3,10 @@
'Inventory'
from trytond.model import ModelWorkflow, ModelView, ModelSQL, fields
from trytond.wizard import Wizard
+from trytond.pyson import Not, Equal, Eval, Or, Bool
STATES = {
- 'readonly': "state != 'draft'",
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
}
@@ -18,19 +19,22 @@ class Inventory(ModelWorkflow, ModelSQL, ModelView):
location = fields.Many2One(
'stock.location', 'Location', required=True,
domain=[('type', '=', 'storage')], states={
- 'readonly': "state != 'draft' or bool(lines)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('lines'))),
})
date = fields.Date('Date', required=True, states={
- 'readonly': "state != 'draft' or bool(lines)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('lines'))),
})
lost_found = fields.Many2One(
'stock.location', 'Lost and Found', required=True,
domain=[('type', '=', 'lost_found')], states=STATES)
lines = fields.One2Many(
'stock.inventory.line', 'inventory', 'Lines', states=STATES)
- company = fields.Many2One(
- 'company.company', 'Company', required=True, states={
- 'readonly': "state != 'draft' or bool(lines)",
+ company = fields.Many2One('company.company', 'Company', required=True,
+ states={
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('lines'))),
})
state = fields.Selection([
('draft', 'Draft'),
@@ -199,8 +203,8 @@ class InventoryLine(ModelSQL, ModelView):
unit_digits = fields.Function('get_unit_digits', type='integer',
string='Unit Digits')
expected_quantity = fields.Float('Expected Quantity',
- digits="(16, unit_digits)", readonly=True)
- quantity = fields.Float('Quantity', digits="(16, unit_digits)")
+ digits=(16, Eval('unit_digits', 2)), readonly=True)
+ quantity = fields.Float('Quantity', digits=(16, Eval('unit_digits', 2)))
move = fields.Many2One('stock.move', 'Move', readonly=True)
inventory = fields.Many2One('stock.inventory', 'Inventory', required=True,
ondelete='CASCADE')
diff --git a/inventory.xml b/inventory.xml
index 6a41b560d3..c52bcf5d82 100644
--- a/inventory.xml
+++ b/inventory.xml
@@ -27,7 +27,7 @@ this repository contains the full copyright notices and license terms. -->
@@ -37,12 +37,12 @@ this repository contains the full copyright notices and license terms. -->
+ states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
+ icon="'tryton-cancel'" />
+ states="{'invisible': In(Eval('state'), ['done','cancel']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
+ icon="'tryton-ok'"/>
diff --git a/location.py b/location.py
index 95b3efa4ed..3ec8e1567f 100644
--- a/location.py
+++ b/location.py
@@ -1,13 +1,14 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level
-#of this repository contains the full copyright notices and license terms.
+#This file is part of Tryton. The COPYRIGHT file at the top level of
+#this repository contains the full copyright notices and license terms.
"Wharehouse"
from trytond.model import ModelView, ModelSQL, fields
from trytond.wizard import Wizard
from trytond.backend import TableHandler
+from trytond.pyson import Not, Bool, Eval, Equal, PYSONEncoder, Date
import datetime
STATES = {
- 'readonly': "not active",
+ 'readonly': Not(Bool(Eval('active'))),
}
@@ -21,8 +22,8 @@ class Location(ModelSQL, ModelView):
active = fields.Boolean('Active', select=1)
address = fields.Many2One("party.address", "Address",
states={
- 'invisible': "type != 'warehouse'",
- 'readonly': "not active",
+ 'invisible': Not(Equal(Eval('type'), 'warehouse')),
+ 'readonly': Not(Bool(Eval('active'))),
})
type = fields.Selection([
('supplier', 'Supplier'),
@@ -40,34 +41,37 @@ class Location(ModelSQL, ModelView):
childs = fields.One2Many("stock.location", "parent", "Children")
input_location = fields.Many2One(
"stock.location", "Input", states={
- 'invisible': "type != 'warehouse'",
- 'readonly': "not active",
- 'required': "type == 'warehouse'",
+ 'invisible': Not(Equal(Eval('type'), 'warehouse')),
+ 'readonly': Not(Bool(Eval('active'))),
+ 'required': Equal(Eval('type'), 'warehouse'),
},
- domain=["('type','=','storage')",
+ domain=[
+ ('type','=','storage'),
['OR',
- "('parent', 'child_of', [active_id])",
- "('parent', '=', False)"]])
+ ('parent', 'child_of', [Eval('active_id')]),
+ ('parent', '=', False),
+ ],
+ ])
output_location = fields.Many2One(
"stock.location", "Output", states={
- 'invisible': "type != 'warehouse'",
- 'readonly': "not active",
- 'required': "type == 'warehouse'",
+ 'invisible': Not(Equal(Eval('type'), 'warehouse')),
+ 'readonly': Not(Bool(Eval('active'))),
+ 'required': Equal(Eval('type'), 'warehouse'),
},
- domain=["('type','=','storage')",
+ domain=[('type','=','storage'),
['OR',
- "('parent', 'child_of', [active_id])",
- "('parent', '=', False)"]])
+ ('parent', 'child_of', [Eval('active_id')]),
+ ('parent', '=', False)]])
storage_location = fields.Many2One(
"stock.location", "Storage", states={
- 'invisible': "type != 'warehouse'",
- 'readonly': "not active",
- 'required': "type == 'warehouse'",
+ 'invisible': Not(Equal(Eval('type'), 'warehouse')),
+ 'readonly': Not(Bool(Eval('active'))),
+ 'required': Equal(Eval('type'), 'warehouse'),
},
- domain=["('type','=','storage')",
+ domain=[('type','=','storage'),
['OR',
- "('parent', 'child_of', [active_id])",
- "('parent', '=', False)"]])
+ ('parent', 'child_of', [Eval('active_id')]),
+ ('parent', '=', False)]])
quantity = fields.Function('get_quantity', type='float', string='Quantity')
forecast_quantity = fields.Function('get_quantity', type='float',
string='Forecast Quantity')
@@ -385,10 +389,11 @@ class OpenProduct(Wizard):
ctx = {}
ctx['locations'] = data['ids']
if data['form']['forecast_date']:
- ctx['stock_date_end'] = data['form']['forecast_date']
+ date = data['form']['forecast_date']
else:
- ctx['stock_date_end'] = datetime.date.max
- res['context'] = str(ctx)
+ date = datetime.date.max
+ ctx['stock_date_end'] = Date(date.year, date.month, date.day)
+ res['pyson_context'] = PYSONEncoder().encode(ctx)
return res
diff --git a/move.py b/move.py
index ed419412d1..46461412e7 100644
--- a/move.py
+++ b/move.py
@@ -3,10 +3,11 @@
"Move"
from trytond.model import ModelView, ModelSQL, fields
from trytond.backend import TableHandler
+from trytond.pyson import In, Eval, Not, In, Equal, If, Get, Bool
from decimal import Decimal
STATES = {
- 'readonly': "(state in ('cancel', 'done'))",
+ 'readonly': In(Eval('state'), ['cancel', 'done']),
}
@@ -20,23 +21,25 @@ class Move(ModelSQL, ModelView):
'from_location', 'to_location'],
domain=[('type', '!=', 'service')])
uom = fields.Many2One("product.uom", "Uom", required=True, states=STATES,
- domain=["('category', '=', " \
- "(product, 'product.default_uom.category'))"],
- context="{'category': (product, 'product.default_uom.category')}",
+ domain=[
+ ('category', '=',
+ (Eval('product'), 'product.default_uom.category')),
+ ],
+ context={
+ 'category': (Eval('product'), 'product.default_uom.category'),
+ },
on_change=['product', 'currency', 'uom', 'company',
'from_location', 'to_location'])
unit_digits = fields.Function('get_unit_digits', type='integer',
string='Unit Digits', on_change_with=['uom'])
quantity = fields.Float("Quantity", required=True,
- digits="(16, unit_digits)", states=STATES)
+ digits=(16, Eval('unit_digits', 2)), states=STATES)
from_location = fields.Many2One("stock.location", "From Location", select=1,
required=True, states=STATES,
- domain=["('type', 'not in', " \
- "('warehouse', 'view'))"])
+ domain=[('type', 'not in', ('warehouse', 'view'))])
to_location = fields.Many2One("stock.location", "To Location", select=1,
required=True, states=STATES,
- domain=["('type', 'not in', " \
- "('warehouse', 'view'))"])
+ domain=[('type', 'not in', ('warehouse', 'view'))])
shipment_in = fields.Many2One('stock.shipment.in', 'Supplier Shipment',
readonly=True, select=1, ondelete='CASCADE')
shipment_out = fields.Many2One('stock.shipment.out', 'Customer Shipment',
@@ -59,21 +62,23 @@ class Move(ModelSQL, ModelView):
], 'State', select=1, readonly=True)
company = fields.Many2One('company.company', 'Company', required=True,
states={
- 'readonly': "state != 'draft'",
- }, domain=["('id', 'company' in context and '=' or '!=', " \
- "context.get('company', 0))"])
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ }, domain=[
+ ('id', If(In('company', Eval('context', {})), '=', '!='),
+ Get(Eval('context', {}), 'company', 0)),
+ ])
unit_price = fields.Numeric('Unit Price', digits=(16, 4),
states={
- 'invisible': "not unit_price_required",
- 'required': "unit_price_required",
- 'readonly': "state != 'draft'",
+ 'invisible': Not(Bool(Eval('unit_price_required'))),
+ 'required': Bool(Eval('unit_price_required')),
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
})
cost_price = fields.Numeric('Cost Price', digits=(16, 4), readonly=True)
currency = fields.Many2One('currency.currency', 'Currency',
states={
- 'invisible': "not unit_price_required",
- 'required': "unit_price_required",
- 'readonly': "state != 'draft'",
+ 'invisible': Not(Bool(Eval('unit_price_required'))),
+ 'required': Not(Bool(Eval('unit_price_required'))),
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
})
unit_price_required = fields.Function('get_unit_price_required',
type='boolean', string='Unit Price Required',
diff --git a/party.xml b/party.xml
index 3759c97cfc..88bfad2d0c 100644
--- a/party.xml
+++ b/party.xml
@@ -7,7 +7,7 @@ this repository contains the full copyright notices and license terms. -->
Customer Shipments
stock.shipment.out
form
- [("customer", "=", active_id)]
+ [("customer", "=", Eval('active_id'))]
@@ -20,7 +20,7 @@ this repository contains the full copyright notices and license terms. -->
Supplier Shipments
stock.shipment.in
form
- [("supplier", "=", active_id)]
+ [("supplier", "=", Eval('active_id'))]
diff --git a/product.py b/product.py
index f9188cddfe..46f8b0afe8 100644
--- a/product.py
+++ b/product.py
@@ -2,6 +2,7 @@
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.wizard import Wizard
+from trytond.pyson import PYSONEncoder
import datetime
@@ -585,7 +586,7 @@ class OpenLocation(Wizard):
ctx['stock_date_end'] = data['form']['forecast_date']
else:
ctx['stock_date_end'] = datetime.date.max
- res['context'] = str(ctx)
+ res['pyson_context'] = PYSONEncoder().encode(ctx)
return res
diff --git a/shipment.py b/shipment.py
index aa13cae092..91e08e4a66 100644
--- a/shipment.py
+++ b/shipment.py
@@ -5,6 +5,7 @@ from trytond.model import ModelWorkflow, ModelView, ModelSQL, fields
from trytond.modules.company import CompanyReport
from trytond.wizard import Wizard
from trytond.backend import TableHandler
+from trytond.pyson import Eval, Not, Equal, If, Or, And, Bool, In
STATES = {
'readonly': "state in ('cancel', 'done')",
@@ -18,45 +19,54 @@ class ShipmentIn(ModelWorkflow, ModelSQL, ModelView):
_rec_name = 'code'
effective_date = fields.Date('Effective Date', readonly=True)
- planned_date = fields.Date(
- 'Planned Date', states={'readonly': "state != 'draft'",})
- reference = fields.Char(
- "Reference", size=None, select=1,
- states={'readonly': "state != 'draft'",})
+ planned_date = fields.Date('Planned Date', states={
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ })
+ reference = fields.Char("Reference", size=None, select=1,
+ states={
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ })
supplier = fields.Many2One('party.party', 'Supplier',
states={
- 'readonly': "(state != 'draft' or bool(incoming_moves)) " \
- "and bool(supplier)",
+ 'readonly': And(Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('incoming_moves'))), Bool(Eval('supplier'))),
}, on_change=['supplier'], required=True)
contact_address = fields.Many2One('party.address', 'Contact Address',
states={
- 'readonly': "state != 'draft'",
- }, domain=["('party', '=', supplier)"])
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ }, domain=[('party', '=', Eval('supplier'))])
warehouse = fields.Many2One('stock.location', "Warehouse",
required=True, domain=[('type', '=', 'warehouse')],
states={
- 'readonly': "state in ('cancel', 'done') or " \
- "bool(incoming_moves)",
+ 'readonly': Or(In(Eval('state'), ['cancel', 'done']),
+ Bool(Eval('incoming_moves'))),
})
incoming_moves = fields.Function('get_incoming_moves', type='one2many',
relation='stock.move', string='Incoming Moves',
- fnct_inv='set_incoming_moves', add_remove="[" \
- "('shipment_in', '=', False),"\
- "('from_location.type', '=', 'supplier'),"\
- "('state', '=', 'draft'),"\
- "('to_location_warehouse', '=', warehouse),"\
- "]",
+ fnct_inv='set_incoming_moves', add_remove=[
+ ('shipment_in', '=', False),
+ ('from_location.type', '=', 'supplier'),
+ ('state', '=', 'draft'),
+ ('to_location_warehouse', '=', Eval('warehouse')),
+ ],
states={
- 'readonly': "state in ('received', 'done', 'cancel') "\
- "or not bool(warehouse)",
- }, context="{'warehouse': warehouse, 'type': 'incoming'," \
- "'supplier': supplier}")
+ 'readonly': Or(In(Eval('state'),
+ ['received', 'done', 'cancel']),
+ Not(Bool(Eval('warehouse')))),
+ }, context={
+ 'warehouse': Eval('warehouse'),
+ 'type': 'incoming',
+ 'supplier': Eval('supplier'),
+ })
inventory_moves = fields.Function('get_inventory_moves', type='one2many',
relation='stock.move', string='Inventory Moves',
fnct_inv='set_inventory_moves',
states={
- 'readonly': "state in ('draft', 'done', 'cancel')",
- }, context="{'warehouse': warehouse, 'type': 'inventory_in'}")
+ 'readonly': In(Eval('state'), ['draft', 'done', 'cancel']),
+ }, context={
+ 'warehouse': Eval('warehouse'),
+ 'type': 'inventory_in',
+ })
moves = fields.One2Many('stock.move', 'shipment_in', 'Moves',
readonly=True)
code = fields.Char("Code", size=None, select=1, readonly=True)
@@ -348,28 +358,36 @@ class ShipmentInReturn(ModelWorkflow, ModelSQL, ModelView):
_rec_name = 'code'
effective_date =fields.Date('Effective Date', readonly=True)
- planned_date = fields.Date(
- 'Planned Date', states={'readonly': "state != 'draft'",})
+ planned_date = fields.Date('Planned Date',
+ states={
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ })
code = fields.Char("Code", size=None, select=1, readonly=True)
- reference = fields.Char(
- "Reference", size=None, select=1,
- states={'readonly': "state != 'draft'",})
- from_location = fields.Many2One(
- 'stock.location', "From Location", required=True,
- states={ 'readonly': "state != 'draft' or bool(moves)", },
- domain=[('type', '=', 'storage')])
+ reference = fields.Char("Reference", size=None, select=1,
+ states={
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ })
+ from_location = fields.Many2One('stock.location', "From Location",
+ required=True, states={
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('moves'))),
+ }, domain=[('type', '=', 'storage')])
to_location = fields.Many2One('stock.location', "To Location",
required=True, states={
- 'readonly': "state != 'draft' or bool(moves)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('moves'))),
}, domain=[('type', '=', 'supplier')])
- moves = fields.One2Many(
- 'stock.move', 'shipment_in_return', 'Moves',
- states={'readonly': "state != 'draft' or "\
- "not(bool(from_location) and bool (to_location))"},
- context="{'from_location': from_location,"
- "'to_location': to_location,"
- "'planned_date': planned_date}",
- )
+ moves = fields.One2Many('stock.move', 'shipment_in_return', 'Moves',
+ states={
+ 'readonly': And(Or(Not(Equal(Eval('state'), 'draft')),
+ Not(Bool(Eval('from_location')))),
+ Bool(Eval('to_location'))),
+ },
+ context={
+ 'from_location': Eval('from_location'),
+ 'to_location': Eval('to_location'),
+ 'planned_date': Eval('planned_date'),
+ })
state = fields.Selection([
('draft', 'Draft'),
('cancel', 'Canceled'),
@@ -531,38 +549,47 @@ class ShipmentOut(ModelWorkflow, ModelSQL, ModelView):
effective_date = fields.Date('Effective Date', readonly=True)
planned_date = fields.Date('Planned Date',
states={
- 'readonly': "state != 'draft'",
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
})
customer = fields.Many2One('party.party', 'Customer', required=True,
states={
- 'readonly': "state != 'draft' or bool(outgoing_moves)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('outgoing_moves'))),
}, on_change=['customer'])
delivery_address = fields.Many2One('party.address',
'Delivery Address', required=True,
states={
- 'readonly': "state != 'draft'",
- }, domain=["('party', '=', customer)"])
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ }, domain=[('party', '=', Eval('customer'))])
reference = fields.Char("Reference", size=None, select=1,
states={
- 'readonly': "state != 'draft'",
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
})
warehouse = fields.Many2One('stock.location', "Warehouse", required=True,
states={
- 'readonly': "state != 'draft' or bool(outgoing_moves)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('outgoing_moves'))),
}, domain=[('type', '=', 'warehouse')])
outgoing_moves = fields.Function('get_outgoing_moves', type='one2many',
relation='stock.move', string='Outgoing Moves',
fnct_inv='set_outgoing_moves',
states={
- 'readonly':"state != 'draft' or not bool(warehouse)",
- }, context="{'warehouse': warehouse, 'type': 'outgoing'," \
- "'customer': customer}")
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Not(Bool(Eval('warehouse')))),
+ }, context={
+ 'warehouse': Eval('warehouse'),
+ 'type': 'outgoing',
+ 'customer': Eval('customer'),
+ })
inventory_moves = fields.Function('get_inventory_moves', type='one2many',
relation='stock.move', string='Inventory Moves',
fnct_inv='set_inventory_moves',
states={
- 'readonly':"state in ('draft', 'packed', 'done')",
- }, context="{'warehouse': warehouse, 'type': 'inventory_out',}")
+ 'readonly': In(Eval('state'), ['draft', 'packed', 'done']),
+ }, context={
+ 'warehouse': Eval('warehouse'),
+ 'type': 'inventory_out',
+ })
moves = fields.One2Many('stock.move', 'shipment_out', 'Moves',
readonly=True)
code = fields.Char("Code", size=None, select=1, readonly=True)
@@ -951,38 +978,46 @@ class ShipmentOutReturn(ModelWorkflow, ModelSQL, ModelView):
effective_date = fields.Date('Effective Date', readonly=True)
planned_date = fields.Date('Planned Date',
states={
- 'readonly': "state != 'draft'",
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
})
customer = fields.Many2One('party.party', 'Customer', required=True,
states={
- 'readonly': "state != 'draft' or bool(incoming_moves)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('incoming_moves'))),
}, on_change=['customer'])
delivery_address = fields.Many2One('party.address',
'Delivery Address', required=True,
states={
- 'readonly': "state != 'draft'",
- }, domain=["('party', '=', customer)"])
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ }, domain=[('party', '=', Eval('customer'))])
reference = fields.Char("Reference", size=None, select=1,
states={
- 'readonly': "state != 'draft'",
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
})
warehouse = fields.Many2One('stock.location', "Warehouse", required=True,
states={
- 'readonly': "state != 'draft' or bool(incoming_moves)",
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('incoming_moves'))),
}, domain=[('type', '=', 'warehouse')])
incoming_moves = fields.Function('get_incoming_moves', type='one2many',
relation='stock.move', string='Incoming Moves',
fnct_inv='set_incoming_moves',
states={
- 'readonly':"state != 'draft'",
- }, context="{'warehouse': warehouse, 'type': 'incoming'," \
- "'customer': customer}")
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ }, context={
+ 'warehouse': Eval('warehouse'),
+ 'type': 'incoming',
+ 'customer': Eval('customer'),
+ })
inventory_moves = fields.Function('get_inventory_moves', type='one2many',
relation='stock.move', string='Inventory Moves',
fnct_inv='set_inventory_moves',
states={
- 'readonly':"state in ('draft', 'cancel', 'done')",
- }, context="{'warehouse': warehouse, 'type': 'inventory_out',}")
+ 'readonly': In(Eval('state'), ['draft', 'cancel', 'done']),
+ }, context={
+ 'warehouse': Eval('warehouse'),
+ 'type': 'inventory_out',
+ })
moves = fields.One2Many('stock.move', 'shipment_out_return', 'Moves',
readonly=True)
code = fields.Char("Code", size=None, select=1, readonly=True)
@@ -1331,30 +1366,43 @@ class ShipmentInternal(ModelWorkflow, ModelSQL, ModelView):
_rec_name = 'code'
effective_date =fields.Date('Effective Date', readonly=True)
- planned_date = fields.Date(
- 'Planned Date', states={'readonly': "state != 'draft'",})
+ planned_date = fields.Date('Planned Date',
+ states={
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ })
code = fields.Char("Code", size=None, select=1, readonly=True)
- reference = fields.Char(
- "Reference", size=None, select=1,
- states={'readonly': "state != 'draft'",})
- from_location = fields.Many2One(
- 'stock.location', "From Location", required=True,
- states={ 'readonly': "state != 'draft' or bool(moves)", },
- domain=["('type', 'not in', " \
- "('supplier', 'customer', 'warehouse', 'view'))"])
+ reference = fields.Char("Reference", size=None, select=1,
+ states={
+ 'readonly': Not(Equal(Eval('state'), 'draft')),
+ })
+ from_location = fields.Many2One('stock.location', "From Location",
+ required=True, states={
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('moves'))),
+ },
+ domain=[
+ ('type', 'not in',
+ ['supplier', 'customer', 'warehouse', 'view']),
+ ])
to_location = fields.Many2One('stock.location', "To Location",
required=True, states={
- 'readonly': "state != 'draft' or bool(moves)",
- }, domain=["('type', 'not in', " \
- "('supplier', 'customer', 'warehouse', 'view'))"])
- moves = fields.One2Many(
- 'stock.move', 'shipment_internal', 'Moves',
- states={'readonly': "state != 'draft' or "\
- "not(bool(from_location) and bool (to_location))"},
- context="{'from_location': from_location,"
- "'to_location': to_location,"
- "'planned_date': planned_date}",
- )
+ 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
+ Bool(Eval('moves'))),
+ }, domain=[
+ ('type', 'not in',
+ ['supplier', 'customer', 'warehouse', 'view']),
+ ])
+ moves = fields.One2Many('stock.move', 'shipment_internal', 'Moves',
+ states={
+ 'readonly': And(Or(Not(Equal(Eval('state'), 'draft')),
+ Not(Bool(Eval('from_location')))),
+ Bool(Eval('to_location'))),
+ },
+ context={
+ 'from_location': Eval('from_location'),
+ 'to_location': Eval('to_location'),
+ 'planned_date': Eval('planned_date'),
+ })
state = fields.Selection([
('draft', 'Draft'),
('cancel', 'Canceled'),
diff --git a/shipment.xml b/shipment.xml
index f985846931..b236b20ecd 100644
--- a/shipment.xml
+++ b/shipment.xml
@@ -49,17 +49,17 @@ this repository contains the full copyright notices and license terms. -->
@@ -177,22 +177,23 @@ this repository contains the full copyright notices and license terms. -->
+ states="{'invisible': Not(In(Eval('state'), ['assigned', 'draft'])), 'readonly': Not(In(%(group_stock)d, Eval('groups', []))), 'icon': If(Equal(Eval('state'), 'assigned'), 'tryton-go-previous', If(Equal(Eval('state'), 'draft'), 'tryton-go-next', ''))}"/>
@@ -322,26 +323,26 @@ this repository contains the full copyright notices and license terms. -->
+ states="{'invisible': Not(In(Eval('state'), ['assigned', 'waiting', 'draft'])), 'readonly': Not(In(%(group_stock)d, Eval('groups', []))), 'icon': If(Equal(Eval('state'), 'assigned'), 'tryton-go-previous', If(Equal(Eval('state'), 'waiting'), 'tryton-clear', If(Equal(Eval('state'), 'draft'), 'tryton-go-next', '')))}"/>
@@ -519,22 +520,23 @@ this repository contains the full copyright notices and license terms. -->
+ states="{'invisible': Not(In(Eval('state'), ['assigned', 'waiting', 'draft'])), 'readonly': Not(In(%(group_stock)d, Eval('groups', []))), 'icon': If(Equal(Eval('state'), 'assigned'), 'tryton-go-previous', If(Equal(Eval('state'), 'waiting'), 'tryton-clear', If(Equal(Eval('state'), 'draft'), 'tryton-go-next', '')))}"/>
@@ -735,17 +737,17 @@ this repository contains the full copyright notices and license terms. -->