-
-
Notifications
You must be signed in to change notification settings - Fork 307
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_intrastat_delivery_note: new module that adds missing
fields to the delivery note report
- Loading branch information
1 parent
a149fa6
commit 87413c5
Showing
19 changed files
with
802 additions
and
60 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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
============================= | ||
ITA - Intrastat Delivery Note | ||
============================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:3e3510f1efa020fc96deafc7148bb0330fc1d930017577bf2a09390cd5c5b06c | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github | ||
:target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_intrastat_delivery_note | ||
:alt: OCA/l10n-italy | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_intrastat_delivery_note | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
**Italiano** | ||
|
||
Questo modulo aggiunge campi mancanti alla stampa del resoconto DDT | ||
|
||
**English** | ||
|
||
This module adds missing fields to the DDT report print | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_intrastat_delivery_note%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* PyTech SRL | ||
|
||
Contributors | ||
------------ | ||
|
||
- `PyTech SRL <https://pytech.it>`__: | ||
|
||
- Sebastiano Picchi <[email protected]> | ||
- Alessandro Uffreduzzi <[email protected]> | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
.. |maintainer-aleuffre| image:: https://github.com/aleuffre.png?size=40px | ||
:target: https://github.com/aleuffre | ||
:alt: aleuffre | ||
.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px | ||
:target: https://github.com/renda-dev | ||
:alt: renda-dev | ||
.. |maintainer-PicchiSeba| image:: https://github.com/PicchiSeba.png?size=40px | ||
:target: https://github.com/PicchiSeba | ||
:alt: PicchiSeba | ||
|
||
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-aleuffre| |maintainer-renda-dev| |maintainer-PicchiSeba| | ||
|
||
This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_intrastat_delivery_note>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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,2 @@ | ||
from . import models | ||
from .hooks import post_init_hook, uninstall_hook |
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,22 @@ | ||
{ | ||
"name": "ITA - Intrastat Delivery Note", | ||
"version": "16.0.1.0.0", | ||
"category": "Hidden", | ||
"summary": "Aggiunta campi mancanti a stampa DDT", | ||
"author": "PyTech SRL, Odoo Community Association (OCA)", | ||
"maintainers": ["aleuffre", "renda-dev", "PicchiSeba"], | ||
"website": "https://github.com/OCA/l10n-italy", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": [ | ||
"l10n_it_delivery_note", | ||
"l10n_it_intrastat", | ||
], | ||
"data": [ | ||
"report/report_delivery_document.xml", | ||
"report/report_delivery_note.xml", | ||
], | ||
"demo": [], | ||
"post_init_hook": "post_init_hook", | ||
"uninstall_hook": "uninstall_hook", | ||
} |
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,43 @@ | ||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api, tools | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
# Convert 'HS Code' to an 'Intrastat code' | ||
with api.Environment.manage(): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
product_ids = env["product.product"].search([("hs_code", "!=", False)]) | ||
for code, products in tools.groupby(product_ids, lambda x: x.hs_code): | ||
report_intrastat_code_id = env["report.intrastat.code"].search( | ||
[("name", "=", code)] | ||
) | ||
if not report_intrastat_code_id: | ||
_logger.warning("No Intrastat Code found for HS Code: '%s'", code) | ||
continue | ||
|
||
env["product.product"].browse([i.id for i in products]).write( | ||
{ | ||
"intrastat_code_id": report_intrastat_code_id.id, | ||
"intrastat_type": report_intrastat_code_id.type, | ||
} | ||
) | ||
|
||
|
||
def uninstall_hook(cr, registry): | ||
# Move every 'Intrastat code' to 'HS Code' | ||
with api.Environment.manage(): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
if hasattr(env["product.product"], "hs_code"): | ||
product_ids = env["product.product"].search( | ||
[("intrastat_code_id", "!=", False), ("hs_code", "=", False)] | ||
) | ||
|
||
for code, products in tools.groupby( | ||
product_ids, lambda x: x.intrastat_code_id | ||
): | ||
env["product.product"].browse([i.id for i in products]).write( | ||
{"hs_code": code.name} | ||
) |
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 @@ | ||
from . import stock_move |
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,16 @@ | ||
from odoo import models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
def _get_aggregated_product_quantities(self, **kwargs): | ||
aggregated_move_lines = super()._get_aggregated_product_quantities(**kwargs) | ||
for aggregated_move_line in aggregated_move_lines: | ||
intrastat_code = aggregated_move_lines[aggregated_move_line][ | ||
"product" | ||
].product_tmpl_id.intrastat_code_id.name | ||
aggregated_move_lines[aggregated_move_line][ | ||
"intrastat_code_id" | ||
] = intrastat_code | ||
return aggregated_move_lines |
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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
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,3 @@ | ||
- [PyTech SRL](https://pytech.it): | ||
- Sebastiano Picchi \<<[email protected]>\> | ||
- Alessandro Uffreduzzi \<<[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,7 @@ | ||
**Italiano** | ||
|
||
Questo modulo aggiunge campi mancanti alla stampa del resoconto DDT | ||
|
||
**English** | ||
|
||
This module adds missing fields to the DDT report print |
86 changes: 86 additions & 0 deletions
86
l10n_it_intrastat_delivery_note/report/report_delivery_document.xml
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,86 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<template id="report_delivery_document" inherit_id="stock.report_delivery_document"> | ||
<xpath expr="//div[hasclass('page')]" position="before"> | ||
<t | ||
t-set="has_intrastat_code" | ||
t-value="o.move_lines.filtered(lambda l: l.product_id.intrastat_code_id)" | ||
/> | ||
</xpath> | ||
<xpath | ||
expr="//table[@name='stock_move_table']/thead/tr/th[@name='th_sm_product']" | ||
position="before" | ||
> | ||
<th name="th_sm_hs_code" t-if="has_intrastat_code"> | ||
<strong>HS Code</strong> | ||
</th> | ||
</xpath> | ||
<xpath | ||
expr="//table[@name='stock_move_line_table']/thead/tr/th[@name='th_sml_product']" | ||
position="before" | ||
> | ||
<th name="th_sml_hs_code" t-if="has_intrastat_code"> | ||
<strong>HS Code</strong> | ||
</th> | ||
</xpath> | ||
<xpath | ||
expr="//table[@name='stock_backorder_table']/thead/tr/th[@name='th_sb_product']" | ||
position="before" | ||
> | ||
<th name="th_sb_hs_code" t-if="has_intrastat_code"> | ||
<strong>HS Code</strong> | ||
</th> | ||
</xpath> | ||
|
||
<!-- old HS Code invisible --> | ||
<xpath | ||
expr="//table[@name='stock_move_table']/thead/tr/th[@t-if='has_hs_code']" | ||
position="attributes" | ||
> | ||
<attribute name="t-if">0</attribute> | ||
</xpath> | ||
|
||
<xpath | ||
expr="//table[@name='stock_move_line_table']/thead/tr/th[@t-if='has_hs_code']" | ||
position="attributes" | ||
> | ||
<attribute name="t-if">0</attribute> | ||
</xpath> | ||
</template> | ||
|
||
|
||
<!-- Intrastat Code to table rows--> | ||
<template | ||
id="stock_report_delivery_has_serial_move_line_inherit_delivery" | ||
inherit_id="stock.stock_report_delivery_has_serial_move_line" | ||
> | ||
<xpath expr="//td" position="before"> | ||
<td t-if="has_intrastat_code"> | ||
<span t-field="move_line.product_id.intrastat_code_id.name" /> | ||
</td> | ||
</xpath> | ||
|
||
<!-- old HS Code invisible --> | ||
<xpath expr="//td[@t-if='has_hs_code']" position="attributes"> | ||
<attribute name="t-if">0</attribute> | ||
</xpath> | ||
</template> | ||
|
||
<template | ||
id="stock_report_delivery_aggregated_move_lines_inherit_delivery" | ||
inherit_id="stock.stock_report_delivery_aggregated_move_lines" | ||
> | ||
<xpath expr="//td" position="before"> | ||
<td t-if="has_intrastat_code"> | ||
<span t-esc="aggregated_lines[line]['intrastat_code_id']" /> | ||
</td> | ||
</xpath> | ||
|
||
<!-- old HS Code invisible --> | ||
<xpath expr="//td[@t-if='has_hs_code']" position="attributes"> | ||
<attribute name="t-if">0</attribute> | ||
</xpath> | ||
</template> | ||
|
||
|
||
</odoo> |
25 changes: 25 additions & 0 deletions
25
l10n_it_intrastat_delivery_note/report/report_delivery_note.xml
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,25 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<template | ||
id="delivery_note_report_template" | ||
inherit_id="l10n_it_delivery_note.delivery_note_report_template" | ||
> | ||
<xpath expr="//table[@id='product_data']//th" position="before"> | ||
<t | ||
t-set="has_intrastat_code" | ||
t-value="doc.line_ids.filtered(lambda l: l.product_id.intrastat_code_id)" | ||
/> | ||
<th class="text-left" t-if="has_intrastat_code"> | ||
HS Code | ||
</th> | ||
</xpath> | ||
<xpath | ||
expr="//tbody[hasclass('sale_tbody')]//td[span[@t-field='line.product_id.default_code']]" | ||
position="before" | ||
> | ||
<td t-if="has_intrastat_code"> | ||
<span t-field="line.product_id.intrastat_code_id.name" /> | ||
</td> | ||
</xpath> | ||
</template> | ||
</odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.