diff --git a/modules/purchase_trade/lot.py b/modules/purchase_trade/lot.py
index 36f8563..975ae5c 100755
--- a/modules/purchase_trade/lot.py
+++ b/modules/purchase_trade/lot.py
@@ -2108,6 +2108,8 @@ class LotQt(
lqt.lot_shipment_internal.as_('r_lot_shipment_internal'),
si.vessel.as_('r_vessel'),
si.operator.as_('r_operator'),
+ si.bl_date.as_('r_bl_date'),
+ si.bl_number.as_('r_bl_number'),
lqt.lot_move.as_('r_lot_move'),
lqt.lot_status.as_('r_lot_status'),
Case((lp.lot_type=='physic',lp.lot_av),else_=lqt.lot_av).as_('r_lot_av'),
@@ -2264,6 +2266,8 @@ class LotQt(
lp.lot_shipment_internal.as_('r_lot_shipment_internal'),
si.vessel.as_("r_vessel"),
si.operator.as_("r_operator"),
+ si.bl_date.as_("r_bl_date"),
+ si.bl_number.as_("r_bl_number"),
lp.move.as_("r_lot_move"),
lp.lot_status.as_("r_lot_status"),
lp.lot_av.as_("r_lot_av"),
@@ -2340,6 +2344,8 @@ class LotQt(
lp.lot_shipment_internal.as_('r_lot_shipment_internal'),
Max(si.vessel).as_("r_vessel"),
Max(si.operator).as_("r_operator"),
+ Max(si.bl_date).as_("r_bl_date"),
+ Max(si.bl_number).as_("r_bl_number"),
Max(lp.move).as_("r_lot_move"),
Max(lp.lot_status).as_("r_lot_status"),
Max(lp.lot_av).as_("r_lot_av"),
@@ -2404,6 +2410,8 @@ class LotQt(
union.r_lot_shipment_internal.as_('r_lot_shipment_internal'),
union.r_vessel.as_("r_vessel"),
union.r_operator.as_("r_operator"),
+ union.r_bl_date.as_("r_bl_date"),
+ union.r_bl_number.as_("r_bl_number"),
union.r_lot_move.as_("r_lot_move"),
union.r_lot_status.as_("r_lot_status"),
union.r_lot_av.as_("r_lot_av"),
@@ -2492,6 +2500,8 @@ class LotReport(
r_lot_shipment_internal = fields.Many2One('stock.shipment.internal', "Shipment Internal")
r_vessel = fields.Many2One('trade.vessel', "Vessel")
r_operator = fields.Many2One('party.party', "Operator")
+ r_bl_date = fields.Date("BL date")
+ r_bl_number = fields.Char("BL number")
r_lot_move = fields.Many2One('stock.move', "Move")
r_lot_parent = fields.Many2One('lot.lot',"Parent")
r_lot_himself = fields.Many2One('lot.lot',"Lot")
@@ -2953,17 +2963,23 @@ class LotShipping(Wizard):
shipping = StateTransition()
- def transition_start(self):
- if self.model.__name__ == 'lot.report':
- return 'ship'
- return 'end'
-
- #def default_ship(self, fields):
- #values = []
- # if self.model.__name__ == 'lot.report':
- # return {
- # }
-
+ def transition_start(self):
+ if self.model.__name__ == 'lot.report':
+ return 'ship'
+ return 'end'
+
+ def default_ship(self, fields):
+ values = {}
+ if len(self.records) != 1:
+ return values
+ record = self.records[0]
+ if record.r_planned_from_location:
+ values['planned_from_location'] = (
+ record.r_planned_from_location.id)
+ if record.r_planned_to_location:
+ values['planned_to_location'] = record.r_planned_to_location.id
+ return values
+
def transition_shipping(self):
Lot = Pool().get('lot.lot')
LotQt = Pool().get('lot.qt')
@@ -3078,11 +3094,15 @@ class LotShippingStart(ModelView):
('out', 'Shipment Out'),
('int', 'Internal Shipment'),
], 'Shipment type', readonly=True)
- shipment_in = fields.Many2One('stock.shipment.in',"Shipment In", states={'invisible': (Eval('shipment') != 'in')})
- shipment_out = fields.Many2One('stock.shipment.out',"Shipment Out", states={'invisible': (Eval('shipment') != 'out')})
- shipment_internal = fields.Many2One('stock.shipment.internal',"Shipment Internal", states={'invisible': (Eval('shipment') != 'int')})
- full = fields.Boolean("Link all the lot")
- quantity = fields.Numeric("Qt", states={'readonly': (Eval('full') == True)})
+ shipment_in = fields.Many2One('stock.shipment.in',"Shipment In", states={'invisible': (Eval('shipment') != 'in')})
+ shipment_out = fields.Many2One('stock.shipment.out',"Shipment Out", states={'invisible': (Eval('shipment') != 'out')})
+ shipment_internal = fields.Many2One('stock.shipment.internal',"Shipment Internal", states={'invisible': (Eval('shipment') != 'int')})
+ planned_from_location = fields.Many2One(
+ 'stock.location', "Planned From", readonly=True)
+ planned_to_location = fields.Many2One(
+ 'stock.location', "Planned To", readonly=True)
+ full = fields.Boolean("Link all the lot")
+ quantity = fields.Numeric("Qt", states={'readonly': (Eval('full') == True)})
@classmethod
def default_full(cls):
diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py
index 37654ad..a31b73e 100755
--- a/modules/purchase_trade/stock.py
+++ b/modules/purchase_trade/stock.py
@@ -1749,6 +1749,28 @@ class ShipmentIn(metaclass=PoolMeta):
def default_cargo_mode(cls):
return 'bulk'
+ @classmethod
+ def default_from_location(cls):
+ location = Transaction().context.get(
+ 'lot_shipping_planned_from_location')
+ if location:
+ return location
+ try:
+ return super().default_from_location()
+ except AttributeError:
+ return None
+
+ @classmethod
+ def default_to_location(cls):
+ location = Transaction().context.get(
+ 'lot_shipping_planned_to_location')
+ if location:
+ return location
+ try:
+ return super().default_to_location()
+ except AttributeError:
+ return None
+
@fields.depends('transport_type', 'cargo_mode', 'vessel')
def on_change_transport_type(self):
if self.transport_type == 'truck':
diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py
index b656936..a4c57c7 100644
--- a/modules/purchase_trade/tests/test_module.py
+++ b/modules/purchase_trade/tests/test_module.py
@@ -206,6 +206,19 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(affected_lines, [purchase_line, sale_line])
+ def test_lot_shipping_defaults_planned_locations(self):
+ 'link to transport carries planned locations into shipment create'
+ wizard = lot_module.LotShipping()
+ wizard.records = [Mock(
+ r_planned_from_location=Mock(id=10),
+ r_planned_to_location=Mock(id=20),
+ )]
+
+ self.assertEqual(wizard.default_ship(None), {
+ 'planned_from_location': 10,
+ 'planned_to_location': 20,
+ })
+
@with_transaction()
def test_get_mtm_applies_component_ratio_as_percentage(self):
'get_mtm treats component ratio as a percentage'
diff --git a/modules/purchase_trade/view/lot_report_list.xml b/modules/purchase_trade/view/lot_report_list.xml
index 21cdf2b..f18f01a 100755
--- a/modules/purchase_trade/view/lot_report_list.xml
+++ b/modules/purchase_trade/view/lot_report_list.xml
@@ -25,6 +25,8 @@
+
+
diff --git a/modules/purchase_trade/view/lot_shipping_start_form.xml b/modules/purchase_trade/view/lot_shipping_start_form.xml
index ee30109..33da66f 100755
--- a/modules/purchase_trade/view/lot_shipping_start_form.xml
+++ b/modules/purchase_trade/view/lot_shipping_start_form.xml
@@ -3,11 +3,13 @@
-
+
+
+