From 99e3d580ad8a7bd66b554cafa09aaf5adb318561 Mon Sep 17 00:00:00 2001 From: David-Luis-Mora Date: Mon, 6 May 2024 14:33:23 +0100 Subject: [PATCH] [17.0][MIG] base_delivery_carrier_label: Migration to 17.0 --- base_delivery_carrier_label/README.rst | 4 +++ base_delivery_carrier_label/__manifest__.py | 4 +-- .../models/delivery_carrier.py | 2 +- .../delivery_carrier_template_option.py | 5 ++-- .../models/stock_move_line.py | 4 +-- .../models/stock_picking.py | 1 - .../models/stock_quant_package.py | 5 ++-- .../readme/CONTRIBUTORS.md | 3 +++ .../static/description/index.html | 16 ++++++++--- .../tests/carrier_label_case.py | 4 +-- .../tests/test_get_weight.py | 16 +++++------ .../tests/test_manifest_wizard.py | 7 ++--- .../tests/test_send.py | 10 +++---- .../views/delivery.xml | 27 +++++++------------ base_delivery_carrier_label/views/stock.xml | 11 +++++--- .../wizard/manifest_wizard.py | 8 +++--- .../wizard/manifest_wizard_view.xml | 18 ++++++------- 17 files changed, 76 insertions(+), 69 deletions(-) diff --git a/base_delivery_carrier_label/README.rst b/base_delivery_carrier_label/README.rst index 34b78f0ec8..cdd5e3f9e5 100644 --- a/base_delivery_carrier_label/README.rst +++ b/base_delivery_carrier_label/README.rst @@ -98,6 +98,10 @@ Contributors - Dave Lasley - Timothée Ringeard - Pimolnat Suntian +- Maksym Yankin +- `Binhex `__: + + - David Luis Mora Maintainers ----------- diff --git a/base_delivery_carrier_label/__manifest__.py b/base_delivery_carrier_label/__manifest__.py index dc859b5589..6b8aa4a4c9 100644 --- a/base_delivery_carrier_label/__manifest__.py +++ b/base_delivery_carrier_label/__manifest__.py @@ -2,12 +2,12 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Base module for carrier labels", - "version": "16.0.1.1.1", + "version": "17.0.1.0.0", "author": "Camptocamp,Akretion,Odoo Community Association (OCA)", "maintainer": "Camptocamp", "category": "Delivery", "depends": [ - "delivery", + "stock_delivery", "delivery_carrier_info", ], "website": "https://github.com/OCA/delivery-carrier", diff --git a/base_delivery_carrier_label/models/delivery_carrier.py b/base_delivery_carrier_label/models/delivery_carrier.py index e678d1319b..eb364a713d 100644 --- a/base_delivery_carrier_label/models/delivery_carrier.py +++ b/base_delivery_carrier_label/models/delivery_carrier.py @@ -42,7 +42,7 @@ def send_shipping(self, pickings): result = super().send_shipping(pickings) if not result: result = self.alternative_send_shipping(pickings) - for result_dict, picking in zip(result, pickings): + for result_dict, picking in zip(result, pickings, strict=False): for label in result_dict.get("labels", []): picking.attach_shipping_label(label) return result diff --git a/base_delivery_carrier_label/models/delivery_carrier_template_option.py b/base_delivery_carrier_label/models/delivery_carrier_template_option.py index 064a1a5122..32d4316977 100644 --- a/base_delivery_carrier_label/models/delivery_carrier_template_option.py +++ b/base_delivery_carrier_label/models/delivery_carrier_template_option.py @@ -12,9 +12,8 @@ class DeliveryCarrierTemplateOption(models.Model): _description = "Delivery carrier template option" partner_id = fields.Many2one(comodel_name="res.partner", string="Partner Carrier") - name = fields.Char(readonly=True) - code = fields.Char(readonly=True) + name = fields.Char() + code = fields.Char() description = fields.Char( - readonly=True, help="Allow to define a more complete description " "than in the name field.", ) diff --git a/base_delivery_carrier_label/models/stock_move_line.py b/base_delivery_carrier_label/models/stock_move_line.py index e46197a881..3b9057c11f 100644 --- a/base_delivery_carrier_label/models/stock_move_line.py +++ b/base_delivery_carrier_label/models/stock_move_line.py @@ -36,9 +36,9 @@ def get_weight(self): "Type conversion not implemented for product %s", product.id ) cant_calc_total = True - # reserved_qty may be 0 if you don't set move line + # quantity_product_uom may be 0 if you don't set move line # individually but directly validate the picking - qty = operation.qty_done or operation.reserved_qty + qty = operation.quantity or operation.quantity_product_uom operation.weight = product.weight * qty total_weight += operation.weight diff --git a/base_delivery_carrier_label/models/stock_picking.py b/base_delivery_carrier_label/models/stock_picking.py index 7f0f0fff0c..dae9b4d83f 100644 --- a/base_delivery_carrier_label/models/stock_picking.py +++ b/base_delivery_carrier_label/models/stock_picking.py @@ -16,7 +16,6 @@ class StockPicking(models.Model): carrier_id = fields.Many2one( comodel_name="delivery.carrier", string="Carrier", - states={"done": [("readonly", True)]}, ) carrier_code = fields.Char(related="carrier_id.code", readonly=True) option_ids = fields.Many2many( diff --git a/base_delivery_carrier_label/models/stock_quant_package.py b/base_delivery_carrier_label/models/stock_quant_package.py index 91a9632021..42797e22eb 100644 --- a/base_delivery_carrier_label/models/stock_quant_package.py +++ b/base_delivery_carrier_label/models/stock_quant_package.py @@ -13,7 +13,7 @@ class StockQuantPackage(models.Model): help="Link to the carrier's tracking page for this package." ) - @api.depends("shipping_weight") + @api.depends("shipping_weight", "quant_ids", "package_type_id") def _compute_weight(self): """Use shipping_weight if defined otherwise fallback on the computed weight @@ -22,7 +22,7 @@ def _compute_weight(self): for pack in self: if pack.shipping_weight: pack.weight = pack.shipping_weight - elif not pack.quant_ids and not self.env.context.get("picking_id"): + elif pack.quant_ids and not self.env.context.get("picking_id"): # package.pack_operations would be too easy operations = self.env["stock.move.line"].search( [ @@ -31,6 +31,7 @@ def _compute_weight(self): ("product_id", "!=", False), ] ) + pack.weight = operations.get_weight() else: to_do |= pack diff --git a/base_delivery_carrier_label/readme/CONTRIBUTORS.md b/base_delivery_carrier_label/readme/CONTRIBUTORS.md index 445f8e3ee1..abe0c05392 100644 --- a/base_delivery_carrier_label/readme/CONTRIBUTORS.md +++ b/base_delivery_carrier_label/readme/CONTRIBUTORS.md @@ -7,3 +7,6 @@ - Dave Lasley \<\> - Timothée Ringeard \<\> - Pimolnat Suntian \<\> +- Maksym Yankin \<\> +- [Binhex](https://binhex.cloud//com): + - David Luis Mora \<\> diff --git a/base_delivery_carrier_label/static/description/index.html b/base_delivery_carrier_label/static/description/index.html index 6d301760ed..38613cd854 100644 --- a/base_delivery_carrier_label/static/description/index.html +++ b/base_delivery_carrier_label/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -439,12 +440,19 @@

