Skip to content

Commit 4ec9ab3

Browse files
committed
[FIX] l10n_it_edi_doi_extension: removed check on DOI tax to accept also other taxes
This PR is created to accept other taxes than DOI(for example inarcassa) removed also on odoo core odoo/odoo@b88caf8
1 parent d3d4fe7 commit 4ec9ab3

File tree

5 files changed

+56
-26
lines changed

5 files changed

+56
-26
lines changed

l10n_it_edi_doi_extension/README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ for the Declaration of Intent for incoming vendor bills.
5656
In the contacts, you can create a Declaration of Intent by choosing
5757
between two types:
5858

59-
- "Issued from company": for declarations issued by the company.
60-
- "Received from customer": for declarations received from suppliers.
59+
- "Issued from company": for declarations issued by the company.
60+
- "Received from customer": for declarations received from suppliers.
6161

6262
**Italiano**
6363

@@ -66,8 +66,9 @@ dedicata alla Dichiarazione di Intento per le fatture in ingresso. Nei
6666
contatti è possibile creare una Dichiarazione di Intento scegliendo tra
6767
due tipologie:
6868

69-
- "Issued from company": per le dichiarazioni emesse dall'azienda.
70-
- "Received from customer": per le dichiarazioni ricevute dai fornitori.
69+
- "Issued from company": per le dichiarazioni emesse dall'azienda.
70+
- "Received from customer": per le dichiarazioni ricevute dai
71+
fornitori.
7172

7273
Bug Tracker
7374
===========
@@ -90,7 +91,10 @@ Authors
9091
Contributors
9192
------------
9293

93-
- Nextev S.r.l<odoo@nextev.it>
94+
- Nextev S.r.l<odoo@nextev.it>
95+
- `Stesi Consulting <https://www.stesi.consulting>`__:
96+
97+
- Michele Di Croce <dicroce.m@stesi.consulting>
9498

9599
Maintainers
96100
-----------

l10n_it_edi_doi_extension/models/account_move.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ def _compute_l10n_it_edi_doi_amount(self):
3737
other_move_ids = self - purchase_move_ids
3838
super(AccountMove, other_move_ids)._compute_l10n_it_edi_doi_amount()
3939
for move in purchase_move_ids:
40-
tax = move.company_id.l10n_it_edi_doi_bill_tax_id
41-
if not tax or not move.l10n_it_edi_doi_id:
40+
l10n_it_edi_doi_bill_tax_ids = move.company_id.l10n_it_edi_doi_bill_tax_id
41+
if not l10n_it_edi_doi_bill_tax_ids or not move.l10n_it_edi_doi_id:
4242
move.l10n_it_edi_doi_amount = 0
4343
continue
4444
declaration_lines = move.invoice_line_ids.filtered(
45-
# The declaration tax cannot be used with other taxes on a single line
46-
# (checked in `_post`)
47-
lambda line, tax=tax: line.tax_ids.ids == tax.ids
45+
lambda line,
46+
l10n_it_edi_doi_bill_tax_ids=l10n_it_edi_doi_bill_tax_ids: all(
47+
tax in line.tax_ids for tax in l10n_it_edi_doi_bill_tax_ids
48+
)
4849
)
4950
move.l10n_it_edi_doi_amount = sum(declaration_lines.mapped("price_total"))
5051
return # W8110
@@ -97,13 +98,7 @@ def _post(self, soft=True):
9798
doi_bill_tax.name,
9899
)
99100
)
100-
if any(line.tax_ids != doi_bill_tax for line in declaration_lines):
101-
errors.append(
102-
_(
103-
"A line using tax %s should not contain any other taxes",
104-
doi_bill_tax.name,
105-
)
106-
)
101+
107102
if errors:
108103
raise UserError("\n".join(errors))
109104
return super()._post(soft)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
- Nextev S.r.l\<<odoo@nextev.it>\>
2+
- [Stesi Consulting](https://www.stesi.consulting):
3+
- Michele Di Croce \<<dicroce.m@stesi.consulting>\>
4+

l10n_it_edi_doi_extension/static/description/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
409409
due tipologie:</p>
410410
<ul class="simple">
411411
<li>“Issued from company”: per le dichiarazioni emesse dall’azienda.</li>
412-
<li>“Received from customer”: per le dichiarazioni ricevute dai fornitori.</li>
412+
<li>“Received from customer”: per le dichiarazioni ricevute dai
413+
fornitori.</li>
413414
</ul>
414415
</div>
415416
<div class="section" id="bug-tracker">
@@ -432,6 +433,10 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
432433
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
433434
<ul class="simple">
434435
<li>Nextev S.r.l&lt;<a class="reference external" href="mailto:odoo&#64;nextev.it">odoo&#64;nextev.it</a>&gt;</li>
436+
<li><a class="reference external" href="https://www.stesi.consulting">Stesi Consulting</a>:<ul>
437+
<li>Michele Di Croce &lt;<a class="reference external" href="mailto:dicroce.m&#64;stesi.consulting">dicroce.m&#64;stesi.consulting</a>&gt;</li>
438+
</ul>
439+
</li>
435440
</ul>
436441
</div>
437442
<div class="section" id="maintainers">

l10n_it_edi_doi_extension/tests/test_doi_issued_from_company.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def _create_declaration(cls, type_doi):
2222
"start_date": fields.Date.today(),
2323
"end_date": fields.Date.today() + relativedelta(months=2),
2424
"threshold": 5000,
25-
"protocol_number_part1": "123",
26-
"protocol_number_part2": "456",
25+
"protocol_number_part1": f"123{type_doi}",
26+
"protocol_number_part2": f"456{type_doi}",
2727
}
2828
)
2929

