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/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..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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
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 d9c5f9aa9aa8..89526eec9ea6 100644
--- a/l10n_it_delivery_note/wizard/delivery_note_create.py
+++ b/l10n_it_delivery_note/wizard/delivery_note_create.py
@@ -82,8 +82,7 @@ def confirm(self):
delivery_note = self.env["stock.delivery.note"].create(
{
- "company_id": self.selected_picking_ids.mapped("company_id")[:1].id
- or False,
+ "company_id": self.selected_picking_ids.mapped("company_id")[:1].id,
"partner_sender_id": self.partner_sender_id.id,
"partner_id": self.selected_picking_ids.mapped("sale_id.partner_id").id
if self.selected_picking_ids.mapped("sale_id.partner_id").id
@@ -91,7 +90,10 @@ def confirm(self):
"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
or self.partner_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..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 @@
+
+
+
+