Add packages weight

issue11123
review373001002
This commit is contained in:
Cédric Krier
2022-01-30 01:32:51 +01:00
parent d6e46390eb
commit ca7e7604d5
7 changed files with 100 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add packages weight
* Add support for Python 3.10
* Remove support for Python 3.6
+2
View File
@@ -18,6 +18,8 @@ def register():
module='stock_shipment_measurements', type_='model')
Pool.register(
stock.Package,
stock.ShipmentOutPackage,
stock.ShipmentInReturnPackage,
module='stock_shipment_measurements', type_='model',
depends=['stock_package'])
Pool.register(
+20
View File
@@ -294,3 +294,23 @@ class Package(MeasurementsMixin, object, metaclass=PoolMeta):
self.packaging_weight_uom, self.packaging_weight, kg,
round=False)
return measurement
class MeasurementsPackageMixin:
__slots__ = ()
packages_weight = fields.Function(
fields.Float("Packages Weight", digits=None,
help="The total weight of the packages in kg."),
'get_packages_weight')
def get_packages_weight(self, name):
return sum(p.total_weight for p in self.root_packages)
class ShipmentOutPackage(MeasurementsPackageMixin, metaclass=PoolMeta):
__name__ = 'stock.shipment.out'
class ShipmentInReturnPackage(MeasurementsPackageMixin, metaclass=PoolMeta):
__name__ = 'stock.shipment.in.return'
+47
View File
@@ -8,21 +8,42 @@ this repository contains the full copyright notices and license terms. -->
<field name="inherit" ref="stock.shipment_in_view_tree"/>
<field name="name">shipment_list</field>
</record>
<record model="ir.ui.view" id="shipment_in_view_form">
<field name="model">stock.shipment.in</field>
<field name="inherit" ref="stock.shipment_in_view_form"/>
<field name="name">shipment_form</field>
</record>
<record model="ir.ui.view" id="shipment_in_return_view_list">
<field name="model">stock.shipment.in.return</field>
<field name="inherit" ref="stock.shipment_in_return_view_tree"/>
<field name="name">shipment_list</field>
</record>
<record model="ir.ui.view" id="shipment_in_return_view_form">
<field name="model">stock.shipment.in.return</field>
<field name="inherit" ref="stock.shipment_in_return_view_form"/>
<field name="name">shipment_form</field>
</record>
<record model="ir.ui.view" id="shipment_out_view_list">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_tree"/>
<field name="name">shipment_list</field>
</record>
<record model="ir.ui.view" id="shipment_out_view_form">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_form"/>
<field name="name">shipment_form</field>
</record>
<record model="ir.ui.view" id="shipment_out_return_view_list">
<field name="model">stock.shipment.out.return</field>
<field name="inherit" ref="stock.shipment_out_return_view_tree"/>
<field name="name">shipment_list</field>
</record>
<record model="ir.ui.view" id="shipment_out_return_view_form">
<field name="model">stock.shipment.out.return</field>
<field name="inherit" ref="stock.shipment_out_return_view_form"/>
<field name="name">shipment_form</field>
</record>
</data>
<data depends="stock_package">
<record model="ir.ui.view" id="package_view_tree">
@@ -40,5 +61,31 @@ this repository contains the full copyright notices and license terms. -->
<field name="inherit" ref="stock_package.package_view_form"/>
<field name="name">package_form</field>
</record>
<record model="ir.ui.view" id="shipment_in_return_view_list_package">
<field name="model">stock.shipment.in.return</field>
<field name="inherit" ref="stock.shipment_in_return_view_tree"/>
<field name="priority" eval="20"/>
<field name="name">shipment_list_package</field>
</record>
<record model="ir.ui.view" id="shipment_in_return_view_form_package">
<field name="model">stock.shipment.in.return</field>
<field name="inherit" ref="stock.shipment_in_return_view_form"/>
<field name="priority" eval="20"/>
<field name="name">shipment_form_package</field>
</record>
<record model="ir.ui.view" id="shipment_out_view_list_package">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_tree"/>
<field name="priority" eval="20"/>
<field name="name">shipment_list_package</field>
</record>
<record model="ir.ui.view" id="shipment_out_view_form_package">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_form"/>
<field name="priority" eval="20"/>
<field name="name">shipment_form_package</field>
</record>
</data>
</tryton>
+13
View File
@@ -0,0 +1,13 @@
<?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="//page[@id='other']" position="inside">
<separator id="measurements" colspan="4" string="Measurements"/>
<label name="weight"/>
<field name="weight"/>
<label name="volume"/>
<field name="volume"/>
<newline/>
</xpath>
</data>
+9
View File
@@ -0,0 +1,9 @@
<?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='weight']" position="after">
<label name="packages_weight"/>
<field name="packages_weight"/>
</xpath>
</data>
+8
View File
@@ -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="/tree/field[@name='weight']" position="after">
<field name="packages_weight"/>
</xpath>
</data>