From 19693e7a9848be65da2c5045791921b1dd46c461 Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Thu, 11 Jan 2024 12:24:05 +0100 Subject: [PATCH] [IMP] l10n_it_delivery_note: link carrier with delivery method --- l10n_it_delivery_note/README.rst | 2 +- l10n_it_delivery_note/__manifest__.py | 4 ++-- .../migrations/14.0.2.6.0/post-migrate.py | 11 +++++++++++ l10n_it_delivery_note/models/res_partner.py | 2 +- l10n_it_delivery_note/models/stock_delivery_note.py | 2 +- l10n_it_delivery_note/static/description/index.html | 3 ++- l10n_it_delivery_note/views/res_partner.xml | 1 - l10n_it_delivery_note/views/stock_delivery_note.xml | 5 +---- l10n_it_delivery_note/views/stock_picking.xml | 1 - l10n_it_delivery_note/wizard/delivery_note_base.py | 12 ++++++++++++ .../wizard/delivery_note_select.py | 13 ++++++++++++- .../wizard/delivery_note_select.xml | 8 ++++++++ 12 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 l10n_it_delivery_note/migrations/14.0.2.6.0/post-migrate.py diff --git a/l10n_it_delivery_note/README.rst b/l10n_it_delivery_note/README.rst index f75cc4516d2a..f1d652754a57 100644 --- a/l10n_it_delivery_note/README.rst +++ b/l10n_it_delivery_note/README.rst @@ -7,7 +7,7 @@ ITA - Documento di trasporto !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:48fb8a0d085dce618e7696ef8bdb30aa56d61f48d3db5f895cf477ddf0d3505c + !! source digest: sha256:e389fbd4dff70da2d65271df7684c21141a86b5e861217fe285b4df642e5a57a !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/l10n_it_delivery_note/__manifest__.py b/l10n_it_delivery_note/__manifest__.py index 5aca02197b07..b94f657811ac 100644 --- a/l10n_it_delivery_note/__manifest__.py +++ b/l10n_it_delivery_note/__manifest__.py @@ -13,12 +13,12 @@ "author": "Marco Calcagni, Gianmarco Conte, Link IT Europe Srl, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/l10n-italy", - "version": "14.0.2.5.0", + "version": "14.0.2.6.0", "category": "Localization/Italy", "license": "AGPL-3", "maintainers": ["MarcoCalcagni", "aleuffre", "renda-dev"], "depends": [ - "delivery", + "delivery_carrier_partner", "l10n_it_delivery_note_base", "mail", "sale_stock", diff --git a/l10n_it_delivery_note/migrations/14.0.2.6.0/post-migrate.py b/l10n_it_delivery_note/migrations/14.0.2.6.0/post-migrate.py new file mode 100644 index 000000000000..b761e4031c6b --- /dev/null +++ b/l10n_it_delivery_note/migrations/14.0.2.6.0/post-migrate.py @@ -0,0 +1,11 @@ +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + note_ids = env["stock.delivery.note"].search( + [("carrier_id", "!=", False), ("delivery_method_id", "!=", False)] + ) + + for note_id in note_ids: + note_id.carrier_id.write({"carrier_ids": [(4, note_id.delivery_method_id.id)]}) diff --git a/l10n_it_delivery_note/models/res_partner.py b/l10n_it_delivery_note/models/res_partner.py index 31a36e66eaf4..d71e3d68cc06 100644 --- a/l10n_it_delivery_note/models/res_partner.py +++ b/l10n_it_delivery_note/models/res_partner.py @@ -19,4 +19,4 @@ class ResPartner(models.Model): default_transport_method_id = fields.Many2one( "stock.picking.transport.method", string="Method of transport" ) - is_carrier = fields.Boolean("Is Carrier") + carrier_ids = fields.One2many("delivery.carrier", "partner_id", string="Carrier") diff --git a/l10n_it_delivery_note/models/stock_delivery_note.py b/l10n_it_delivery_note/models/stock_delivery_note.py index b99dccecf0b2..1c502b838c46 100644 --- a/l10n_it_delivery_note/models/stock_delivery_note.py +++ b/l10n_it_delivery_note/models/stock_delivery_note.py @@ -143,7 +143,7 @@ def _domain_weight_uom(self): string="Carrier", states=DONE_READONLY_STATE, tracking=True, - domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + related="delivery_method_id.partner_id", ) delivery_method_id = fields.Many2one( "delivery.carrier", diff --git a/l10n_it_delivery_note/static/description/index.html b/l10n_it_delivery_note/static/description/index.html index 21b5b801a86f..43fba4276a7d 100644 --- a/l10n_it_delivery_note/static/description/index.html +++ b/l10n_it_delivery_note/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@

ITA - Documento di trasporto

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:48fb8a0d085dce618e7696ef8bdb30aa56d61f48d3db5f895cf477ddf0d3505c +!! source digest: sha256:e389fbd4dff70da2d65271df7684c21141a86b5e861217fe285b4df642e5a57a !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runboat

English

diff --git a/l10n_it_delivery_note/views/res_partner.xml b/l10n_it_delivery_note/views/res_partner.xml index 965c49b0a1ed..186739fe4475 100644 --- a/l10n_it_delivery_note/views/res_partner.xml +++ b/l10n_it_delivery_note/views/res_partner.xml @@ -12,7 +12,6 @@ - diff --git a/l10n_it_delivery_note/views/stock_delivery_note.xml b/l10n_it_delivery_note/views/stock_delivery_note.xml index af27e90b7318..021173ba4deb 100644 --- a/l10n_it_delivery_note/views/stock_delivery_note.xml +++ b/l10n_it_delivery_note/views/stock_delivery_note.xml @@ -156,10 +156,7 @@ - + diff --git a/l10n_it_delivery_note/views/stock_picking.xml b/l10n_it_delivery_note/views/stock_picking.xml index a1b8432206fc..ad6352b512be 100644 --- a/l10n_it_delivery_note/views/stock_picking.xml +++ b/l10n_it_delivery_note/views/stock_picking.xml @@ -204,7 +204,6 @@ -from odoo import api, fields, models +from odoo import _, api, fields, models class StockDeliveryNoteSelectWizard(models.TransientModel): @@ -37,6 +37,17 @@ def _compute_fields(self): self.picking_ids += self.selected_picking_ids else: self.picking_ids = self.picking_ids + self.warning_message = self._get_warning_message() + + def _get_warning_message(self): + res = super()._get_warning_message() + carrier_ids = self.picking_ids.mapped("carrier_id.partner_id") + if len(carrier_ids) > 1: + res = _( + "The selected pickings have different delivery methods: %(carriers)s", + carriers=", ".join(carrier_ids.mapped("name")), + ) + return res def check_compliance(self, pickings): super().check_compliance(pickings) diff --git a/l10n_it_delivery_note/wizard/delivery_note_select.xml b/l10n_it_delivery_note/wizard/delivery_note_select.xml index f14a454dcda0..fce33925fd60 100644 --- a/l10n_it_delivery_note/wizard/delivery_note_select.xml +++ b/l10n_it_delivery_note/wizard/delivery_note_select.xml @@ -14,6 +14,14 @@ +