Use new PYSON syntax
issue2205 review16391002
This commit is contained in:
1 parent
f481efa408
commit
a2da70ea13
5 files changed
+75
-82
No files matched your search
+5
-8
@@ -3,7 +3,7 @@
|
||||
from sql import Null
|
||||
|
||||
from trytond.model import Workflow, Model, ModelView, ModelSQL, fields, Check
|
||||
from trytond.pyson import Not, Equal, Eval, Or, Bool
|
||||
from trytond.pyson import Eval
|
||||
from trytond import backend
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
@@ -11,7 +11,7 @@ from trytond.pool import Pool
|
||||
__all__ = ['Inventory', 'InventoryLine']
|
||||
|
||||
STATES = {
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}
|
||||
DEPENDS = ['state']
|
||||
|
||||
@@ -22,13 +22,11 @@ class Inventory(Workflow, ModelSQL, ModelView):
|
||||
location = fields.Many2One(
|
||||
'stock.location', 'Location', required=True,
|
||||
domain=[('type', '=', 'storage')], states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('lines', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
|
||||
},
|
||||
depends=['state'])
|
||||
date = fields.Date('Date', required=True, states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('lines', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
|
||||
},
|
||||
depends=['state'])
|
||||
lost_found = fields.Many2One(
|
||||
@@ -39,8 +37,7 @@ class Inventory(Workflow, ModelSQL, ModelView):
|
||||
depends=DEPENDS)
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('lines', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
|
||||
},
|
||||
depends=['state'])
|
||||
state = fields.Selection([
|
||||
|
||||
+13
-13
@@ -5,7 +5,7 @@ from decimal import Decimal
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.wizard import Wizard, StateView, Button, StateAction
|
||||
from trytond import backend
|
||||
from trytond.pyson import Not, Bool, Eval, Equal, PYSONEncoder, Date, If
|
||||
from trytond.pyson import Eval, PYSONEncoder, Date, If
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.tools import grouped_slice
|
||||
@@ -15,7 +15,7 @@ __all__ = ['Location', 'Party', 'ProductsByLocationsStart',
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
STATES = {
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'readonly': ~Eval('active'),
|
||||
}
|
||||
DEPENDS = ['active']
|
||||
|
||||
@@ -30,8 +30,8 @@ class Location(ModelSQL, ModelView):
|
||||
active = fields.Boolean('Active', select=True)
|
||||
address = fields.Many2One("party.address", "Address",
|
||||
states={
|
||||
'invisible': Not(Equal(Eval('type'), 'warehouse')),
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'invisible': Eval('type') != 'warehouse',
|
||||
'readonly': ~Eval('active'),
|
||||
},
|
||||
depends=['type', 'active'])
|
||||
type = fields.Selection([
|
||||
@@ -54,9 +54,9 @@ class Location(ModelSQL, ModelView):
|
||||
childs = fields.One2Many("stock.location", "parent", "Children")
|
||||
input_location = fields.Many2One(
|
||||
"stock.location", "Input", states={
|
||||
'invisible': Not(Equal(Eval('type'), 'warehouse')),
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'required': Equal(Eval('type'), 'warehouse'),
|
||||
'invisible': Eval('type') != 'warehouse',
|
||||
'readonly': ~Eval('active'),
|
||||
'required': Eval('type') == 'warehouse',
|
||||
},
|
||||
domain=[
|
||||
('type', '=', 'storage'),
|
||||
@@ -68,9 +68,9 @@ class Location(ModelSQL, ModelView):
|
||||
depends=['type', 'active', 'id'])
|
||||
output_location = fields.Many2One(
|
||||
"stock.location", "Output", states={
|
||||
'invisible': Not(Equal(Eval('type'), 'warehouse')),
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'required': Equal(Eval('type'), 'warehouse'),
|
||||
'invisible': Eval('type') != 'warehouse',
|
||||
'readonly': ~Eval('active'),
|
||||
'required': Eval('type') == 'warehouse',
|
||||
},
|
||||
domain=[
|
||||
('type', '=', 'storage'),
|
||||
@@ -80,9 +80,9 @@ class Location(ModelSQL, ModelView):
|
||||
depends=['type', 'active', 'id'])
|
||||
storage_location = fields.Many2One(
|
||||
"stock.location", "Storage", states={
|
||||
'invisible': Not(Equal(Eval('type'), 'warehouse')),
|
||||
'readonly': Not(Bool(Eval('active'))),
|
||||
'required': Equal(Eval('type'), 'warehouse'),
|
||||
'invisible': Eval('type') != 'warehouse',
|
||||
'readonly': ~Eval('active'),
|
||||
'required': Eval('type') == 'warehouse',
|
||||
},
|
||||
domain=[
|
||||
('type', '=', 'storage'),
|
||||
|
||||
@@ -12,7 +12,7 @@ from sql.operators import Concat
|
||||
|
||||
from trytond.model import Workflow, Model, ModelView, ModelSQL, fields, Check
|
||||
from trytond import backend
|
||||
from trytond.pyson import In, Eval, Not, Equal, If, Bool
|
||||
from trytond.pyson import Eval, If, Bool
|
||||
from trytond.tools import reduce_ids
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
@@ -22,7 +22,7 @@ from trytond.modules.product import price_digits
|
||||
__all__ = ['StockMixin', 'Move']
|
||||
|
||||
STATES = {
|
||||
'readonly': In(Eval('state'), ['cancel', 'assigned', 'done']),
|
||||
'readonly': Eval('state').in_(['cancel', 'assigned', 'done']),
|
||||
}
|
||||
DEPENDS = ['state']
|
||||
|
||||
@@ -187,7 +187,7 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
},
|
||||
depends=['state'])
|
||||
planned_date = fields.Date("Planned Date", states={
|
||||
'readonly': (In(Eval('state'), ['cancel', 'assigned', 'done'])
|
||||
'readonly': (Eval('state').in_(['cancel', 'assigned', 'done'])
|
||||
| Eval('shipment'))
|
||||
}, depends=['state', 'shipment'],
|
||||
select=True)
|
||||
@@ -205,27 +205,27 @@ class Move(Workflow, ModelSQL, ModelView):
|
||||
], 'State', select=True, readonly=True)
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=['state'])
|
||||
unit_price = fields.Numeric('Unit Price', digits=price_digits,
|
||||
states={
|
||||
'invisible': Not(Bool(Eval('unit_price_required'))),
|
||||
'invisible': ~Eval('unit_price_required'),
|
||||
'required': Bool(Eval('unit_price_required')),
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
depends=['unit_price_required', 'state'])
|
||||
cost_price = fields.Numeric('Cost Price', digits=price_digits,
|
||||
readonly=True)
|
||||
currency = fields.Many2One('currency.currency', 'Currency',
|
||||
states={
|
||||
'invisible': Not(Bool(Eval('unit_price_required'))),
|
||||
'invisible': ~Eval('unit_price_required'),
|
||||
'required': Bool(Eval('unit_price_required')),
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
depends=['unit_price_required', 'state'])
|
||||
unit_price_required = fields.Function(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from itertools import chain
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.pyson import Equal, Eval, If, In
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.tools import grouped_slice
|
||||
@@ -15,11 +15,11 @@ class Period(Workflow, ModelSQL, ModelView):
|
||||
__name__ = 'stock.period'
|
||||
_rec_name = 'date'
|
||||
date = fields.Date('Date', required=True, states={
|
||||
'readonly': Equal(Eval('state'), 'closed'),
|
||||
}, depends=['state'])
|
||||
'readonly': Eval('state') == 'closed',
|
||||
}, depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
])
|
||||
caches = fields.One2Many('stock.period.cache', 'period', 'Caches',
|
||||
|
||||
+44
-48
@@ -13,7 +13,7 @@ from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.modules.company import CompanyReport
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond import backend
|
||||
from trytond.pyson import Eval, Not, Equal, If, Or, And, Bool, In, Id
|
||||
from trytond.pyson import Eval, If, Id
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.tools import reduce_ids, grouped_slice
|
||||
@@ -45,25 +45,26 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
},
|
||||
depends=['state'])
|
||||
planned_date = fields.Date('Planned Date', states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=['state'])
|
||||
reference = fields.Char("Reference", size=None, select=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
supplier = fields.Many2One('party.party', 'Supplier',
|
||||
states={
|
||||
'readonly': And(Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('incoming_moves', [0]))), Bool(Eval('supplier'))),
|
||||
'readonly': (((Eval('state') != 'draft')
|
||||
| Eval('incoming_moves', [0]))
|
||||
& Eval('supplier')),
|
||||
}, required=True,
|
||||
depends=['state', 'supplier'])
|
||||
supplier_location = fields.Function(fields.Many2One('stock.location',
|
||||
@@ -71,14 +72,14 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
'on_change_with_supplier_location')
|
||||
contact_address = fields.Many2One('party.address', 'Contact Address',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, domain=[('party', '=', Eval('supplier'))],
|
||||
depends=['state', 'supplier'])
|
||||
warehouse = fields.Many2One('stock.location', "Warehouse",
|
||||
required=True, domain=[('type', '=', 'warehouse')],
|
||||
states={
|
||||
'readonly': Or(In(Eval('state'), ['cancel', 'done']),
|
||||
Bool(Eval('incoming_moves', [0]))),
|
||||
'readonly': (Eval('state').in_(['cancel', 'done'])
|
||||
| Eval('incoming_moves', [0])),
|
||||
}, depends=['state'])
|
||||
warehouse_input = fields.Function(fields.Many2One('stock.location',
|
||||
'Warehouse Input'),
|
||||
@@ -115,7 +116,7 @@ class ShipmentIn(Workflow, ModelSQL, ModelView):
|
||||
('company', '=', Eval('company')),
|
||||
],
|
||||
states={
|
||||
'readonly': In(Eval('state'), ['draft', 'done', 'cancel']),
|
||||
'readonly': Eval('state').in_(['draft', 'done', 'cancel']),
|
||||
},
|
||||
depends=['state', 'warehouse', 'warehouse_input',
|
||||
'warehouse_storage', 'company']),
|
||||
@@ -485,39 +486,36 @@ class ShipmentInReturn(Workflow, ModelSQL, ModelView):
|
||||
depends=['state'])
|
||||
planned_date = fields.Date('Planned Date',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=['state'])
|
||||
code = fields.Char("Code", size=None, select=True, readonly=True)
|
||||
reference = fields.Char("Reference", size=None, select=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
from_location = fields.Many2One('stock.location', "From Location",
|
||||
required=True, states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('moves', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('moves', [0]),
|
||||
}, domain=[('type', '=', 'storage')],
|
||||
depends=['state'])
|
||||
to_location = fields.Many2One('stock.location', "To Location",
|
||||
required=True, states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('moves', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('moves', [0]),
|
||||
}, domain=[('type', '=', 'supplier')],
|
||||
depends=['state'])
|
||||
moves = fields.One2Many('stock.move', 'shipment', 'Moves',
|
||||
states={
|
||||
'readonly': And(Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Not(Bool(Eval('from_location')))),
|
||||
Bool(Eval('to_location'))),
|
||||
'readonly': (((Eval('state') != 'draft') | ~Eval('from_location'))
|
||||
& Eval('to_location')),
|
||||
},
|
||||
domain=[
|
||||
('from_location', '=', Eval('from_location')),
|
||||
@@ -765,21 +763,21 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
depends=['state'])
|
||||
planned_date = fields.Date('Planned Date',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=['state'])
|
||||
customer = fields.Many2One('party.party', 'Customer', required=True,
|
||||
states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('outgoing_moves', [0]))),
|
||||
'readonly': ((Eval('state') != 'draft')
|
||||
| Eval('outgoing_moves', [0])),
|
||||
},
|
||||
depends=['state'])
|
||||
customer_location = fields.Function(fields.Many2One('stock.location',
|
||||
@@ -787,17 +785,17 @@ class ShipmentOut(Workflow, ModelSQL, ModelView):
|
||||
delivery_address = fields.Many2One('party.address',
|
||||
'Delivery Address', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, domain=[('party', '=', Eval('customer'))],
|
||||
depends=['state', 'customer'])
|
||||
reference = fields.Char("Reference", size=None, select=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
warehouse = fields.Many2One('stock.location', "Warehouse", required=True,
|
||||
states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('outgoing_moves', [0]))),
|
||||
'readonly': ((Eval('state') != 'draft')
|
||||
| Eval('outgoing_moves', [0])),
|
||||
}, domain=[('type', '=', 'warehouse')],
|
||||
depends=['state'])
|
||||
warehouse_storage = fields.Function(fields.Many2One('stock.location',
|
||||
@@ -1315,21 +1313,21 @@ class ShipmentOutReturn(Workflow, ModelSQL, ModelView):
|
||||
depends=['state'])
|
||||
planned_date = fields.Date('Planned Date',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=['state'])
|
||||
customer = fields.Many2One('party.party', 'Customer', required=True,
|
||||
states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('incoming_moves', [0]))),
|
||||
'readonly': ((Eval('state') != 'draft')
|
||||
| Eval('incoming_moves', [0])),
|
||||
},
|
||||
depends=['state'])
|
||||
customer_location = fields.Function(fields.Many2One('stock.location',
|
||||
@@ -1337,17 +1335,17 @@ class ShipmentOutReturn(Workflow, ModelSQL, ModelView):
|
||||
delivery_address = fields.Many2One('party.address',
|
||||
'Delivery Address', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, domain=[('party', '=', Eval('customer'))],
|
||||
depends=['state', 'customer'])
|
||||
reference = fields.Char("Reference", size=None, select=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
warehouse = fields.Many2One('stock.location', "Warehouse", required=True,
|
||||
states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('incoming_moves', [0]))),
|
||||
'readonly': ((Eval('state') != 'draft')
|
||||
| Eval('incoming_moves', [0])),
|
||||
}, domain=[('type', '=', 'warehouse')],
|
||||
depends=['state'])
|
||||
warehouse_storage = fields.Function(fields.Many2One('stock.location',
|
||||
@@ -1751,34 +1749,32 @@ class ShipmentInternal(Workflow, ModelSQL, ModelView):
|
||||
depends=['state'])
|
||||
planned_date = fields.Date('Planned Date',
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
},
|
||||
domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
depends=['state'])
|
||||
code = fields.Char("Code", size=None, select=True, readonly=True)
|
||||
reference = fields.Char("Reference", size=None, select=True,
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'])
|
||||
from_location = fields.Many2One('stock.location', "From Location",
|
||||
required=True, states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('moves', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('moves', [0]),
|
||||
},
|
||||
domain=[
|
||||
('type', 'in', ['storage', 'lost_found']),
|
||||
], depends=['state'])
|
||||
to_location = fields.Many2One('stock.location', "To Location",
|
||||
required=True, states={
|
||||
'readonly': Or(Not(Equal(Eval('state'), 'draft')),
|
||||
Bool(Eval('moves', [0]))),
|
||||
'readonly': (Eval('state') != 'draft') | Eval('moves', [0]),
|
||||
}, domain=[
|
||||
('type', 'in', ['storage', 'lost_found']),
|
||||
], depends=['state'])
|
||||
|
||||
Reference in new issue
Block a user