3030
@classmethod
31-
def _create_invoice(cls, name, partner, tax=False, date=False, in_type=False):
31+
def _create_invoice(cls, name, partner, taxes=False, date=False, in_type=False):
3232
invoice_form = Form(
3333
cls.env["account.move"].with_context(
3434
default_move_type="in_invoice" if in_type else "out_invoice",
@@ -39,20 +39,21 @@ def _create_invoice(cls, name, partner, tax=False, date=False, in_type=False):
3939
invoice_form.invoice_payment_term_id = cls.env.ref(
4040
"account.account_payment_term_advance"
4141
)
42-
cls._add_invoice_line_id(invoice_form, tax=tax, in_type=in_type)
42+
cls._add_invoice_line_id(invoice_form, taxes=taxes, in_type=in_type)
4343
invoice = invoice_form.save()
4444
return invoice
4545

4646
@classmethod
47-
def _add_invoice_line_id(cls, invoice_form, tax=False, in_type=False):
47+
def _add_invoice_line_id(cls, invoice_form, taxes=False, in_type=False):
4848
with invoice_form.invoice_line_ids.new() as invoice_line:
4949
invoice_line.product_id = cls.env.ref("product.product_product_5")
5050
invoice_line.quantity = 10.00
5151
invoice_line.name = "test line"
5252
invoice_line.price_unit = 90.00
53-
if tax:
53+
if taxes:
5454
invoice_line.tax_ids.clear()
55-
invoice_line.tax_ids.add(tax)
55+
for tax in taxes:
56+
invoice_line.tax_ids.add(tax)
5657

5758
@classmethod
5859
def setUpClass(cls):
@@ -81,7 +82,29 @@ def setUpClass(cls):
8182
cls.env.company.l10n_it_edi_doi_bill_tax_id = cls.tax
8283

8384
def test_in_invoice_under_declaration_limit(self):
84-
invoice = self._create_invoice("1", self.partner, tax=self.tax, in_type=True)
85+
invoice = self._create_invoice("1", self.partner, taxes=self.tax, in_type=True)
86+
previous_used_amount = self.doi_in.invoiced
87+
invoice.action_post()
88+
used_amount = self.doi_in.invoiced
89+
self.assertNotEqual(previous_used_amount, used_amount)
90+
self.assertEqual(used_amount, invoice.amount_total)
91+
self.assertEqual(self.doi_in.state, "active")
92+
93+
def test_out_invoice_with_two_taxes(self):
94+
tax2 = self.tax_model.create(
95+
{
96+
"l10n_it_exempt_reason": "N4",
97+
"l10n_it_law_reference": "Dumb tax for test",
98+
"type_tax_use": "purchase",
99+
"name": "0% dumb tax",
100+
"amount": 0,
101+
"tax_group_id": self.tax_group.id,
102+
}
103+
)
104+
invoice = self._create_invoice(
105+
"1", self.partner, taxes=self.tax | tax2, in_type=True
106+
)
107+
85108
previous_used_amount = self.doi_in.invoiced
86109
invoice.action_post()
87110
used_amount = self.doi_in.invoiced

0 commit comments

Comments
 (0)