Skip to content

Commit

Permalink
Merge PR #3838 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by aleuffre
  • Loading branch information
OCA-git-bot committed Feb 1, 2024
2 parents a2edccb + 4a71c0d commit abf6442
Show file tree
Hide file tree
Showing 28 changed files with 405 additions and 40 deletions.
6 changes: 5 additions & 1 deletion l10n_it_delivery_note/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions l10n_it_delivery_note/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
],
}
3 changes: 2 additions & 1 deletion l10n_it_delivery_note/cli/migrate_l10n_it_ddt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions l10n_it_delivery_note/demo/delivery_carrier_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="delivery.delivery_carrier" model="delivery.carrier">
<field name="partner_id" ref="l10n_it_delivery_note.partner_carrier_1" />
</record>

<record id="delivery.free_delivery_carrier" model="delivery.carrier">
<field name="partner_id" ref="l10n_it_delivery_note.partner_carrier_1" />
</record>

<record id="delivery.normal_delivery_carrier" model="delivery.carrier">
<field name="partner_id" ref="l10n_it_delivery_note.partner_carrier_2" />
</record>
</odoo>
10 changes: 10 additions & 0 deletions l10n_it_delivery_note/demo/res_partner_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="partner_carrier_1" model="res.partner">
<field name="name">Carrier 1</field>
</record>

<record id="partner_carrier_2" model="res.partner">
<field name="name">Carrier 2</field>
</record>
</odoo>
11 changes: 11 additions & 0 deletions l10n_it_delivery_note/migrations/14.0.3.0.0/post-migrate.py
Original file line number Diff line number Diff line change
@@ -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})
8 changes: 8 additions & 0 deletions l10n_it_delivery_note/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
10 changes: 10 additions & 0 deletions l10n_it_delivery_note/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
1 change: 0 additions & 1 deletion l10n_it_delivery_note/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
65 changes: 63 additions & 2 deletions l10n_it_delivery_note/models/stock_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion l10n_it_delivery_note/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions l10n_it_delivery_note/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 29 additions & 4 deletions l10n_it_delivery_note/report/report_delivery_note.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@
</p>
</div>
</div>
<div
id="carrier"
t-if="doc.carrier_id and doc.company_id.display_carrier_dn_report"
>
<strong>Carrier:</strong>
<t t-esc="doc.carrier_id.name" />
</div>
<div
id="delivery_method"
t-if="doc.delivery_method_id and doc.company_id.display_delivery_method_dn_report"
>
<strong>Delivery Method:</strong>
<t t-esc="doc.delivery_method_id.name" />
</div>

<div id="dn_terms">
<strong> Delivery Note: </strong>
Under the terms of Italian Presidential Decree 472-96 of 14.08.1996
Expand All @@ -115,7 +130,17 @@
<strong>Carriage Condition:</strong>
<p t-field="doc.transport_condition_id" class="m-0" />
</div>
<div t-if="doc.transport_method_id" class="col-3 bm-2">
<div
t-if="doc.transport_method_id and doc.company_id.display_carrier_dn_report"
class="col-3 bm-2"
>
<strong>Method of Transport:</strong>
<p t-field="doc.transport_method_id" class="m-0" />
</div>
<div
t-if="doc.transport_method_id and not doc.company_id.display_carrier_dn_report"
class="col-3 bm-2"
>
<strong>Method of Transport / Carrier:</strong>
<span t-field="doc.transport_method_id" class="m-0" />
<t t-if="doc.transport_method_id and doc.carrier_id"> / </t>
Expand Down Expand Up @@ -277,7 +302,7 @@
style="font-size:10px;"
>Gross Weight</div>
<div
class="text-right"
class="text-left"
style="font-size:12px;"
t-field="doc.gross_weight"
/>
Expand All @@ -288,7 +313,7 @@
style="font-size:10px;"
>Net Weight</div>
<div
class="text-right"
class="text-left"
style="font-size:12px;"
t-field="doc.net_weight"
/>
Expand All @@ -307,7 +332,7 @@
<td>
<div name="packages" style="font-size:10px;">Packages</div>
<div
class="text-right"
class="text-left"
style="font-size:12px;"
t-field="doc.packages"
/>
Expand Down
2 changes: 2 additions & 0 deletions l10n_it_delivery_note/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion l10n_it_delivery_note/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h1 class="title">ITA - Documento di trasporto</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4db8a7e4bd8b969bc8d01e11c77d7734d924dca8bb3d82f03dd2c9a4f16a3c74
!! source digest: sha256:568c76e12d39faef3f6e808c5c0e888b044073a056c21d675a6eb4eaf972fa8b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-italy/tree/14.0/l10n_it_delivery_note"><img alt="OCA/l10n-italy" src="https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-l10n_it_delivery_note"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><strong>English</strong></p>
Expand Down Expand Up @@ -416,6 +416,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<li><p class="first"><em>Inventory → Configuration → Settings - Delivery Notes</em></p>
<p>Checking ‘Use Advanced DN Features’ allows you to manage more picking on one delivery note.</p>
<p>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).</p>
<p>Checking ‘Display Carrier in Delivery Note Report’ enables in report field ‘Carrier’.</p>
<p>Checking ‘Display Delivery Method in Delivery Note Report’ enables in report field ‘Delivery Method’.</p>
</li>
<li><p class="first"><em>Inventory → Configuration → Warehouse Management → Delivery Note Types</em></p>
<p>In delivery note type you can specify if the product price have to be printed in the delivery note report/slip.</p>
Expand Down
Loading

0 comments on commit abf6442

Please sign in to comment.