forked from OCA/l10n-italy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_it_delivery_note: aggiornata PR OCA#4413
- Loading branch information
Showing
12 changed files
with
318 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,6 +216,10 @@ Contributors | |
- Alessandro Uffreduzzi <[email protected]> | ||
- Sebastiano Picchi <[email protected]> | ||
|
||
- `Aion Tech <https://aiontech.company/>`__: | ||
|
||
- Simone Rubino <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
@@ -43,6 +51,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" | ||
|
@@ -61,24 +70,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( | ||
|
@@ -269,6 +270,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", | ||
|
@@ -521,9 +586,18 @@ def _action_confirm(self): | |
note.date = datetime.date.today() | ||
|
||
if not note.name: | ||
note.name = sequence.with_context( | ||
ir_sequence_date=note.date | ||
).next_by_id() | ||
note.name = sequence.next_by_id() | ||
# Avoid duplicates | ||
while True: | ||
name = sequence.with_context( | ||
ir_sequence_date=note.date | ||
).next_by_id() | ||
if not self.search( | ||
[("name", "=", name), ("company_id", "=", note.company_id.id)] | ||
): | ||
break | ||
|
||
note.name = name | ||
note.sequence_id = sequence | ||
|
||
def action_confirm(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,7 @@ | |
|
||
> - Alessandro Uffreduzzi \<<[email protected]>\> | ||
> - Sebastiano Picchi \<<[email protected]>\> | ||
- [Aion Tech](https://aiontech.company/): | ||
|
||
- Simone Rubino <<[email protected]>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?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 mb-4"> | ||
<div class="col" t-if="doc.transport_reason_id" name="transport_reason"> | ||
<strong>Reason of Transport</strong> | ||
<div t-field="doc.transport_reason_id" /> | ||
</div> | ||
<div class="col" t-if="doc.transport_condition_id"> | ||
<strong>Carriage Condition</strong> | ||
<div t-field="doc.transport_condition_id" /> | ||
</div> | ||
<div | ||
class="col" | ||
t-if="doc.transport_method_id and doc.company_id.display_carrier_dn_report" | ||
> | ||
<strong>Method of Transport:</strong> | ||
<div t-field="doc.transport_method_id" /> | ||
</div> | ||
<div | ||
class="col" | ||
t-if="doc.transport_method_id and not doc.company_id.display_carrier_dn_report" | ||
> | ||
<strong>Method of Transport / Carrier</strong> | ||
<div t-field="doc.transport_method_id" /> | ||
<t t-if="doc.transport_method_id and doc.carrier_id"> / </t> | ||
<div t-field="doc.carrier_id" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<template id="parcels_data"> | ||
<div id="parcel_info" class="row"> | ||
<div class="col border" name="good_description"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Goods Description</div> | ||
<div | ||
class="px-2 pb-2" | ||
style="font-size:12px;" | ||
t-field="doc.goods_appearance_id" | ||
/> | ||
</div> | ||
<div class="col border border-start-0" name="gross_weight"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Gross Weight</div> | ||
<div | ||
class="px-2 pb-2" | ||
style="font-size:10px;" | ||
t-field="doc.gross_weight" | ||
/> | ||
</div> | ||
<div class="col border border-start-0" name="net_weight"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Net Weight</div> | ||
<div | ||
class="px-2 pb-2" | ||
style="font-size:10px;" | ||
t-field="doc.net_weight" | ||
/> | ||
</div> | ||
<div class="col border border-start-0" name="transport_date"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Transport date</div> | ||
<div | ||
class="px-2 pb-2" | ||
style="font-size:12px;" | ||
t-field="doc.transport_datetime" | ||
/> | ||
</div> | ||
<div class="col border border-start-0" name="packages"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Packages</div> | ||
<div class="px-2 pb-2" style="font-size:12px;" t-field="doc.packages" /> | ||
</div> | ||
</div> | ||
<div id="parcel_info_note" class="row"> | ||
<div class="col border border-bottom-0" name="note"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Notes</div> | ||
<div | ||
class="px-2 pb-2" | ||
style="font-size:12px;" | ||
t-if="doc.note" | ||
t-field="doc.note" | ||
/> | ||
<div class="m-3 p-3" style="font-size:12px;" t-if="not doc.note" /> | ||
</div> | ||
</div> | ||
<div id="parcel_info_signature" class="row"> | ||
<div class="col border" name="carrier_signature"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Carrier's Signature</div> | ||
<div class="m-3 p-3" style="font-size:12px;" /> | ||
</div> | ||
<div class="col border border-start-0" name="driver_signature"> | ||
<div class="px-2 pt-2" style="font-size:10px;">Driver's Signature</div> | ||
<div class="m-3 p-3" style="font-size:12px;" /> | ||
</div> | ||
<div class="col border border-start-0" name="recipint_signature"> | ||
<div | ||
class="px-2 pt-2" | ||
style="font-size:10px;" | ||
>Recipient's Signature</div> | ||
<div class="m-3 p-3" style="font-size:12px;" /> | ||
</div> | ||
</div> | ||
</template> | ||
</odoo> |
Oops, something went wrong.