diff --git a/l10n_it_delivery_note/README.rst b/l10n_it_delivery_note/README.rst
index 1c9ea3399f35..e8684f1f3fbe 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:4db8a7e4bd8b969bc8d01e11c77d7734d924dca8bb3d82f03dd2c9a4f16a3c74
+ !! source digest: sha256:568c76e12d39faef3f6e808c5c0e888b044073a056c21d675a6eb4eaf972fa8b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -75,6 +75,10 @@ To configure this module, go to:
Checking 'Display Ref. Order in Delivery Note Report' or 'Display Ref. Customer in Delivery Note Report" enables in report fields relating DN line to SO (if applicable).
+ Checking 'Display Carrier in Delivery Note Report' enables in report field 'Carrier'.
+
+ Checking 'Display Delivery Method in Delivery Note Report' enables in report field 'Delivery Method'.
+
2. *Inventory → Configuration → Warehouse Management → Delivery Note Types*
In delivery note type you can specify if the product price have to be printed in the delivery note report/slip.
diff --git a/l10n_it_delivery_note/__manifest__.py b/l10n_it_delivery_note/__manifest__.py
index ac9d76a837b2..cf07a612d1a0 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.6",
+ "version": "14.0.3.0.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",
@@ -41,10 +41,15 @@
"views/stock_picking.xml",
"views/portal_templates.xml",
"views/portal_my_delivery_notes.xml",
+ "wizard/delivery_note_confirm.xml",
"wizard/delivery_note_create.xml",
"wizard/delivery_note_invoice.xml",
"wizard/delivery_note_select.xml",
"wizard/delivery_note_template.xml",
"wizard/sale_advance_payment_inv.xml",
],
+ "demo": [
+ "demo/res_partner_demo.xml",
+ "demo/delivery_carrier_demo.xml",
+ ],
}
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/demo/delivery_carrier_demo.xml b/l10n_it_delivery_note/demo/delivery_carrier_demo.xml
new file mode 100644
index 000000000000..32d16e09a36b
--- /dev/null
+++ b/l10n_it_delivery_note/demo/delivery_carrier_demo.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/l10n_it_delivery_note/demo/res_partner_demo.xml b/l10n_it_delivery_note/demo/res_partner_demo.xml
new file mode 100644
index 000000000000..d65375002234
--- /dev/null
+++ b/l10n_it_delivery_note/demo/res_partner_demo.xml
@@ -0,0 +1,10 @@
+
+
+
+ Carrier 1
+
+
+
+ Carrier 2
+
+
diff --git a/l10n_it_delivery_note/migrations/14.0.3.0.0/post-migrate.py b/l10n_it_delivery_note/migrations/14.0.3.0.0/post-migrate.py
new file mode 100644
index 000000000000..a7890e8513bf
--- /dev/null
+++ b/l10n_it_delivery_note/migrations/14.0.3.0.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_company.py b/l10n_it_delivery_note/models/res_company.py
index 3418b3064557..729bafa3f378 100644
--- a/l10n_it_delivery_note/models/res_company.py
+++ b/l10n_it_delivery_note/models/res_company.py
@@ -12,3 +12,11 @@ class ResCompany(models.Model):
"Display Ref. Customer in Delivery Note Report",
default=False,
)
+ display_carrier_dn_report = fields.Boolean(
+ "Display Carrier in Delivery Note Report",
+ default=False,
+ )
+ display_delivery_method_dn_report = fields.Boolean(
+ "Display Delivery Method in Delivery Note Report",
+ default=False,
+ )
diff --git a/l10n_it_delivery_note/models/res_config_settings.py b/l10n_it_delivery_note/models/res_config_settings.py
index 959b0c451650..c9090e780f99 100644
--- a/l10n_it_delivery_note/models/res_config_settings.py
+++ b/l10n_it_delivery_note/models/res_config_settings.py
@@ -34,3 +34,13 @@ def _default_virtual_locations_root(self):
related="company_id.display_ref_customer_dn_report",
readonly=False,
)
+ display_carrier_dn_report = fields.Boolean(
+ string="Display Carrier in Delivery Note Report",
+ related="company_id.display_carrier_dn_report",
+ readonly=False,
+ )
+ display_delivery_method_dn_report = fields.Boolean(
+ string="Display Delivery Method in Delivery Note Report",
+ related="company_id.display_delivery_method_dn_report",
+ readonly=False,
+ )
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 d7bd1ca4871c..1659618de3b8 100644
--- a/l10n_it_delivery_note/models/stock_delivery_note.py
+++ b/l10n_it_delivery_note/models/stock_delivery_note.py
@@ -143,7 +143,6 @@ def _domain_weight_uom(self):
string="Carrier",
states=DONE_READONLY_STATE,
tracking=True,
- domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)
delivery_method_id = fields.Many2one(
"delivery.carrier",
@@ -364,6 +363,10 @@ def _compute_weights(self):
def _onchange_picking_ids(self):
self._compute_weights()
+ @api.onchange("delivery_method_id")
+ def _onchange_delivery_method_id(self):
+ self.carrier_id = self.delivery_method_id.partner_id
+
def _inverse_set_pickings(self):
for note in self:
if note.pickings_picker:
@@ -532,7 +535,7 @@ def action_draft(self):
self.write({"state": DOMAIN_DELIVERY_NOTE_STATES[0]})
self.line_ids.sync_invoice_status()
- def action_confirm(self):
+ def _action_confirm(self):
for note in self:
sequence = note.type_id.sequence_id
@@ -546,6 +549,64 @@ def action_confirm(self):
).next_by_id()
note.sequence_id = sequence
+ def action_confirm(self):
+ for note in self:
+ warning_message = False
+ carrier_ids = note.mapped("picking_ids.carrier_id")
+ carrier_partner_ids = carrier_ids.mapped("partner_id")
+ if len(carrier_partner_ids) > 1:
+ warning_message = _(
+ "This delivery note contains pickings "
+ "related to different transporters. "
+ "Are you sure you want to proceed?\n"
+ "Carrier Partners: %(carrier_partners)s",
+ carrier_partners=", ".join(carrier_partner_ids.mapped("name")),
+ )
+ elif len(carrier_ids) > 1:
+ warning_message = _(
+ "This delivery note contains pickings related to different "
+ "delivery methods from the same transporter. "
+ "Are you sure you want to proceed?\n"
+ "Delivery Methods: %(carriers)s",
+ carriers=", ".join(carrier_ids.mapped("name")),
+ )
+ elif (
+ carrier_partner_ids
+ and note.carrier_id
+ and note.carrier_id != carrier_partner_ids
+ ):
+ warning_message = _(
+ "The carrier set in Delivery Note is different "
+ "from the carrier set in picking(s). "
+ "Are you sure you want to proceed?"
+ )
+ elif (
+ carrier_ids
+ and note.delivery_method_id
+ and carrier_ids != note.delivery_method_id
+ ):
+ warning_message = _(
+ "The shipping method set in Delivery Note is different "
+ "from the shipping method set in picking(s). "
+ "Are you sure you want to proceed?"
+ )
+ if warning_message:
+ return {
+ "type": "ir.actions.act_window",
+ "name": _("Warning"),
+ "res_model": "stock.delivery.note.confirm.wizard",
+ "view_type": "form",
+ "target": "new",
+ "view_mode": "form",
+ "context": {
+ "default_delivery_note_id": note.id,
+ "default_warning_message": warning_message,
+ **self._context,
+ },
+ }
+ else:
+ note._action_confirm()
+
def _check_delivery_notes_before_invoicing(self):
for delivery_note_id in self:
if not delivery_note_id.sale_ids:
diff --git a/l10n_it_delivery_note/models/stock_picking.py b/l10n_it_delivery_note/models/stock_picking.py
index 815dfe70e018..ed6c49ed1168 100644
--- a/l10n_it_delivery_note/models/stock_picking.py
+++ b/l10n_it_delivery_note/models/stock_picking.py
@@ -90,6 +90,8 @@ class StockPicking(models.Model):
string="DN Operation Type", related="picking_type_id.code"
)
+ carrier_partner_id = fields.Many2one("res.partner", related="carrier_id.partner_id")
+
use_delivery_note = fields.Boolean(compute="_compute_boolean_flags")
use_advanced_behaviour = fields.Boolean(compute="_compute_boolean_flags")
delivery_note_exists = fields.Boolean(compute="_compute_boolean_flags")
@@ -143,6 +145,10 @@ def _compute_boolean_flags(self):
)
picking.can_be_invoiced = bool(picking.delivery_note_id.sale_ids)
+ @api.onchange("delivery_method_id")
+ def _onchange_delivery_method_id(self):
+ self.delivery_note_carrier_id = self.delivery_method_id.partner_id
+
@api.onchange("delivery_note_type_id")
def _onchange_delivery_note_type(self):
if self.delivery_note_type_id:
@@ -338,6 +344,7 @@ def _create_delivery_note(self):
],
limit=1,
)
+ delivery_method_id = self.mapped("carrier_id")[:1]
return self.env["stock.delivery.note"].create(
{
"company_id": self.company_id.id,
@@ -348,7 +355,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,
+ "carrier_id": delivery_method_id.partner_id.id,
+ "delivery_method_id": delivery_method_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/readme/CONFIGURE.rst b/l10n_it_delivery_note/readme/CONFIGURE.rst
index 3ce312185b99..10751f5cf3ea 100644
--- a/l10n_it_delivery_note/readme/CONFIGURE.rst
+++ b/l10n_it_delivery_note/readme/CONFIGURE.rst
@@ -6,6 +6,10 @@ To configure this module, go to:
Checking 'Display Ref. Order in Delivery Note Report' or 'Display Ref. Customer in Delivery Note Report" enables in report fields relating DN line to SO (if applicable).
+ Checking 'Display Carrier in Delivery Note Report' enables in report field 'Carrier'.
+
+ Checking 'Display Delivery Method in Delivery Note Report' enables in report field 'Delivery Method'.
+
2. *Inventory → Configuration → Warehouse Management → Delivery Note Types*
In delivery note type you can specify if the product price have to be printed in the delivery note report/slip.
diff --git a/l10n_it_delivery_note/report/report_delivery_note.xml b/l10n_it_delivery_note/report/report_delivery_note.xml
index 87b28517a625..fe7d7b385597 100644
--- a/l10n_it_delivery_note/report/report_delivery_note.xml
+++ b/l10n_it_delivery_note/report/report_delivery_note.xml
@@ -89,6 +89,21 @@
+
+ Carrier:
+
+
+
+ Delivery Method:
+
+
+
Delivery Note:
Under the terms of Italian Presidential Decree 472-96 of 14.08.1996
@@ -115,7 +130,17 @@
Carriage Condition:
-
+
+
Method of Transport:
+
+
+
Method of Transport / Carrier:
/
@@ -277,7 +302,7 @@
style="font-size:10px;"
>Gross Weight
@@ -288,7 +313,7 @@
style="font-size:10px;"
>Net Weight
@@ -307,7 +332,7 @@
Packages
diff --git a/l10n_it_delivery_note/security/ir.model.access.csv b/l10n_it_delivery_note/security/ir.model.access.csv
index 725630b093f3..364845cefe86 100644
--- a/l10n_it_delivery_note/security/ir.model.access.csv
+++ b/l10n_it_delivery_note/security/ir.model.access.csv
@@ -19,7 +19,9 @@ access_stock_delivery_note_line_portal,stock.delivery.note.line.portal,l10n_it_d
access_stock_delivery_note_type_user,access_stock_delivery_note_type user,l10n_it_delivery_note_base.model_stock_delivery_note_type,stock.group_stock_user,1,0,0,0
access_stock_delivery_note_type_manager,access_stock_delivery_note_type manager,l10n_it_delivery_note_base.model_stock_delivery_note_type,stock.group_stock_manager,1,1,1,1
access_stock_delivery_note_type_user_account,access_stock_delivery_note_type user_account,l10n_it_delivery_note_base.model_stock_delivery_note_type,account.group_account_invoice,1,0,0,0
+access_stock_delivery_note_confirm_wizard_manager,access_stock_delivery_note_confirm_wizard manager,l10n_it_delivery_note.model_stock_delivery_note_confirm_wizard,,1,1,1,1
access_stock_delivery_note_create_wizard_manager,access_stock_delivery_note_create_wizard manager,l10n_it_delivery_note.model_stock_delivery_note_create_wizard,,1,1,1,1
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 376fa8ea683c..8136a6cc6c06 100644
--- a/l10n_it_delivery_note/static/description/index.html
+++ b/l10n_it_delivery_note/static/description/index.html
@@ -366,7 +366,7 @@ ITA - Documento di trasporto
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:4db8a7e4bd8b969bc8d01e11c77d7734d924dca8bb3d82f03dd2c9a4f16a3c74
+!! source digest: sha256:568c76e12d39faef3f6e808c5c0e888b044073a056c21d675a6eb4eaf972fa8b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
English
@@ -416,6 +416,8 @@
Inventory → Configuration → Settings - Delivery Notes
Checking ‘Use Advanced DN Features’ allows you to manage more picking on one delivery note.
Checking ‘Display Ref. Order in Delivery Note Report’ or ‘Display Ref. Customer in Delivery Note Report” enables in report fields relating DN line to SO (if applicable).
+Checking ‘Display Carrier in Delivery Note Report’ enables in report field ‘Carrier’.
+Checking ‘Display Delivery Method in Delivery Note Report’ enables in report field ‘Delivery Method’.
Inventory → Configuration → Warehouse Management → Delivery Note Types
In delivery note type you can specify if the product price have to be printed in the delivery note report/slip.
diff --git a/l10n_it_delivery_note/tests/delivery_note_common.py b/l10n_it_delivery_note/tests/delivery_note_common.py
index 26cad7e95003..7217d1660a01 100644
--- a/l10n_it_delivery_note/tests/delivery_note_common.py
+++ b/l10n_it_delivery_note/tests/delivery_note_common.py
@@ -58,6 +58,36 @@ def create_delivery_note(self, **kwargs):
return self.env["stock.delivery.note"].create(vals)
+ def create_picking(self, **kwargs):
+ picking_data = {
+ "partner_id": self.recipient.id,
+ "picking_type_id": self.env.ref("stock.picking_type_out").id,
+ "location_id": self.env.ref("stock.stock_location_stock").id,
+ "location_dest_id": self.env.ref("stock.stock_location_customers").id,
+ "move_lines": [
+ (
+ 0,
+ 0,
+ {
+ "name": self.env.ref("product.product_product_8").name,
+ "product_id": self.env.ref("product.product_product_8").id,
+ "product_uom_qty": 1,
+ "product_uom": self.env.ref(
+ "product.product_product_8"
+ ).uom_id.id,
+ "location_id": self.env.ref("stock.stock_location_stock").id,
+ "location_dest_id": self.env.ref(
+ "stock.stock_location_customers"
+ ).id,
+ },
+ )
+ ],
+ }
+
+ picking_data.update(kwargs)
+
+ return self.env["stock.picking"].create(picking_data)
+
def setUp(self):
super().setUp()
diff --git a/l10n_it_delivery_note/tests/test_stock_delivery_note.py b/l10n_it_delivery_note/tests/test_stock_delivery_note.py
index fc8b7ba24b1e..e10b2ccd479e 100644
--- a/l10n_it_delivery_note/tests/test_stock_delivery_note.py
+++ b/l10n_it_delivery_note/tests/test_stock_delivery_note.py
@@ -73,25 +73,7 @@ def test_delivery_without_so(self):
# change user in order to activate DN advanced settings
self.env.user = user
- picking = self.env["stock.picking"].create(
- {
- "partner_id": self.recipient.id,
- "picking_type_id": self.env.ref("stock.picking_type_out").id,
- "location_id": self.env.ref("stock.stock_location_stock").id,
- "location_dest_id": self.env.ref("stock.stock_location_customers").id,
- }
- )
- self.env["stock.move"].create(
- {
- "name": self.env.ref("product.product_product_8").name,
- "product_id": self.env.ref("product.product_product_8").id,
- "product_uom_qty": 1,
- "product_uom": self.env.ref("product.product_product_8").uom_id.id,
- "picking_id": picking.id,
- "location_id": self.env.ref("stock.stock_location_stock").id,
- "location_dest_id": self.env.ref("stock.stock_location_customers").id,
- }
- )
+ picking = self.create_picking()
self.assertEqual(len(picking.move_lines), 1)
@@ -119,3 +101,86 @@ def test_delivery_without_so(self):
self.assertIn("type_id", exc_message)
self.assertIn("picking_ids", exc_message)
self.assertIn("belongs to another company", exc_message)
+
+ def test_delivery_action_confirm(self):
+ user = new_test_user(
+ self.env,
+ login="test",
+ groups="stock.group_stock_manager,"
+ "l10n_it_delivery_note.use_advanced_delivery_notes",
+ )
+ # change user in order to activate DN advanced settings
+ self.env.user = user
+
+ picking = self.create_picking(
+ carrier_id=self.env.ref("delivery.delivery_carrier").id
+ )
+ picking.move_lines.quantity_done = 1
+ picking.button_validate()
+
+ dn_form = Form(
+ self.env["stock.delivery.note.create.wizard"].with_context(
+ {"active_id": picking.id, "active_ids": picking.ids}
+ )
+ )
+ dn = dn_form.save()
+ dn.confirm()
+
+ delivery_note_id = picking.delivery_note_id
+
+ new_picking = self.create_picking(
+ carrier_id=self.env.ref("delivery.normal_delivery_carrier").id
+ )
+ new_picking.move_lines.quantity_done = 1
+ new_picking.button_validate()
+
+ delivery_note_id.write({"picking_ids": [(4, new_picking.id)]})
+
+ warning_context = delivery_note_id.action_confirm().get("context")
+ self.assertTrue(warning_context)
+ self.assertIn(
+ "contains pickings related to different transporters",
+ warning_context.get("default_warning_message"),
+ )
+
+ picking.carrier_id = self.env.ref("delivery.free_delivery_carrier").id
+ new_picking.carrier_id = self.env.ref("delivery.free_delivery_carrier").id
+ delivery_note_id.carrier_id = self.env.ref(
+ "l10n_it_delivery_note.partner_carrier_2"
+ ).id
+
+ warning_context = delivery_note_id.action_confirm().get("context")
+ self.assertTrue(warning_context)
+ self.assertIn(
+ "The carrier set in Delivery Note is "
+ "different from the carrier set in picking(s)",
+ warning_context.get("default_warning_message"),
+ )
+
+ delivery_note_id.delivery_method_id = self.env.ref(
+ "delivery.free_delivery_carrier"
+ ).id
+ picking.carrier_id = self.env.ref("delivery.delivery_carrier").id
+ new_picking.carrier_id = self.env.ref("delivery.free_delivery_carrier").id
+ warning_context = delivery_note_id.action_confirm().get("context")
+ self.assertTrue(warning_context)
+ self.assertIn(
+ "contains pickings related to different "
+ "delivery methods from the same transporter",
+ warning_context.get("default_warning_message"),
+ )
+
+ new_picking.carrier_id = self.env.ref("delivery.delivery_carrier").id
+ delivery_note_id.delivery_method_id = self.env.ref(
+ "delivery.free_delivery_carrier"
+ ).id
+ delivery_note_id.carrier_id = self.env.ref(
+ "l10n_it_delivery_note.partner_carrier_1"
+ ).id
+ warning_context = delivery_note_id.action_confirm().get("context")
+ self.assertTrue(warning_context)
+ self.assertIn(
+ "The shipping method set in Delivery Note is "
+ "different from the shipping method set in picking(s)",
+ warning_context.get("default_warning_message"),
+ )
diff --git a/l10n_it_delivery_note/views/res_config_settings.xml b/l10n_it_delivery_note/views/res_config_settings.xml
index 96ae9e755ab1..09f89de88b8b 100644
--- a/l10n_it_delivery_note/views/res_config_settings.xml
+++ b/l10n_it_delivery_note/views/res_config_settings.xml
@@ -74,6 +74,38 @@
+
+
+
+
+
+
+
+
+ Prints Carrier's name on DN report (if there is any)
+
+
+
+
+
+
+
+
+
+
+
+
+ Prints Delivery Method on DN report (if there is any)
+
+
+
+
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 db34a4c5e4a0..aa8f626e212c 100644
--- a/l10n_it_delivery_note/views/stock_delivery_note.xml
+++ b/l10n_it_delivery_note/views/stock_delivery_note.xml
@@ -150,10 +150,7 @@
-
+
@@ -422,6 +419,8 @@
/>
+
+
diff --git a/l10n_it_delivery_note/views/stock_picking.xml b/l10n_it_delivery_note/views/stock_picking.xml
index b17fda21bb9d..a54f578ff955 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/__init__.py b/l10n_it_delivery_note/wizard/__init__.py
index 328cc9a9d46b..b42b1dd632a6 100644
--- a/l10n_it_delivery_note/wizard/__init__.py
+++ b/l10n_it_delivery_note/wizard/__init__.py
@@ -1,4 +1,5 @@
from . import delivery_note_base
+from . import delivery_note_confirm
from . import delivery_note_create
from . import delivery_note_invoice
from . import delivery_note_select
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_confirm.py b/l10n_it_delivery_note/wizard/delivery_note_confirm.py
new file mode 100644
index 000000000000..5370b326036d
--- /dev/null
+++ b/l10n_it_delivery_note/wizard/delivery_note_confirm.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2019, Link IT Europe Srl
+# @author: Matteo Bilotta
+
+
+from odoo import fields, models
+
+
+class StockDeliveryNoteCreateWizard(models.TransientModel):
+ _name = "stock.delivery.note.confirm.wizard"
+ _description = "Delivery Note Confirm"
+
+ delivery_note_id = fields.Many2one("stock.delivery.note", readonly=True)
+ warning_message = fields.Text("Warning Message", readonly=True)
+
+ def confirm(self):
+ self.ensure_one()
+ self.delivery_note_id._action_confirm()
diff --git a/l10n_it_delivery_note/wizard/delivery_note_confirm.xml b/l10n_it_delivery_note/wizard/delivery_note_confirm.xml
new file mode 100644
index 000000000000..647c867f05c1
--- /dev/null
+++ b/l10n_it_delivery_note/wizard/delivery_note_confirm.xml
@@ -0,0 +1,21 @@
+
+
+
+ stock.delivery.note.confirm.form
+ stock.delivery.note.confirm.wizard
+
+
+
+
+
diff --git a/l10n_it_delivery_note/wizard/delivery_note_create.py b/l10n_it_delivery_note/wizard/delivery_note_create.py
index 27454080199b..ea090098e54f 100644
--- a/l10n_it_delivery_note/wizard/delivery_note_create.py
+++ b/l10n_it_delivery_note/wizard/delivery_note_create.py
@@ -75,6 +75,7 @@ def _onchange_partner(self):
)
def _prepare_delivery_note_vals(self, sale_order_id):
+ delivery_method_id = self.selected_picking_ids.mapped("carrier_id")[:1]
return {
"company_id": (
self.selected_picking_ids.mapped("company_id")[:1].id or False
@@ -88,7 +89,8 @@ 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,
+ "carrier_id": delivery_method_id.partner_id.id,
+ "delivery_method_id": delivery_method_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..072503bae6af 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,19 @@ 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")
+ if len(carrier_ids.mapped("partner_id")) > 1:
+ res = _(
+ "The selected pickings have different delivery methods: %(carriers)s",
+ carriers=", ".join(
+ '"%s: %s"' % (i.name, i.partner_id.name) for i in carrier_ids
+ ),
+ )
+ 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 @@
+
+
+
+