Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] l10n_it_accompanying_invoice -> l10n_it_shipping_invoice: Migration to 16.0 #3742

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions l10n_it_delivery_note/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ Contributors
- Alessandro Uffreduzzi <[email protected]>
- Sebastiano Picchi <[email protected]>

- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <[email protected]>

Maintainers
-----------

Expand Down
1 change: 1 addition & 0 deletions l10n_it_delivery_note/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"security/ir_rule.xml",
"security/res_groups.xml",
"security/res_users.xml",
"report/delivery_data.xml",
"report/report_delivery_note.xml",
"views/account_move.xml",
"views/res_config_settings.xml",
Expand Down
1 change: 1 addition & 0 deletions l10n_it_delivery_note/mixins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import delivery_mixin
from . import picking_checker
from . import shipping_updater
91 changes: 91 additions & 0 deletions l10n_it_delivery_note/mixins/delivery_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from odoo import fields, models


def _default_volume_uom(model):
return model.env.ref("uom.product_uom_litre", raise_if_not_found=False)


def _domain_volume_uom(model):
uom_category_id = model.env.ref(
"uom.product_uom_categ_vol", raise_if_not_found=False
)

return [("category_id", "=", uom_category_id.id)]


def _default_weight_uom(model):
return model.env.ref("uom.product_uom_kgm", raise_if_not_found=False)


def _domain_weight_uom(model):
uom_category_id = model.env.ref(
"uom.product_uom_categ_kgm", raise_if_not_found=False
)

return [("category_id", "=", uom_category_id.id)]


class DeliveryData(models.AbstractModel):
_name = "l10n_it_delivery_note.delivery_mixin"
_description = "Common data for records to be delivered"

delivery_transport_reason_id = fields.Many2one(
comodel_name="stock.picking.transport.reason",
string="Reason of transport of Delivery",
)
delivery_transport_condition_id = fields.Many2one(
comodel_name="stock.picking.transport.condition",
string="Condition of transport of Delivery",
)
delivery_transport_method_id = fields.Many2one(
comodel_name="stock.picking.transport.method",
string="Method of transport of Delivery",
)
delivery_carrier_id = fields.Many2one(
comodel_name="res.partner",
string="Carrier of Delivery",
)
delivery_goods_appearance_id = fields.Many2one(
comodel_name="stock.picking.goods.appearance",
string="Appearance of goods of Delivery",
)
delivery_volume_uom_id = fields.Many2one(
"uom.uom",
string="Volume of Delivery UoM",
default=_default_volume_uom,
domain=_domain_volume_uom,
)
delivery_volume = fields.Float(
string="Volume of Delivery",
)
delivery_gross_weight_uom_id = fields.Many2one(
"uom.uom",
string="Gross Weight of Delivery UoM",
default=_default_weight_uom,
domain=_domain_weight_uom,
)
delivery_gross_weight = fields.Float(
string="Gross Weight of Delivery",
)
delivery_net_weight_uom_id = fields.Many2one(
"uom.uom",
string="Net Weight of Delivery UoM",
default=_default_weight_uom,
domain=_domain_weight_uom,
)
delivery_net_weight = fields.Float(
string="Net Weight of Delivery",
)
delivery_transport_datetime = fields.Datetime(
string="Transport Date of Delivery",
)
delivery_packages = fields.Integer(
string="Packages of Delivery",
)
delivery_note = fields.Html(
string="Internal note of delivery",
)
89 changes: 77 additions & 12 deletions l10n_it_delivery_note/models/stock_delivery_note.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Copyright (c) 2019, Link IT Europe Srl
# @author: Matteo Bilotta <[email protected]>
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import datetime

from odoo import _, api, fields, models
from odoo.exceptions import UserError

from ..mixins.delivery_mixin import (
_default_volume_uom,
_default_weight_uom,
_domain_volume_uom,
_domain_weight_uom,
)
from ..mixins.picking_checker import (
DOMAIN_PICKING_TYPES,
DONE_PICKING_STATE,
Expand Down Expand Up @@ -46,6 +54,7 @@ class StockDeliveryNote(models.Model):
"mail.activity.mixin",
"stock.picking.checker.mixin",
"shipping.information.updater.mixin",
"l10n_it_delivery_note.delivery_mixin",
]
_description = "Delivery Note"
_order = "date DESC, id DESC"
Expand All @@ -64,24 +73,16 @@ def _default_type(self):
)

def _default_volume_uom(self):
return self.env.ref("uom.product_uom_litre", raise_if_not_found=False)
return _default_volume_uom(self)

def _domain_volume_uom(self):
uom_category_id = self.env.ref(
"uom.product_uom_categ_vol", raise_if_not_found=False
)

return [("category_id", "=", uom_category_id.id)]
return _domain_volume_uom(self)

def _default_weight_uom(self):
return self.env.ref("uom.product_uom_kgm", raise_if_not_found=False)
return _default_weight_uom(self)

def _domain_weight_uom(self):
uom_category_id = self.env.ref(
"uom.product_uom_categ_kgm", raise_if_not_found=False
)

return [("category_id", "=", uom_category_id.id)]
return _domain_weight_uom(self)

