-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] delivery_carrier_package_measure_required: Migration to 16.0"
- Loading branch information
Showing
11 changed files
with
101 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from . import product_packaging | ||
from . import stock_package_type | ||
from . import stock_picking | ||
from . import stock_quant_package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
delivery_carrier_package_measure_required/views/product_packaging.xml
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
delivery_carrier_package_measure_required/views/stock_package_type_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="view_stock_package_type_form_delivery_inherit" model="ir.ui.view"> | ||
<field name="name">stock.package.type.form.delivery</field> | ||
<field name="model">stock.package.type</field> | ||
<field name="inherit_id" ref="delivery.stock_package_type_form_delivery" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='delivery']" position="inside"> | ||
<group | ||
name="carrier_required_mesaurement" | ||
string="Carrier Required Measurements" | ||
> | ||
<field name="package_length_required" /> | ||
<field name="package_width_required" /> | ||
<field name="package_height_required" /> | ||
<field name="package_weight_required" /> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
57 changes: 39 additions & 18 deletions
57
delivery_carrier_package_measure_required/wizard/choose_delivery_package.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,56 @@ | ||
# Copyright 2022 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import fields, models | ||
from odoo import api, fields, models | ||
|
||
|
||
class ChooseDeliveryPackage(models.TransientModel): | ||
_inherit = "choose.delivery.package" | ||
|
||
pick_name = fields.Char(related="picking_id.name") | ||
@api.depends("delivery_package_type_id") | ||
def _compute_dimension_uom_name(self): | ||
length_uom_id = self.env[ | ||
"product.template" | ||
]._get_length_uom_id_from_ir_config_parameter() | ||
for package in self: | ||
package.dimension_uom_name = length_uom_id.name | ||
|
||
def _default_dimension_uom_id(self): | ||
val = self.env["product.template"]._get_length_uom_id_from_ir_config_parameter() | ||
return val | ||
@api.depends("delivery_package_type_id") | ||
def _compute_dimension(self): | ||
for package in self: | ||
package.package_length = ( | ||
package.delivery_package_type_id.packaging_length or 0 | ||
) | ||
package.package_width = package.delivery_package_type_id.width or 0 | ||
package.package_height = package.delivery_package_type_id.height or 0 | ||
|
||
package_height = fields.Integer() | ||
package_length = fields.Integer() | ||
package_width = fields.Integer() | ||
dimension_uom_id = fields.Many2one( | ||
"uom.uom", | ||
default=lambda self: self._default_dimension_uom_id(), | ||
package_length = fields.Integer( | ||
compute="_compute_dimension", store=True, readonly=False | ||
) | ||
dimension_uom_name = fields.Char(related="dimension_uom_id.name") | ||
package_width = fields.Integer( | ||
compute="_compute_dimension", store=True, readonly=False | ||
) | ||
package_height = fields.Integer( | ||
compute="_compute_dimension", store=True, readonly=False | ||
) | ||
dimension_uom_name = fields.Char(compute="_compute_dimension_uom_name") | ||
package_height_required = fields.Boolean( | ||
related="delivery_packaging_id.package_height_required" | ||
related="delivery_package_type_id.package_height_required" | ||
) | ||
package_length_required = fields.Boolean( | ||
related="delivery_packaging_id.package_length_required" | ||
) | ||
package_weight_required = fields.Boolean( | ||
related="delivery_packaging_id.package_weight_required" | ||
related="delivery_package_type_id.package_length_required" | ||
) | ||
package_width_required = fields.Boolean( | ||
related="delivery_packaging_id.package_width_required" | ||
related="delivery_package_type_id.package_width_required" | ||
) | ||
package_weight_required = fields.Boolean( | ||
related="delivery_package_type_id.package_weight_required" | ||
) | ||
|
||
def action_put_in_pack(self): | ||
self = self.with_context( | ||
choose_delivery_package_length=self.package_length, | ||
choose_delivery_package_width=self.package_width, | ||
choose_delivery_package_height=self.package_height, | ||
) | ||
return super().action_put_in_pack() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters