Skip to content

Commit

Permalink
[ADD] l10n_it_account_stamp: migration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
primes2h authored and SirAionTech committed Oct 18, 2024
1 parent c4e7190 commit dff90a8
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 30 deletions.
31 changes: 22 additions & 9 deletions l10n_it_account_stamp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fatture e nelle ricevute.

**English**

This module adds Italian Tax Stamp support in invoices and receipts.
This module adds Italian Stamp Duty support in invoices and receipts.

**Table of contents**

Expand All @@ -58,7 +58,7 @@ necessario abilitare le funzioni complete per la contabilità:
Modalità automatica:

- andare sul prodotto "Imposta di bollo 2 euro" e configurare "Imposte
marca da bollo" (Imposte in esenzione).
per bollo" (Imposte in esenzione).
- per ciascuna fattura o ricevuta, l'applicabilità dell'imposta di
bollo verrà calcolata in modo automatico in base alla somma degli
imponibili relativi alle imposte selezionate.
Expand All @@ -77,7 +77,7 @@ generalmente ricavo="Debiti per bolli" e costo="Valori bollati".

**English**

In order to change Tax Stamp 2 euro product settings, enable full
In order to change 'Stamp duty 2 euro' product settings, enable full
accounting features:

1. Settings -> Users & Companies -> Groups
Expand All @@ -86,17 +86,17 @@ accounting features:

Automatic mode:

- Go to 'Tax Stamp 2 euro' product and configure 'Stamp taxes'
- Go to 'Stamp duty 2 euro' product and configure 'Stamp taxes'
(exemption taxes).
- For each invoice or receipt, the base amount for each selected tax
will be added up and used to determine the application of the account
stamp.

Manual mode:

- Go to 'Tax Stamp 2 euro' product and deselect 'Auto-compute'
- Go to 'Stamp duty 2 euro' product and deselect 'Auto-compute'
checkbox.
- For each invoice or receipt, manually enable 'Tax Stamp' checkbox.
- For each invoice or receipt, manually enable 'Stamp Duty' checkbox.

Also set income/expense accounts, typically income = 'Debiti per bolli'
and expense = 'Valori bollati'.
Expand All @@ -115,12 +115,25 @@ verrà addebitata al cliente.

**English**

In invoice or receipt form, when applicable, click 'Add tax stamp line'
button to add tax stamp as invoice line, thus charging customer.
In invoice or receipt form, when applicable, click 'Add stamp duty line'
button to add stamp duty as invoice line, thus charging customer.

Otherwise, tax stamp will be anyway accounted, without charging
Otherwise, stamp duty will be anyway accounted, without charging
customer.

Known issues / Roadmap
======================

\*\* Italiano \*\*

Sono stati aggiunti gli script di migrazione, da provare quando saranno
rilasciati quelli relativi ad ``account``.

\*\* English \*\*

Migration scripts have been added, to be tested when ``account`` related
ones will be released.

Bug Tracker
===========

