diff --git a/l10n_it_delivery_note/README.rst b/l10n_it_delivery_note/README.rst index d607eedd283d..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:86cc264b131150d0e14a593b955879a5dfe4ecfe7db4069f8ede4f8a416c9e20 + !! 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 e75951c2591b..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.1", + "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/cli/migrate_l10n_it_ddt.py b/l10n_it_delivery_note/cli/migrate_l10n_it_ddt.py index 4162a9dec8c8..afb84b38eeb2 100644 --- a/l10n_it_delivery_note/cli/migrate_l10n_it_ddt.py +++ b/l10n_it_delivery_note/cli/migrate_l10n_it_ddt.py @@ -288,7 +288,8 @@ def vals_getter(record): "type_id": self._document_types[record.ddt_type_id].id, "date": record.date, "carrier_id": record.carrier_id.id, - "delivery_method_id": record.partner_id.property_delivery_carrier_id.id, + "delivery_method_id": record.picking_ids.mapped("carrier_id")[:1].id + or record.partner_id.property_delivery_carrier_id.id, "transport_datetime": record.date_done, "packages": record.parcels, "volume": record.volume, 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..a7890e8513bf --- /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.delivery_method_id.write({"partner_id": note_id.carrier_id.id}) diff --git a/l10n_it_delivery_note/models/res_partner.py b/l10n_it_delivery_note/models/res_partner.py index 31a36e66eaf4..928760d2b8de 100644 --- a/l10n_it_delivery_note/models/res_partner.py +++ b/l10n_it_delivery_note/models/res_partner.py @@ -19,4 +19,3 @@ class ResPartner(models.Model): default_transport_method_id = fields.Many2one( "stock.picking.transport.method", string="Method of transport" ) - is_carrier = fields.Boolean("Is 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..74e637fd2dd1 100644 --- a/l10n_it_delivery_note/models/stock_delivery_note.py +++ b/l10n_it_delivery_note/models/stock_delivery_note.py @@ -143,7 +143,8 @@ def _domain_weight_uom(self): string="Carrier", states=DONE_READONLY_STATE, tracking=True, - domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + store=True, + compute="_compute_carrier_id", ) delivery_method_id = fields.Many2one( "delivery.carrier", @@ -313,6 +314,11 @@ def name_get(self): return result + @api.depends("delivery_method_id.partner_id") + def _compute_carrier_id(self): + for note in self: + note.carrier_id = note.delivery_method_id.partner_id + @api.depends("state", "line_ids", "line_ids.invoice_status") def _compute_invoice_status(self): for note in self: diff --git a/l10n_it_delivery_note/models/stock_picking.py b/l10n_it_delivery_note/models/stock_picking.py index 28b527896e54..bbbadeeae5b5 100644 --- a/l10n_it_delivery_note/models/stock_picking.py +++ b/l10n_it_delivery_note/models/stock_picking.py @@ -346,7 +346,8 @@ def _create_delivery_note(self): "partner_shipping_id": partners[1].id, "type_id": type_id.id, "date": self.date_done, - "delivery_method_id": self.partner_id.property_delivery_carrier_id.id, + "delivery_method_id": self.mapped("carrier_id")[:1].id + or self.partner_id.property_delivery_carrier_id.id, "transport_condition_id": ( self.sale_id.default_transport_condition_id.id or partners[1].default_transport_condition_id.id diff --git a/l10n_it_delivery_note/security/ir.model.access.csv b/l10n_it_delivery_note/security/ir.model.access.csv index 725630b093f3..b1c7697ae157 100644 --- a/l10n_it_delivery_note/security/ir.model.access.csv +++ b/l10n_it_delivery_note/security/ir.model.access.csv @@ -23,3 +23,4 @@ access_stock_delivery_note_create_wizard_manager,access_stock_delivery_note_crea access_stock_delivery_note_select_wizard_manager,access_stock_delivery_note_select_wizard manager,l10n_it_delivery_note.model_stock_delivery_note_select_wizard,,1,1,1,1 access_stock_delivery_note_base_wizard_manager,access_stock_delivery_note_base_wizard manager,l10n_it_delivery_note.model_stock_delivery_note_base_wizard,,1,1,1,1 access_stock_delivery_note_invoice_wizard_manager,access_stock_delivery_note_invoice_wizard manager,l10n_it_delivery_note.model_stock_delivery_note_invoice_wizard,,1,1,1,1 +access_delivery_carrier_portal,delivery.carrier portal,delivery.model_delivery_carrier,base.group_portal,1,0,0,0 diff --git a/l10n_it_delivery_note/static/description/index.html b/l10n_it_delivery_note/static/description/index.html index 060cae4a5b50..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:86cc264b131150d0e14a593b955879a5dfe4ecfe7db4069f8ede4f8a416c9e20 +!! 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..0c5b47b72f27 100644 --- a/l10n_it_delivery_note/views/stock_picking.xml +++ b/l10n_it_delivery_note/views/stock_picking.xml @@ -204,7 +204,6 @@ + + + diff --git a/l10n_it_delivery_note/wizard/delivery_note_base.py b/l10n_it_delivery_note/wizard/delivery_note_base.py index c86064935524..3073bca0e9db 100644 --- a/l10n_it_delivery_note/wizard/delivery_note_base.py +++ b/l10n_it_delivery_note/wizard/delivery_note_base.py @@ -38,6 +38,7 @@ def _domain_type_id(self): ) error_message = fields.Html(compute="_compute_fields") + warning_message = fields.Char("Warning", readonly=True, compute="_compute_fields") def _get_validation_errors(self, pickings): validators = [ @@ -63,6 +64,16 @@ def _get_validation_errors(self, pickings): return errors + def _get_warning_message(self): + """ + This method is used to be inherited and extended + to display whatever message could be used to improve the + user experience when creating a delivery note + + :return: message to be displayed + """ + return False + @api.depends("selected_picking_ids") def _compute_fields(self): try: @@ -84,6 +95,7 @@ def _compute_fields(self): ) else: + self.warning_message = self._get_warning_message() partners = self.selected_picking_ids.get_partners() self.partner_sender_id = partners[0] self.partner_id = partners[1] diff --git a/l10n_it_delivery_note/wizard/delivery_note_create.py b/l10n_it_delivery_note/wizard/delivery_note_create.py index 27454080199b..0fd62db574ae 100644 --- a/l10n_it_delivery_note/wizard/delivery_note_create.py +++ b/l10n_it_delivery_note/wizard/delivery_note_create.py @@ -88,7 +88,10 @@ def _prepare_delivery_note_vals(self, sale_order_id): "partner_shipping_id": self.partner_shipping_id.id, "type_id": self.type_id.id, "date": self.date, - "delivery_method_id": self.partner_id.property_delivery_carrier_id.id, + "delivery_method_id": ( + self.selected_picking_ids.mapped("carrier_id")[:1].id + or self.partner_id.property_delivery_carrier_id.id + ), "transport_condition_id": ( sale_order_id and sale_order_id.default_transport_condition_id.id diff --git a/l10n_it_delivery_note/wizard/delivery_note_select.py b/l10n_it_delivery_note/wizard/delivery_note_select.py index f026d9f27746..3482af828757 100644 --- a/l10n_it_delivery_note/wizard/delivery_note_select.py +++ b/l10n_it_delivery_note/wizard/delivery_note_select.py @@ -1,7 +1,7 @@ # Copyright (c) 2019, Link IT Europe Srl # @author: Matteo Bilotta -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..676448e172ac 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 @@ +