Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] REF l10n_it_withholding_tax withholding.tax display_name with cleaner implementation #4502

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions l10n_it_withholding_tax/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ Authors
Contributors
------------

- Alessandro Camilli <[email protected]>
- Lorenzo Battistini <[email protected]>
- Marco Colombo <https://github.com/TheMule71>
- Alex Comba <[email protected]>
- Alessandro Camilli <[email protected]>
- Lorenzo Battistini <[email protected]>
- Marco Colombo <https://github.com/TheMule71>
- Alex Comba <[email protected]>
- `Aion Tech <https://aiontech.company/>`__:

- Simone Rubino <[email protected]>

Maintainers
-----------
Expand Down
18 changes: 12 additions & 6 deletions l10n_it_withholding_tax/models/withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def _compute_total(self):
string="WT amount paid", store=True, readonly=True, compute="_compute_total"
)
move_ids = fields.One2many("withholding.tax.move", "statement_id", "Moves")
display_name = fields.Char(compute="_compute_display_name")

@api.depends("move_id.line_ids.account_id.account_type")
def _compute_type(self):
Expand Down Expand Up @@ -285,8 +284,12 @@ def get_wt_competence(self, amount_reconcile):
amount_wt = tax_data["tax"]
return amount_wt

def _compute_display_name(self):
self.display_name = self.partner_id.name + " - " + self.withholding_tax_id.name
def name_get(self):
res = []
for record in self:
name = record.partner_id.name + " - " + record.withholding_tax_id.name
res.append((record.id, name))
return res


class WithholdingTaxMove(models.Model):
Expand Down Expand Up @@ -341,7 +344,6 @@ class WithholdingTaxMove(models.Model):
"account.move", "Payment Move", ondelete="cascade"
)
wt_account_move_id = fields.Many2one("account.move", "WT Move", ondelete="cascade")
display_name = fields.Char(compute="_compute_display_name")
full_reconcile_id = fields.Many2one(
"account.full.reconcile",
compute="_compute_full_reconcile_id",
Expand Down Expand Up @@ -479,8 +481,12 @@ def generate_account_move(self):
}
)

def _compute_display_name(self):
self.display_name = self.partner_id.name + " - " + self.withholding_tax_id.name
def name_get(self):
res = []
for record in self:
name = record.partner_id.name + " - " + record.withholding_tax_id.name
res.append((record.id, name))
return res

def action_paid(self):
for move in self:
Expand Down
2 changes: 2 additions & 0 deletions l10n_it_withholding_tax/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
- Lorenzo Battistini \<<[email protected]>\>
- Marco Colombo \<<https://github.com/TheMule71>\>
- Alex Comba \<<[email protected]>\>
- [Aion Tech](https://aiontech.company/):
- Simone Rubino \<<[email protected]>\>
4 changes: 4 additions & 0 deletions l10n_it_withholding_tax/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Lorenzo Battistini &lt;<a class="reference external" href="mailto:lorenzo.battistini&#64;agilebg.com">lorenzo.battistini&#64;agilebg.com</a>&gt;</li>
<li>Marco Colombo &lt;<a class="reference external" href="https://github.com/TheMule71">https://github.com/TheMule71</a>&gt;</li>
<li>Alex Comba &lt;<a class="reference external" href="mailto:alex.comba&#64;agilebg.com">alex.comba&#64;agilebg.com</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
35 changes: 35 additions & 0 deletions l10n_it_withholding_tax/tests/test_withholding_tax.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Copyright 2018 Lorenzo Battistini (https://github.com/eLBati)
# Copyright 2024 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import time
from datetime import date, timedelta

from odoo import fields
from odoo.exceptions import ValidationError
from odoo.fields import first
from odoo.tests.common import Form, TransactionCase


Expand Down Expand Up @@ -364,3 +367,35 @@ def test_payment_reset_net_pay_residual(self):
wizard.amount,
invoice.amount_net_pay_residual,
)

def test_wt_display_name(self):
"""The display name of statements and moves
includes the partner and the tax."""
# Arrange
invoice = self.invoice
partner = invoice.partner_id
wt_tax = self.wt1040
payment_wizard = self._get_payment_wizard(invoice)
payment_wizard.action_create_payments()

wt_statement = self.env["withholding.tax.statement"].search(
[
("invoice_id", "=", invoice.id),
("withholding_tax_id", "=", wt_tax.id),
],
limit=1,
)
wt_move = first(wt_statement.move_ids)
# pre-condition
self.assertTrue(wt_statement)
self.assertTrue(wt_move)

# Act
wt_statement_display_name = wt_statement.display_name
wt_move_display_name = wt_move.display_name

# Assert
self.assertIn(partner.name, wt_statement_display_name)
self.assertIn(wt_tax.name, wt_statement_display_name)
self.assertIn(partner.name, wt_move_display_name)
self.assertIn(wt_tax.name, wt_move_display_name)
Loading