Default From To
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
</field>
|
||||
<field name="r_vessel" width="130" optional="1"/>
|
||||
<field name="r_operator" width="130" optional="1"/>
|
||||
<field name="r_bl_date" width="90" optional="1"/>
|
||||
<field name="r_bl_number" width="110" optional="1"/>
|
||||
<field name="r_shipping_status" widget="badge" string="Shipping status" badge_colors="shipped:#16a34a,unshipped:#ef4444,planned:#06b6d4,scheduled:#f59e0b" width="120"/>
|
||||
<field name="r_lot_status"/>
|
||||
<field name="r_lot_av" width="80" optional="1" tree_invisible="1"/>
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
<label name="shipment"/>
|
||||
<field name="shipment"/>
|
||||
<label name="shipment_in"/>
|
||||
<field name="shipment_in"/>
|
||||
<field name="shipment_in" context="{'lot_shipping_planned_from_location': Eval('planned_from_location'), 'lot_shipping_planned_to_location': Eval('planned_to_location')}"/>
|
||||
<label name="shipment_out"/>
|
||||
<field name="shipment_out"/>
|
||||
<label name="shipment_internal"/>
|
||||
<field name="shipment_internal"/>
|
||||
<field name="planned_from_location" invisible="1"/>
|
||||
<field name="planned_to_location" invisible="1"/>
|
||||
<label name="full"/>
|
||||
<field name="full"/>
|
||||
<label name="quantity"/>
|
||||
|
||||
Reference in New Issue
Block a user