Set target field on supplier and customer moves relations

This is required to make the client hide the relation field on when displaying
the One2Many fields on the view.

Also use filter attribute instead of Function fields

issue7475
review51341002
This commit is contained in:
Sergi Almacellas Abellana committed 2018-05-30 13:58:46 +02:00
1 parent 8d76252088
commit 674ded1398
1 file changed
+14 -24
+14 -24
View File
@@ -148,18 +148,20 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView):
],
],
depends=['company'], readonly=True)
supplier_moves = fields.Function(fields.One2Many('stock.move', None,
'Supplier Moves',
states={
'readonly': Eval('state').in_(['shipped', 'done', 'cancel']),
},
depends=['state', 'supplier']), 'get_moves', 'set_moves')
customer_moves = fields.Function(fields.One2Many('stock.move', None,
'Customer Moves',
states={
'readonly': Eval('state') != 'shipped',
},
depends=['state', 'customer']), 'get_moves', 'set_moves')
supplier_moves = fields.One2Many('stock.move', 'shipment',
'Supplier Moves',
filter=[('to_location.type', '=', 'drop')],
states={
'readonly': Eval('state').in_(['shipped', 'done', 'cancel']),
},
depends=['state', 'supplier'])
customer_moves = fields.One2Many('stock.move', 'shipment',
'Customer Moves',
filter=[('from_location.type', '=', 'drop')],
states={
'readonly': Eval('state') != 'shipped',
},
depends=['state', 'customer'])
code = fields.Char('Code', select=1, readonly=True)
state = fields.Selection([
('draft', 'Draft'),
@@ -325,18 +327,6 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView):
if to_write:
Move.write(*to_write)
def get_moves(self, name):
if name == 'supplier_moves':
return [m.id for m in self.moves if m.to_location.type == 'drop']
elif name == 'customer_moves':
return [m.id for m in self.moves if m.from_location.type == 'drop']
@classmethod
def set_moves(cls, shipments, name, values):
if not values:
return
cls.write(shipments, {'moves': values})
@classmethod
def create(cls, vlist):
pool = Pool()