Skip to content

Commit

Permalink
Merge PR #3802 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by sergiocorato
  • Loading branch information
OCA-git-bot committed Jul 12, 2024
2 parents b046105 + af82932 commit 278de92
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 12 deletions.
3 changes: 3 additions & 0 deletions l10n_it_account_stamp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ Contributors
- Marco Colombo <https://github.com/TheMule71>
- Gianmarco Conte <[email protected]>
- Giovanni Serra <[email protected]>
- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <[email protected]>

Maintainers
-----------
Expand Down
23 changes: 22 additions & 1 deletion l10n_it_account_stamp/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import _, api, fields, models
Expand All @@ -7,7 +8,16 @@
class AccountMove(models.Model):
_inherit = "account.move"

tax_stamp = fields.Boolean(readonly=False, compute="_compute_tax_stamp", store=True)
tax_stamp = fields.Boolean(
help="Tax stamp is applied to this invoice.",
readonly=False,
compute="_compute_tax_stamp",
store=True,
)
tax_stamp_line_present = fields.Boolean(
string="Stamp line is present in invoice",
compute="_compute_tax_stamp_line_present",
)
auto_compute_stamp = fields.Boolean(
related="company_id.tax_stamp_product_id.auto_compute"
)
Expand Down Expand Up @@ -74,6 +84,7 @@ def add_tax_stamp_line(self):
invoice_line_vals = {
"move_id": inv.id,
"product_id": stamp_product_id.id,
"is_stamp_line": True,
"name": stamp_product_id.description_sale,
"sequence": 99999,
"account_id": stamp_account.id,
Expand All @@ -86,11 +97,21 @@ def add_tax_stamp_line(self):
inv.write({"invoice_line_ids": [(0, 0, invoice_line_vals)]})

def is_tax_stamp_line_present(self):
self.ensure_one()
for line in self.line_ids:
if line.is_stamp_line:
return True
return False

@api.depends(
"invoice_line_ids",
"invoice_line_ids.product_id",
"invoice_line_ids.product_id.is_stamp",
)
def _compute_tax_stamp_line_present(self):
for invoice in self:
invoice.tax_stamp_line_present = invoice.is_tax_stamp_line_present()

def is_tax_stamp_product_present(self):
product_stamp = self.invoice_line_ids.filtered(
lambda line: line.product_id.is_stamp
Expand Down
2 changes: 2 additions & 0 deletions l10n_it_account_stamp/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
- Marco Colombo \<<https://github.com/TheMule71>\>
- Gianmarco Conte \<<[email protected]>\>
- Giovanni Serra \<<[email protected]>\>
- [Aion Tech](https://aiontech.company/):
- Simone Rubino \<<[email protected]>\>
4 changes: 4 additions & 0 deletions l10n_it_account_stamp/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Marco Colombo &lt;<a class="reference external" href="https://github.com/TheMule71">https://github.com/TheMule71</a>&gt;</li>
<li>Gianmarco Conte &lt;<a class="reference external" href="mailto:gconte&#64;dinamicheaziendali.it">gconte&#64;dinamicheaziendali.it</a>&gt;</li>
<li>Giovanni Serra &lt;<a class="reference external" href="mailto:giovanni&#64;gslab.it">giovanni&#64;gslab.it</a>&gt;</li>
<li><a class="reference external" href="https://aiontech.company/">Aion Tech</a>:<ul>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;aion-tech.it">simone.rubino&#64;aion-tech.it</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
25 changes: 25 additions & 0 deletions l10n_it_account_stamp/tests/test_account_stamp_invoicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,28 @@ def test_amount_total_changing_currency(self):
total = invoice.amount_total
invoice.action_post()
self.assertEqual(total, invoice.amount_total)

def test_tax_stamp_line_button(self):
"""Stamp fields show when stamp is added with the button to the invoice."""
# Arrange: Create an invoice eligible for tax stamp but without it
stamp_tax = self.tax_id
invoice = self.init_invoice(
"out_invoice",
taxes=stamp_tax,
amounts=[
100,
],
)
# pre-condition
self.assertTrue(invoice.tax_stamp)
self.assertFalse(invoice.tax_stamp_line_present)

# Act
invoice.add_tax_stamp_line()

# Assert
self.assertTrue(invoice.tax_stamp_line_present)

# Resetting to draft removes the stamp
invoice.button_draft()
self.assertFalse(invoice.tax_stamp_line_present)
44 changes: 33 additions & 11 deletions l10n_it_account_stamp/views/account_move_view.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Copyright 2023 Simone Rubino - Aion Tech
~ License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
-->
<odoo>

<!-- Form: Invoice Customer -->
Expand All @@ -23,20 +27,38 @@
name="manually_apply_tax_stamp"
attrs="{'invisible': [('auto_compute_stamp', '=', True)]}"
/>
<field name="tax_stamp_line_present" invisible="1" />
</xpath>
<field name="narration" position="before">
<img
src="/l10n_it_account_stamp/static/description/icon.png"
alt="Tax stamp"
<div
name="stamp_applicability"
attrs="{'invisible': [('tax_stamp', '=', False)]}"
/>
<button
class="oe_edit_only"
type="object"
string="Add tax stamp line"
name="add_tax_stamp_line"
attrs="{'invisible': ['|',('tax_stamp', '=', False),('state', 'not in', 'draft')]}"
/>
colspan="2"
>
<img
src="/l10n_it_account_stamp/static/description/icon.png"
alt="Tax stamp"
/>
<span
attrs="{'invisible': [('tax_stamp_line_present', '=', True)]}"
>
<span attrs="{'invisible': [('state', 'not in', 'draft')]}">
<button
type="object"
string="Charge stamp to customer"
name="add_tax_stamp_line"
/>
</span>
<span attrs="{'invisible': [('state', '=', 'draft')]}">
Stamp can only be charged to customer when invoice is in draft state
</span>
</span>
<span
attrs="{'invisible': [('tax_stamp_line_present', '=', False)]}"
>
Stamp charged to customer
</span>
</div>
<!--move narration down-->
<div />
</field>
Expand Down

0 comments on commit 278de92

Please sign in to comment.