changeset 9b8c82346dd8 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=9b8c82346dd8
description:
Fix shipment report when locations are the same or transit location is
used
The inventory moves is empty when the locations of the shipment are the
same.
The other moves field must be used.
When a transit location is used for internal shipment, the moves field
to use
depend of the state. If it is already shipped then the incoming moves
is used
to know where to store products and if it is not yet shipped than the
outgoing
moves is used to pick the products.
issue7881
review50641002
diffstat:
CHANGELOG | 1 +
shipment.py | 53 +++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 44 insertions(+), 10 deletions(-)
diffs (107 lines):
diff -r 8eb35dafff08 -r 9b8c82346dd8 CHANGELOG
--- a/CHANGELOG Tue Dec 04 13:08:49 2018 +0100
+++ b/CHANGELOG Mon Dec 17 23:08:09 2018 +0100
@@ -1,3 +1,4 @@
+* Change move attribute of ShipmentReport for a method
* Rename inventory count quantity_resulting to total_quantity
Version 5.0.0 - 2018-10-01
diff -r 8eb35dafff08 -r 9b8c82346dd8 shipment.py
--- a/shipment.py Tue Dec 04 13:08:49 2018 +0100
+++ b/shipment.py Mon Dec 17 23:08:09 2018 +0100
@@ -2485,7 +2485,6 @@
class ShipmentReport(CompanyReport):
- move_attribute = 'inventory_moves'
@classmethod
def execute(cls, ids, data):
@@ -2493,25 +2492,29 @@
return super(ShipmentReport, cls).execute(ids, data)
@classmethod
- def get_context(cls, records, data):
- report_context = super(ShipmentReport, cls).get_context(records, data)
+ def moves(cls, shipment):
+ raise NotImplementedError
- compare_context = cls.get_compare_context(records, data)
+ @classmethod
+ def get_context(cls, shipments, data):
+ report_context = super().get_context(shipments, data)
+
+ compare_context = cls.get_compare_context(shipments, data)
sorted_moves = {}
- for shipment in records:
+ for shipment in shipments:
sorted_moves[shipment.id] = sorted(
- getattr(shipment, cls.move_attribute),
+ cls.moves(shipment),
key=functools.partial(cls.get_compare_key, compare_context))
report_context['moves'] = sorted_moves
return report_context
@classmethod
- def get_compare_context(cls, objects, data):
+ def get_compare_context(cls, shipments, data):
from_location_ids = set()
to_location_ids = set()
- for obj in objects:
- for move in getattr(obj, cls.move_attribute):
+ for shipment in shipments:
+ for move in cls.moves(shipment):
from_location_ids.add(move.from_location.id)
to_location_ids.add(move.to_location.id)
@@ -2532,18 +2535,48 @@
'Picking List'
__name__ = 'stock.shipment.out.picking_list'
+ @classmethod
+ def moves(cls, shipment):
+ if shipment.warehouse_storage == shipment.warehouse_output:
+ return shipment.outgoing_moves
+ else:
+ return shipment.inventory_moves
+
class SupplierRestockingList(ShipmentReport):
'Supplier Restocking List'
__name__ = 'stock.shipment.in.restocking_list'
+ @classmethod
+ def moves(cls, shipment):
+ if shipment.warehouse_input == shipment.warehouse_storage:
+ return shipment.incoming_moves
+ else:
+ return shipment.inventory_moves
+
class CustomerReturnRestockingList(ShipmentReport):
'Customer Return Restocking List'
__name__ = 'stock.shipment.out.return.restocking_list'
+ @classmethod
+ def moves(cls, shipment):
+ if shipment.warehouse_input == shipment.warehouse_storage:
+ return shipment.incoming_moves
+ else:
+ return shipment.inventory_moves
+
class InteralShipmentReport(ShipmentReport):
'Interal Shipment Report'
__name__ = 'stock.shipment.internal.report'
- move_attribute = 'moves'
+
+ @classmethod
+ def moves(cls, shipment):
+ if shipment.transit_location:
+ if shipment.state == 'shipped':
+ return shipment.incoming_moves
+ else:
+ return shipment.outgoing_moves
+ else:
+ return shipment.moves