Expand Down
12 changes: 12 additions & 0 deletions l10n_it_account_stamp/migrations/18.0.1.0.0/noupdate_changes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8' ?>
<odoo>
<record id="l10n_it_account_stamp_2_euro" model="product.product">
<field name="name">Stamp duty 2 euro</field>
</record>
<record id="base.main_company" model="res.company">
<field
name="l10n_it_account_stamp_stamp_duty_product_id"
ref="l10n_it_account_stamp.l10n_it_account_stamp_2_euro"
/>
</record>
</odoo>
14 changes: 14 additions & 0 deletions l10n_it_account_stamp/migrations/18.0.1.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Sergio Zanchetta
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(
env.cr, "l10n_it_account_stamp", "18.0.1.0.0/noupdate_changes.xml"
)
openupgrade.delete_record_translations(
env.cr, "l10n_it_account_stamp", ["l10n_it_account_stamp_2_euro"]
)
59 changes: 59 additions & 0 deletions l10n_it_account_stamp/migrations/18.0.1.0.0/pre-migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2024 Sergio Zanchetta
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def _rename_fields(env):
openupgrade.rename_fields(
env,
[
(
"account.move",
"account_move",
"l10n_it_account_stamp_is_tax_stamp_applied",
"l10n_it_account_stamp_is_stamp_duty_applied",
),
(
"account.move",
"account_move",
"l10n_it_account_stamp_is_tax_stamp_present",
"l10n_it_account_stamp_is_stamp_duty_present",
),
(
"account.move",
"account_move",
"l10n_it_account_stamp_auto_compute_tax_stamp",
"l10n_it_account_stamp_auto_compute_stamp_duty",
),
(
"account.move",
"account_move",
"l10n_it_account_stamp_manually_apply_tax_stamp",
"l10n_it_account_stamp_manually_apply_stamp_duty",
),
(
"res.company",
"res_company",
"l10n_it_account_stamp_tax_stamp_product_id",
"l10n_it_account_stamp_stamp_duty_product_id",
),
(
"res.config.settings",
"res_config_settings",
"l10n_it_account_stamp_tax_stamp_product_id",
"l10n_it_account_stamp_stamp_duty_product_id",
),
(
"product.template",
"product_template",
"l10n_it_account_stamp_tax_stamp_apply_tax_ids",
"l10n_it_account_stamp_stamp_duty_apply_tax_ids",
),
],
)


@openupgrade.migrate()
def migrate(env, version):
_rename_fields(env)
59 changes: 59 additions & 0 deletions l10n_it_account_stamp/migrations/18.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2024 Sergio Zanchetta
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def _rename_fields(env):
openupgrade.rename_fields(
env,
[
(
"account.move",
"account_move",
"l10n_it_account_stamp_is_tax_stamp_applied",
"l10n_it_account_stamp_is_stamp_duty_applied",
),
(
"account.move",
"account_move",
"l10n_it_account_stamp_is_tax_stamp_present",
"l10n_it_account_stamp_is_stamp_duty_present",
),
(
"account.move",
"account_move",
"l10n_it_account_stamp_auto_compute_tax_stamp",
"l10n_it_account_stamp_auto_compute_stamp_duty",
),
(
"account.move",
"account_move",
"l10n_it_account_stamp_manually_apply_tax_stamp",
"l10n_it_account_stamp_manually_apply_stamp_duty",
),
(
"res.company",
"res_company",
"l10n_it_account_stamp_tax_stamp_product_id",
"l10n_it_account_stamp_stamp_duty_product_id",
),
(
"res.config.settings",
"res_config_settings",
"l10n_it_account_stamp_tax_stamp_product_id",
"l10n_it_account_stamp_stamp_duty_product_id",
),
(
"product.template",
"product_template",
"l10n_it_account_stamp_tax_stamp_apply_tax_ids",
"l10n_it_account_stamp_stamp_duty_apply_tax_ids",
),
],
)


@openupgrade.migrate()
def migrate(env, version):
_rename_fields(env)
8 changes: 6 additions & 2 deletions l10n_it_account_stamp/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ def _post(self, soft=True):
lang=inv.partner_id.lang
).l10n_it_account_stamp_stamp_duty_product_id
if not stamp_product_id:
raise UserError(_("Missing stamp duty product in company settings!"))
income_vals, expense_vals = inv._build_stamp_duty_lines(stamp_product_id)
raise UserError(

Check warning on line 195 in l10n_it_account_stamp/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_account_stamp/models/account_move.py#L195

Added line #L195 was not covered by tests
_("Missing stamp duty product in company settings!")
)
income_vals, expense_vals = inv._build_stamp_duty_lines(
stamp_product_id
)
income_vals["move_id"] = inv.id
expense_vals["move_id"] = inv.id
line_model.with_context(check_move_validity=False).create(income_vals)
Expand Down
7 changes: 7 additions & 0 deletions l10n_it_account_stamp/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
** Italiano **

Sono stati aggiunti gli script di migrazione, da provare quando saranno rilasciati quelli relativi ad `account`.

** English **