Contributors

  • Dave Lasley <dave@laslabs.com>
  • Timothée Ringeard <timothee.ringeard@camptocamp.com>
  • Pimolnat Suntian <pimolnats@ecosoft.co.th>
  • +
  • Maksym Yankin <maksym.yankin@camptocamp.com>
  • +
  • Binhex: +
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    diff --git a/base_delivery_carrier_label/tests/carrier_label_case.py b/base_delivery_carrier_label/tests/carrier_label_case.py index 965e7cc030..230a096067 100644 --- a/base_delivery_carrier_label/tests/carrier_label_case.py +++ b/base_delivery_carrier_label/tests/carrier_label_case.py @@ -9,8 +9,8 @@ class CarrierLabelCase(TransactionCase): """Base class for carrier label tests. Inherit and override _get_carrier to return the carrier you want to test""" - def setUp(self, *args, **kwargs): - super().setUp(*args, **kwargs) + def setUpClass(self): + super().setUpClass(self) self._create_order_picking() @property diff --git a/base_delivery_carrier_label/tests/test_get_weight.py b/base_delivery_carrier_label/tests/test_get_weight.py index febdfa9bc5..1aa6ff024e 100644 --- a/base_delivery_carrier_label/tests/test_get_weight.py +++ b/base_delivery_carrier_label/tests/test_get_weight.py @@ -78,7 +78,7 @@ def test_get_weight(self): operations |= self._create_operation( picking, { - "reserved_uom_qty": 1, + "quantity": 1, "product_id": product.id, "product_uom_id": product.uom_id.id, "result_package_id": package.id, @@ -90,7 +90,7 @@ def test_get_weight(self): for operation in operations: self.assertEqual( operation.get_weight(), - operation.product_id.weight * operation.reserved_uom_qty, + operation.product_id.weight * operation.quantity_product_uom, ) # test package.weight @@ -109,7 +109,7 @@ def test_total_weight(self): operations |= self._create_operation( picking, { - "reserved_uom_qty": 1, + "quantity": 1, "product_id": product.id, "product_uom_id": product.uom_id.id, "result_package_id": package.id, @@ -122,7 +122,7 @@ def test_total_weight(self): for operation in operations: self.assertEqual( operation.get_weight(), - operation.product_id.weight * operation.reserved_uom_qty, + operation.product_id.weight * operation.quantity_product_uom, ) # test package.weight @@ -136,11 +136,11 @@ def test_get_weight_with_qty(self): picking = self._generate_picking(products) package = self.env["stock.quant.package"].create({}) operations = self.env["stock.move.line"] - for idx, product in enumerate(products): + for idx, product in enumerate(products, start=1): operations |= self._create_operation( picking, { - "reserved_uom_qty": idx, # nice one + "quantity": idx, # nice one "product_id": product.id, "product_uom_id": product.uom_id.id, "result_package_id": package.id, @@ -152,7 +152,7 @@ def test_get_weight_with_qty(self): for operation in operations: self.assertEqual( operation.get_weight(), - operation.product_id.weight * operation.reserved_uom_qty, + operation.product_id.weight * operation.quantity_product_uom, ) # test package._weight @@ -208,7 +208,7 @@ def test_get_weight_with_uom(self): operations |= self._create_operation( picking, { - "reserved_uom_qty": 1, + "quantity": 1, "product_id": product.id, "product_uom_id": product.uom_id.id, "result_package_id": package.id, diff --git a/base_delivery_carrier_label/tests/test_manifest_wizard.py b/base_delivery_carrier_label/tests/test_manifest_wizard.py index 64d9822b01..ea7c3393a2 100644 --- a/base_delivery_carrier_label/tests/test_manifest_wizard.py +++ b/base_delivery_carrier_label/tests/test_manifest_wizard.py @@ -6,9 +6,10 @@ class ManifestWizardCase(TransactionCase): - def setUp(self): - super(ManifestWizardCase, self).setUp() - self.free_delivery = self.env.ref("delivery.free_delivery_carrier") + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.free_delivery = cls.env.ref("delivery.free_delivery_carrier") def test_wizard(self): """Create manifest wizard.""" diff --git a/base_delivery_carrier_label/tests/test_send.py b/base_delivery_carrier_label/tests/test_send.py index 60c9fc62f5..569b0a615f 100644 --- a/base_delivery_carrier_label/tests/test_send.py +++ b/base_delivery_carrier_label/tests/test_send.py @@ -3,7 +3,7 @@ import base64 from unittest import mock -from odoo.tests.common import Form, TransactionCase +from odoo.tests.common import TransactionCase class TestSend(TransactionCase): @@ -12,13 +12,13 @@ class TestSend(TransactionCase): def test_send(self): """Test if the module picks up labels returned from delivery.carrier#send""" carrier = self.env.ref("delivery.delivery_carrier") - picking_form = Form( - self.env["stock.picking"].with_context( + picking = ( + self.env["stock.picking"] + .with_context( default_picking_type_id=self.env.ref("stock.picking_type_out").id, ) + .create({"carrier_id": carrier.id}) ) - picking_form.carrier_id = carrier - picking = picking_form.save() package = self.env["stock.quant.package"].create({}) with mock.patch.object(type(carrier), "base_on_rule_send_shipping") as mocked: diff --git a/base_delivery_carrier_label/views/delivery.xml b/base_delivery_carrier_label/views/delivery.xml index ff1a0523ed..77c5f58ec9 100644 --- a/base_delivery_carrier_label/views/delivery.xml +++ b/base_delivery_carrier_label/views/delivery.xml @@ -8,13 +8,13 @@
    - + - + - +
    @@ -27,8 +27,8 @@ - - + + @@ -41,21 +41,12 @@ - - - + + + - + diff --git a/base_delivery_carrier_label/views/stock.xml b/base_delivery_carrier_label/views/stock.xml index c612cb881c..dde76b27e0 100644 --- a/base_delivery_carrier_label/views/stock.xml +++ b/base_delivery_carrier_label/views/stock.xml @@ -4,7 +4,10 @@ stock.picking - + @@ -19,7 +22,7 @@ stock.picking - + show @@ -42,7 +45,7 @@ class="oe_stat_button" icon='fa-truck' string="Tracking" - attrs="{'invisible': [('parcel_tracking','=',False)]}" + invisible="not parcel_tracking" />
    @@ -58,7 +61,7 @@ icon='fa-truck' title="Carrier Tracking URL" string="" - attrs="{'invisible': [('parcel_tracking','=',False)]}" + invisible="not parcel_tracking" /> diff --git a/base_delivery_carrier_label/wizard/manifest_wizard.py b/base_delivery_carrier_label/wizard/manifest_wizard.py index 44f0c33485..be5494ac89 100644 --- a/base_delivery_carrier_label/wizard/manifest_wizard.py +++ b/base_delivery_carrier_label/wizard/manifest_wizard.py @@ -12,17 +12,15 @@ class ManifestWizard(models.TransientModel): carrier_id = fields.Many2one( comodel_name="delivery.carrier", string="Carrier", - states={"done": [("readonly", True)]}, required=True, ) from_date = fields.Datetime(required=True) to_date = fields.Datetime() - file_out = fields.Binary("Manifest", readonly=True) - filename = fields.Char("File Name", readonly=True) - notes = fields.Text("Result", readonly=True) + file_out = fields.Binary("Manifest") + filename = fields.Char("File Name") + notes = fields.Text("Result") state = fields.Selection( [("init", "Init"), ("file", "File"), ("end", "END")], - readonly=True, default="init", ) diff --git a/base_delivery_carrier_label/wizard/manifest_wizard_view.xml b/base_delivery_carrier_label/wizard/manifest_wizard_view.xml index a9169dddc0..e80378d30b 100644 --- a/base_delivery_carrier_label/wizard/manifest_wizard_view.xml +++ b/base_delivery_carrier_label/wizard/manifest_wizard_view.xml @@ -6,20 +6,20 @@ form
    - - - + + + - - - + + + - - + + -