Add picked step to customer shipment workflow

issue9634
review329071002
This commit is contained in:
Maxime Richez committed 2020-10-12 23:19:54 +02:00
1 parent b035935cef
commit c09fb12c43
7 files changed
+62 -12

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add picked step to customer shipment workflow
* Add cron task to reschedule past shipments
* Allow lost and found on inventory moves of shipments
* Add waste locations on warehouses
+27 -6
View File
@@ -950,7 +950,7 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
origins = fields.Function(fields.Char('Origins'), 'get_origins')
number = fields.Char('Number', size=None, select=True, readonly=True,
help="The main identifier for the shipment.")
assigned_by = employee_field("Assigned By")
picked_by = employee_field("Picked By")
packed_by = employee_field("Packed By")
done_by = employee_field("Done By")
state = fields.Selection([
@@ -958,6 +958,7 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
('done', 'Done'),
('cancelled', 'Cancelled'),
('assigned', 'Assigned'),
('picked', 'Picked'),
('packed', 'Packed'),
('waiting', 'Waiting'),
], 'State', readonly=True,
@@ -970,8 +971,9 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
cls._transitions |= set((
('draft', 'waiting'),
('waiting', 'assigned'),
('waiting', 'packed'),
('assigned', 'packed'),
('waiting', 'picked'),
('assigned', 'picked'),
('picked', 'packed'),
('packed', 'done'),
('assigned', 'waiting'),
('waiting', 'waiting'),
@@ -979,6 +981,7 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
('draft', 'cancelled'),
('waiting', 'cancelled'),
('assigned', 'cancelled'),
('picked', 'cancelled'),
('packed', 'cancelled'),
('cancelled', 'draft'),
))
@@ -1006,7 +1009,7 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
'tryton-forward')),
'depends': ['state'],
},
'pack': {
'pick': {
'invisible': If(Eval('warehouse_storage')
== Eval('warehouse_output'),
~Eval('state').in_(['assigned', 'waiting']),
@@ -1014,6 +1017,10 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
'depends': ['state', 'warehouse_storage',
'warehouse_output'],
},
'pack': {
'invisible': Eval('state') != 'picked',
'depends': ['state'],
},
'done': {
'invisible': Eval('state') != 'packed',
},
@@ -1036,6 +1043,10 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
if table.column_exist('code'):
table.column_rename('code', 'number')
# Migration from 5.6: rename assigned_by into picked_by
if table.column_exist('assigned_by'):
table.column_rename('assigned_by', 'picked_by')
super(ShipmentOut, cls).__register__(module_name)
# Add index on create_date
@@ -1188,13 +1199,23 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
@classmethod
@Workflow.transition('assigned')
@set_employee('assigned_by')
def assign(cls, shipments):
pool = Pool()
Move = pool.get('stock.move')
Move.assign([m for s in shipments for m in s.assign_moves])
cls._sync_inventory_to_outgoing(shipments, quantity=False)
@classmethod
@ModelView.button
@Workflow.transition('picked')
@set_employee('picked_by')
def pick(cls, shipments):
pool = Pool()
Move = pool.get('stock.move')
Move.do([m for s in shipments for m in s.inventory_moves])
cls._sync_inventory_to_outgoing(shipments, quantity=True)
Move.assign([m for s in shipments for m in s.outgoing_moves])
@classmethod
@ModelView.button
@Workflow.transition('packed')
@@ -1370,7 +1391,7 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
default.setdefault('inventory_moves', None)
default.setdefault('outgoing_moves', None)
default.setdefault('number', None)
default.setdefault('assigned_by', None)
default.setdefault('picked_by', None)
default.setdefault('packed_by', None)
default.setdefault('done_by', None)
return super(ShipmentOut, cls).copy(shipments, default=default)
+19 -1
View File
@@ -165,9 +165,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="count" eval="True"/>
<field name="act_window" ref="act_shipment_out_form"/>
</record>
<record model="ir.action.act_window.domain" id="act_shipment_out_form_domain_picked">
<field name="name">Picked</field>
<field name="sequence" eval="40"/>
<field name="domain" eval="[('state', '=', 'picked')]" pyson="1"/>
<field name="count" eval="True"/>
<field name="act_window" ref="act_shipment_out_form"/>
</record>
<record model="ir.action.act_window.domain" id="act_shipment_out_form_domain_packed">
<field name="name">Packed</field>
<field name="sequence" eval="40"/>
<field name="sequence" eval="50"/>
<field name="domain" eval="[('state', '=', 'packed')]" pyson="1"/>
<field name="count" eval="True"/>
<field name="act_window" ref="act_shipment_out_form"/>
@@ -624,6 +631,17 @@ this repository contains the full copyright notices and license terms. -->
<field name="group" ref="group_stock"/>
</record>
<record model="ir.model.button" id="shipment_out_pick_button">
<field name="name">pick</field>
<field name="string">Pick</field>
<field name="model" search="[('model', '=', 'stock.shipment.out')]"/>
</record>
<record model="ir.model.button-res.group"
id="shipment_out_pick_button_group_stock">
<field name="button" ref="shipment_out_pick_button"/>
<field name="group" ref="group_stock"/>
</record>
<record model="ir.model.button" id="shipment_out_pack_button">
<field name="name">pack</field>
<field name="string">Pack</field>
+1
View File
@@ -113,6 +113,7 @@ Add two shipment lines of same product and go through the workflow::
>>> shipment_out.click('wait')
>>> shipment_out.click('assign_try')
True
>>> shipment_out.click('pick')
>>> shipment_out.click('pack')
>>> shipment_out.click('done')
+8 -2
View File
@@ -97,7 +97,7 @@ Add two shipment lines of same product::
... move.unit_price = Decimal('1')
... move.currency = company.currency
>>> shipment_out.save()
>>> shipment_out.assigned_by
>>> shipment_out.picked_by
>>> shipment_out.packed_by
>>> shipment_out.done_by
@@ -160,7 +160,12 @@ Ignore non assigned moves and pack shipment::
>>> shipment_assign.execute('ignore')
>>> sorted([m.quantity for m in shipment_out.inventory_moves])
[0.0, 1.0]
>>> shipment_out.assigned_by == employee
>>> shipment_out.picked_by
>>> shipment_out.packed_by
>>> shipment_out.done_by
>>> shipment_out.click('pick')
>>> shipment_out.picked_by == employee
True
>>> shipment_out.packed_by
>>> shipment_out.done_by
@@ -245,6 +250,7 @@ Finish the shipment::
>>> shipment_out.click('assign_try')
True
>>> shipment_out.click('pick')
>>> shipment_out.click('pack')
>>> shipment_out.click('done')
>>> shipment_out.state
@@ -80,7 +80,9 @@ Set the shipment state to waiting::
0
Assign the shipment::
>>> shipment_out.click('pick')
>>> shipment_out.state
'picked'
>>> shipment_out.click('pack')
>>> shipment_out.state
'packed'
+3 -2
View File
@@ -26,8 +26,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="outgoing_moves" colspan="4" view_ids="stock.move_view_list_shipment"/>
</page>
<page string="Other Info" id="other">
<label name="assigned_by"/>
<field name="assigned_by"/>
<label name="picked_by"/>
<field name="picked_by"/>
<label name="packed_by"/>
<field name="packed_by"/>
<label name="done_by"/>
@@ -41,6 +41,7 @@ this repository contains the full copyright notices and license terms. -->
<button name="draft"/>
<button name="wait"/>
<button name="assign_wizard" icon="tryton-forward"/>
<button name="pick" icon="tryton-forward"/>
<button name="pack" icon="tryton-forward"/>
<button name="done" icon="tryton-ok"/>
</group>