Migration scripts have been added, to be tested when `account` related ones will be released.
48 changes: 29 additions & 19 deletions l10n_it_account_stamp/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,18 @@ <h1 class="title">ITA - Imposta di bollo</h1>
<p>Questo modulo aggiunge il supporto all’imposta di bollo italiana nelle
fatture e nelle ricevute.</p>
<p><strong>English</strong></p>
<p>This module adds Italian Tax Stamp support in invoices and receipts.</p>
<p>This module adds Italian Stamp Duty support in invoices and receipts.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -403,7 +404,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Modalità automatica:</p>
<ul class="simple">
<li>andare sul prodotto “Imposta di bollo 2 euro” e configurare “Imposte
marca da bollo” (Imposte in esenzione).</li>
per bollo” (Imposte in esenzione).</li>
<li>per ciascuna fattura o ricevuta, l’applicabilità dell’imposta di
bollo verrà calcolata in modo automatico in base alla somma degli
imponibili relativi alle imposte selezionate.</li>
Expand All @@ -420,7 +421,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Impostare i conti di ricavo/costo nella scheda “Contabilità”,
generalmente ricavo=”Debiti per bolli” e costo=”Valori bollati”.</p>
<p><strong>English</strong></p>
<p>In order to change Tax Stamp 2 euro product settings, enable full
<p>In order to change Stamp duty 2 euro product settings, enable full
accounting features:</p>
<ol class="arabic simple">
<li>Settings -&gt; Users &amp; Companies -&gt; Groups</li>
Expand All @@ -429,17 +430,17 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
</ol>
<p>Automatic mode:</p>
<ul class="simple">
<li>Go to ‘Tax Stamp 2 euro’ product and configure ‘Stamp taxes’
<li>Go to ‘Stamp duty 2 euro’ product and configure ‘Stamp taxes’
(exemption taxes).</li>
<li>For each invoice or receipt, the base amount for each selected tax
will be added up and used to determine the application of the account
stamp.</li>
</ul>
<p>Manual mode:</p>
<ul class="simple">
<li>Go to ‘Tax Stamp 2 euro’ product and deselect ‘Auto-compute’
<li>Go to ‘Stamp duty 2 euro’ product and deselect ‘Auto-compute’
checkbox.</li>
<li>For each invoice or receipt, manually enable ‘Tax Stamp’ checkbox.</li>
<li>For each invoice or receipt, manually enable ‘Stamp Duty’ checkbox.</li>
</ul>
<p>Also set income/expense accounts, typically income = ‘Debiti per bolli’
and expense = ‘Valori bollati’.</p>
Expand All @@ -453,31 +454,40 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>In caso contrario, l’imposta di bollo verrà comunque considerata ma non
verrà addebitata al cliente.</p>
<p><strong>English</strong></p>
<p>In invoice or receipt form, when applicable, click ‘Add tax stamp line’
button to add tax stamp as invoice line, thus charging customer.</p>
<p>Otherwise, tax stamp will be anyway accounted, without charging
<p>In invoice or receipt form, when applicable, click ‘Add stamp duty line’
button to add stamp duty as invoice line, thus charging customer.</p>
<p>Otherwise, stamp duty will be anyway accounted, without charging
customer.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<p>** Italiano **</p>
<p>Sono stati aggiunti gli script di migrazione, da provare quando saranno
rilasciati quelli relativi ad <tt class="docutils literal">account</tt>.</p>
<p>** English **</p>
<p>Migration scripts have been added, to be tested when <tt class="docutils literal">account</tt> related
ones will be released.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-italy/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/l10n-italy/issues/new?body=module:%20l10n_it_account_stamp%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>Ermanno Gnan</li>
<li>Sergio Corato</li>
<li>Enrico Ganzaroli</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Lorenzo Battistini &lt;<a class="reference external" href="https://github.com/eLBati">https://github.com/eLBati</a>&gt;</li>
<li>Sergio Corato</li>
Expand All @@ -494,7 +504,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down

0 comments on commit dff90a8

Please sign in to comment.