Use PySON

This commit is contained in:
Cédric Krier
2010-01-20 11:04:28 +01:00
parent 64645f571a
commit bfab410ce8
8 changed files with 236 additions and 171 deletions
+12 -8
View File
@@ -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')
+5 -5
View File
@@ -27,7 +27,7 @@ this repository contains the full copyright notices and license terms. -->
<label colspan="2" id="empty"/>
<button string="Complete Inventory" type="action"
name="%(wizard_complete_inventory)d"
states="{'readonly': '''state != 'draft' '''}"
states="{'readonly': Not(Equal(Eval('state'), 'draft'))}"
colspan="2"
help="Add an inventory line for each missing products"/>
<field name="lines" colspan="4"/>
@@ -37,12 +37,12 @@ this repository contains the full copyright notices and license terms. -->
<group colspan="2" col="3" id="buttons">
<button string="Cancel"
name="cancel"
states="{'invisible': '''state in ('cancel', 'done') ''', 'readonly': '''%(group_stock)d not in groups'''}"
icon="tryton-cancel" />
states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="'tryton-cancel'" />
<button string="Confirm"
name="done"
states="{'invisible': '''state in ('done','cancel') ''', 'readonly': '''%(group_stock)d not in groups'''}"
icon="tryton-ok"/>
states="{'invisible': In(Eval('state'), ['done','cancel']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="'tryton-ok'"/>
</group>
</group>
</form>
+31 -26
View File
@@ -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
+23 -18
View File
@@ -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',
+2 -2
View File
@@ -7,7 +7,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">Customer Shipments</field>
<field name="res_model">stock.shipment.out</field>
<field name="view_type">form</field>
<field name="domain">[("customer", "=", active_id)]</field>
<field name="domain">[("customer", "=", Eval('active_id'))]</field>
</record>
<record model="ir.action.keyword"
id="act_open_purchase_keyword1">
@@ -20,7 +20,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">Supplier Shipments</field>
<field name="res_model">stock.shipment.in</field>
<field name="view_type">form</field>
<field name="domain">[("supplier", "=", active_id)]</field>
<field name="domain">[("supplier", "=", Eval('active_id'))]</field>
</record>
<record model="ir.action.keyword"
id="act_open_purchase_keyword2">
+2 -1
View File
@@ -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
+132 -84
View File
@@ -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'),
+29 -27
View File
@@ -49,17 +49,17 @@ this repository contains the full copyright notices and license terms. -->
<field name="state"/>
<group col="5" colspan="2" id="buttons">
<button string="Cancel" name="cancel"
states="{'invisible': '''state in ('cancel', 'done') ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-cancel"/>
<button string="Received" name="received"
states="{'invisible': '''state != 'draft' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'draft')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button string="Done" name="done"
states="{'invisible': '''state != 'received' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'received')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-ok"/>
<button string="Reset to Draft" name="button_draft"
type="object"
states="{'invisible': '''state != 'cancel' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-clear"/>
</group>
</group>
@@ -177,22 +177,23 @@ this repository contains the full copyright notices and license terms. -->
<field name="state"/>
<group col="6" colspan="2" id="buttons">
<button string="Cancel" name="cancel"
states="{'invisible': '''state in ('cancel', 'done') ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-cancel"/>
<button string="Draft" name="draft"
states="{'invisible': '''state != 'waiting' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'waiting')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-previous"/>
<button string="Waiting" name="waiting"
states="{'invisible': '''state not in ('assigned', 'draft')''', 'readonly': '''%(group_stock)d not in groups''', 'icon': '''state == 'assigned' and 'tryton-go-previous' or state == 'draft' and 'tryton-go-next' or False'''}"/>
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', ''))}"/>
<button string="Assign" name="%(wizard_shipment_in_return_assign)d"
type="action"
states="{'invisible': '''state != 'waiting' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'waiting')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button string="Reset to Draft" name="button_draft"
type="object" states="{'invisible': '''state != 'cancel' ''', 'readonly': '''%(group_stock)d not in groups'''}"
type="object"
states="{'invisible': Not(Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-clear"/>
<button string="Done" name="done"
states="{'invisible': '''state != 'assigned' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'assigned')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-ok"/>
</group>
</form>
@@ -322,26 +323,26 @@ this repository contains the full copyright notices and license terms. -->
<field name="state"/>
<group col="7" colspan="2" id="buttons">
<button string="Cancel" name="cancel"
states="{'invisible': '''state in ('cancel', 'done') ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-cancel"/>
<button string="Draft" name="draft"
states="{'invisible': '''state != 'waiting' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'waiting')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-previous"/>
<button string="Waiting" name="waiting"
states="{'invisible': '''state not in ('assigned', 'waiting', 'draft')''', 'readonly': '''%(group_stock)d not in groups''', 'icon': '''state == 'assigned' and 'tryton-go-previous' or state == 'waiting' and 'tryton-clear' or state == 'draft' and 'tryton-go-next' or False'''}"/>
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', '')))}"/>
<button string="Assign" name="%(wizard_shipment_out_assign)d"
type="action"
states="{'invisible': '''state != 'waiting' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'waiting')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button string="Make shipment" name="packed"
states="{'invisible': '''state != 'assigned' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'assigned')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button string="Done" name="done"
states="{'invisible': '''state != 'packed' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'packed')), 'readonly': Not(In(%(group_stock)d , Eval('groups', [])))}"
icon="tryton-ok"/>
<button string="Reset to Draft" name="button_draft"
type="object"
states="{'invisible': '''state != 'cancel' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-clear"/>
</group>
</group>
@@ -519,22 +520,23 @@ this repository contains the full copyright notices and license terms. -->
<field name="state"/>
<group col="6" colspan="2" id="buttons">
<button string="Cancel" name="cancel"
states="{'invisible': '''state in ('cancel', 'done') ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-cancel"/>
<button string="Draft" name="draft"
states="{'invisible': '''state != 'waiting' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'waiting')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-previous"/>
<button string="Waiting" name="waiting"
states="{'invisible': '''state not in ('assigned', 'waiting', 'draft')''', 'readonly': '''%(group_stock)d not in groups''', 'icon': '''state == 'assigned' and 'tryton-go-previous' or state == 'waiting' and 'tryton-clear' or state == 'draft' and 'tryton-go-next' or False'''}"/>
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', '')))}"/>
<button string="Assign" name="%(wizard_shipment_internal_assign)d"
type="action"
states="{'invisible': '''state != 'waiting' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'waiting')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button string="Reset to Draft" name="button_draft"
type="object" states="{'invisible': '''state != 'cancel' ''', 'readonly': '''%(group_stock)d not in groups'''}"
type="object"
states="{'invisible': Not(Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-clear"/>
<button string="Done" name="done"
states="{'invisible': '''state != 'assigned' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'assigned')), 'readonly': Not(In(%(group_stock)d , Eval('groups', [])))}"
icon="tryton-ok"/>
</group>
</form>
@@ -735,17 +737,17 @@ this repository contains the full copyright notices and license terms. -->
<field name="state"/>
<group col="5" colspan="2" id="buttons">
<button string="Cancel" name="cancel"
states="{'invisible': '''state in ('cancel', 'done') ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': In(Eval('state'), ['cancel', 'done']), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-cancel"/>
<button string="Received" name="received"
states="{'invisible': '''state != 'draft' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'draft')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-go-next"/>
<button string="Done" name="done"
states="{'invisible': '''state != 'received' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'received')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-ok"/>
<button string="Reset to Draft" name="button_draft"
type="object"
states="{'invisible': '''state != 'cancel' ''', 'readonly': '''%(group_stock)d not in groups'''}"
states="{'invisible': Not(Equal(Eval('state'), 'cancel')), 'readonly': Not(In(%(group_stock)d, Eval('groups', [])))}"
icon="tryton-clear"/>
</group>
</group>