Add shipping to internal shipment with transit

This commit is contained in:
Cédric Krier committed 2024-12-22 18:22:36 +01:00
1 parent 768fc5c1a8
commit 5b1d989be1
6 files changed
+103

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Manage internal shipment with transit
Version 7.4.0 - 2024-11-04
--------------------------
@@ -11,6 +11,7 @@ def register():
stock.Package,
stock.ShipmentOut,
stock.ShipmentInReturn,
stock.ShipmentInternal,
carrier.Carrier,
module='stock_package_shipping', type_='model')
Pool.register(
+57
View File
@@ -310,6 +310,63 @@ class ShipmentInReturn(ShippingMixin, metaclass=PoolMeta):
return self.delivery_address
class ShipmentInternal(ShippingMixin, metaclass=PoolMeta):
__name__ = 'stock.shipment.internal'
carrier = fields.Many2One(
'carrier', "Carrier",
states={
'invisible': ~Eval('transit_location'),
'readonly': ~Eval('state').in_(['draft', 'waiting', 'assigned']),
})
@classmethod
def __setup__(cls):
super().__setup__()
shipping_invisible = ~Eval('transit_location')
for field in [
cls.shipping_reference,
cls.shipping_description,
cls.has_shipping_service]:
field.states['invisible'] = shipping_invisible
cls._buttons['create_shipping']['invisible'] |= shipping_invisible
@classmethod
@ModelView.button
@Workflow.transition('packed')
def pack(cls, shipments):
super().pack(shipments)
pool = Pool()
Warning = pool.get('res.user.warning')
for shipment in shipments:
if not shipment.transit_location:
continue
if not shipment.carrier:
name = Warning.format('no_carrier', [shipment])
if Warning.check(name):
raise PackWarning(
gettext('stock_package_shipping'
'.msg_shipment_without_carrier',
shipment=shipment.rec_name))
@property
def shipping_allowed(self):
return {'packed', 'shipped'}
@property
def shipping_warehouse(self):
return self.warehouse
@property
def shipping_to(self):
return self.company.party
@property
def shipping_to_address(self):
if self.to_location.warehouse:
return self.to_location.warehouse.address
class CreateShipping(Wizard):
__name__ = 'stock.shipment.create_shipping'
+18
View File
@@ -58,6 +58,24 @@ this repository contains the full copyright notices and license terms. -->
<field name="string">Create Shipping for Packages</field>
</record>
<record model="ir.ui.view" id="shipment_internal_view_form">
<field name="model">stock.shipment.internal</field>
<field name="inherit" ref="stock.shipment_internal_view_form"/>
<field name="name">shipment_internal_form</field>
</record>
<record model="ir.ui.view" id="shipment_internal_view_list">
<field name="model">stock.shipment.internal</field>
<field name="inherit" ref="stock.shipment_internal_view_tree"/>
<field name="name">shipment_internal_list</field>
</record>
<record model="ir.model.button" id="shipment_internal_create_shipping_button">
<field name="model">stock.shipment.internal</field>
<field name="name">create_shipping</field>
<field name="string">Create Shipping for Packages</field>
</record>
<record model="ir.action.wizard" id="act_create_shipping_wizard">
<field name="name">Create Shipping</field>
<field name="wiz_name">stock.shipment.create_shipping</field>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="before">
<label name="carrier"/>
<field name="carrier"/>
<label name="shipping_reference"/>
<field name="shipping_reference"/>
<newline/>
<label name="shipping_description"/>
<field name="shipping_description" colspan="3"/>
</xpath>
<xpath expr="//group[@id='buttons']" position="inside">
<button name="create_shipping"/>
</xpath>
</data>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//field[@name='reference']" position="after">
<field name="shipping_reference" expand="1" optional="1"/>
</xpath>
</data>