active = fields.Boolean(default=True)
name = fields.Char(
Expand Down Expand Up @@ -290,6 +291,70 @@ def _domain_weight_uom(self):
show_product_information = fields.Boolean(compute="_compute_boolean_flags")
company_id = fields.Many2one("res.company", required=True, default=_default_company)

# Sync with delivery mixin fields
delivery_transport_reason_id = fields.Many2one(
related="transport_reason_id",
readonly=True,
)
delivery_transport_condition_id = fields.Many2one(
related="transport_condition_id",
readonly=True,
)
delivery_transport_method_id = fields.Many2one(
related="transport_method_id",
readonly=True,
)
delivery_carrier_id = fields.Many2one(
related="carrier_id",
readonly=True,
)
delivery_goods_appearance_id = fields.Many2one(
related="goods_appearance_id",
readonly=True,
)
delivery_volume_uom_id = fields.Many2one(
related="volume_uom_id",
readonly=True,
default=None,
domain=None,
)
delivery_volume = fields.Float(
related="volume",
readonly=True,
)
delivery_gross_weight_uom_id = fields.Many2one(
related="gross_weight_uom_id",
readonly=True,
default=None,
domain=None,
)
delivery_gross_weight = fields.Float(
related="gross_weight",
readonly=True,
)
delivery_net_weight_uom_id = fields.Many2one(
related="net_weight_uom_id",
readonly=True,
default=None,
domain=None,
)
delivery_net_weight = fields.Float(
related="net_weight",
readonly=True,
)
delivery_transport_datetime = fields.Datetime(
related="transport_datetime",
readonly=True,
)
delivery_packages = fields.Integer(
related="packages",
readonly=True,
)
delivery_note = fields.Html(
related="note",
readonly=True,
)

_sql_constraints = [
(
"name_uniq",
Expand Down
4 changes: 4 additions & 0 deletions l10n_it_delivery_note/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@

> - Alessandro Uffreduzzi \<<[email protected]>\>
> - Sebastiano Picchi \<<[email protected]>\>

- [Aion Tech](https://aiontech.company/):

- Simone Rubino <<[email protected]>>
136 changes: 136 additions & 0 deletions l10n_it_delivery_note/report/delivery_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2023 Simone Rubino - Aion Tech
~ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
<template id="delivery_data">
<div id="delivery_data_information" class="row mt32 mb32">
<div t-if="doc.delivery_transport_reason_id" class="col-3 bm-2">
<strong>Reason of Transport:</strong>
<p t-field="doc.delivery_transport_reason_id" class="m-0" />
</div>
<div t-if="doc.delivery_transport_condition_id" class="col-3 bm-2">
<strong>Carriage Condition:</strong>
<p t-field="doc.delivery_transport_condition_id" class="m-0" />
</div>
<div
t-if="doc.delivery_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.delivery_transport_method_id" class="m-0" />
</div>
<div
t-if="doc.delivery_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.delivery_transport_method_id" class="m-0" />
<t
t-if="doc.delivery_transport_method_id and doc.delivery_carrier_id"
> / </t>
<span t-field="doc.delivery_carrier_id" class="m-0" />
</div>
</div>
</template>

<template id="parcels_data">
<table
id="parcel_info"
class="table table-condensed table-bordered delivery_data"
style="page-break-inside: avoid"
>
<tr>
<td>
<div
name="good_description"
style="font-size:10px;"
>Goods Description</div>
<div
style="font-size:12px;"
t-field="doc.delivery_goods_appearance_id"
/>
</td>
<td>
<div name="gross_weight" style="font-size:10px;">Gross Weight</div>
<div
class="text-left"
style="font-size:12px;"
t-field="doc.delivery_gross_weight"
/>
</td>
<td>
<div name="net_weight" style="font-size:10px;">Net Weight</div>
<div
class="text-left"
style="font-size:12px;"
t-field="doc.delivery_net_weight"
/>
</td>
<td>
<div
name="transport_date"
style="font-size:10px;"
>Transport date</div>
<div
class="m-0"
style="font-size:12px;"
t-field="doc.delivery_transport_datetime"
/>
</td>
<td>
<div name="packages" style="font-size:10px;">Packages</div>
<div
class="text-left"
style="font-size:12px;"
t-field="doc.delivery_packages"
/>
</td>
</tr>
<tr>
<td colspan="5" class="notes">
<div name="notes" style="font-size:10px;">Notes</div>
<br />
<div
class="signature"
style="font-size:12px;"
t-field="doc.delivery_note"
/>
</td>
</tr>
<tr>
<td colspan="5">
<table class="table table-condensed delivery_data">
<tr>
<td>
<div
name="carrier_signature"
style="font-size:10px;"
>Carrier's Signature</div>
<br />
<div class="signature" style="font-size:12px;" />
</td>
<td>
<div
name="driver_signature"
style="font-size:10px;"
>Driver's Signature</div>
<br />
<div class="signature" style="font-size:12px;" />
</td>
<td>
<div
name="recipint_signature"
style="font-size:10px;"
>Recipient's Signature</div>
<br />
<div class="signature" style="font-size:12px;" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</template>
</odoo>
Loading
Loading