Implement task.

This commit refs #857
This commit is contained in:
Sergio Morillo 2015-10-20 19:27:57 +02:00
parent 326b69cce5
commit 93cea6e3d4
2 changed files with 35 additions and 4 deletions

27
load.py
View File

@ -38,7 +38,7 @@ class LoadOrder:
super(LoadOrder, cls).__setup__()
cls._buttons.update({
'run_try': {'icon': 'tryton-go-next',
'invisible': Eval('state') != 'waiting'},
'invisible': ~Eval('state').in_(['waiting', 'running'])},
})
cls._error_messages.update({
'cancel_ul': 'Cannot cancel load orders with loaded ULs',
@ -69,6 +69,27 @@ class LoadOrder:
cls.raise_user_error('cancel_ul')
super(LoadOrder, cls).cancel(records)
def _get_load_sale(self, Sale):
res = super(LoadOrder, self)._get_load_sale(Sale)
res.shipment_method = 'manual'
return res
def _get_shipment_moves(self, sale_line, grouped_items):
moves = []
sale_moves = []
for item in grouped_items:
new_moves = item._get_new_moves({'from_location': sale_line.from_location.id,
'to_location': sale_line.to_location.id,
'planned_date': sale_line.delivery_date})
move, = [m for m in new_moves if m.product == item.product]
sale_moves.append(move)
moves.extend(new_moves)
sale_line.moves = sale_moves
return moves
def _get_items(self):
return self.unit_loads
@classmethod
@ModelView.button_action('carrier_load_ul.wizard_load_ul')
def run_try(cls, records):
@ -139,10 +160,10 @@ class LoadOrder:
def check_ul_data_match(self, lines, unit_load):
valid_lines = []
for line in lines:
if not line.origin or not line.origin.product:
product = getattr(line.origin, 'product', None)
if not line.origin or not product:
valid_lines.append(line)
continue
product = getattr(line.origin, 'product', None)
if product.id == unit_load.product.id:
valid_lines.append(line)
return valid_lines

View File

@ -41,6 +41,15 @@ Create carrier::
>>> carrier = create_carrier(config)
Get warehouse and dock::
>>> Location = Model.get('stock.location')
>>> wh, = Location.find([('type', '=', 'warehouse')])
>>> dock = wh.docks.new()
>>> dock.name = 'Dock 1'
>>> dock.code = 'D1'
>>> wh.save()
Create carrier load::
>>> Load = Model.get('carrier.load')
@ -55,7 +64,8 @@ Create carrier load::
True
>>> load.warehouse_output == load.warehouse.output_location
True
>>> load.output_location = load.warehouse_output
>>> load.dock != None
True
>>> load.carrier = carrier
>>> load.vehicle != None
True