Skip to content

Commit

Permalink
Merge PR #88 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Dec 3, 2023
2 parents 2e83b6e + 5df595e commit 076185d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions l10n_pt_account_invoicexpress/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def _compute_invoicexpress_doc_type(self):
" If unset, InvoiceXpress will not be used.",
)

def _compute_is_l10npt_vat_enabled(self):
res = super()._compute_is_l10npt_vat_enabled()
# Disable VAT PT options is InvoiceXpress is disabled
for invoice in self.filtered("invoice.is_l10n_vat_enabled"):
if not invoice.can_invoicexpress:
invoice.is_l10npt_vat_enabled = False

@api.constrains("journal_id", "company_id")
def _check_invoicexpress_doctype_config(self):
"""
Expand Down
11 changes: 8 additions & 3 deletions l10n_pt_vat/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class AccountMove(models.Model):
_inherit = "account.move"

is_l10npt_vat_enabled = fields.Boolean(compute="_compute_is_l10npt_vat_enabled")
vat_adjustment_norm_id = fields.Many2one(
"account.vat.adjustment_norm",
string="VAT Adjustment Norm",
Expand All @@ -25,6 +26,12 @@ class AccountMove(models.Model):
readonly=False,
)

def _compute_is_l10npt_vat_enabled(self):
for invoice in self:
invoice.is_l10npt_vat_enabled = (
invoice.country_code == "PT" and invoice.is_sale_document()
)

@api.depends("country_code", "move_type", "invoice_line_ids")
def _compute_l10npt_has_tax_exempt_lines(self):
for invoice in self:
Expand Down Expand Up @@ -53,9 +60,7 @@ def action_post(self):
"""
VAT Exemption reason is required if there are lines without tax
"""
for invoice in self.filtered(
lambda x: x.country_code == "PT" and x.is_sale_document()
):
for invoice in self.filtered("is_l10npt_vat_enabled"):
exempt_lines = invoice.invoice_line_ids.filtered(
lambda x: not x.tax_ids.filtered("amount")
)
Expand Down
9 changes: 5 additions & 4 deletions l10n_pt_vat/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
<field name="arch" type="xml">

<data>
<!-- Add the VAT Adjustment Norm (Fields 40/41 of the VAT Statement) !-->
<!-- Add the VAT Adjustment Norm (Fields 40/41 of the VAT Statement) -->
<div name="journal_div" position="after">
<field name="move_type" invisible="1" />
<field name="is_l10npt_vat_enabled" invisible="1" />
<field
name="l10npt_vat_exempt_reason"
attrs="{'invisible': [('country_code', '!=', 'PT')]}"
attrs="{'invisible': [('is_l10n_vat_enabled', '=', 'False')]}"
/>
<field name="move_type" invisible="1" />
<field
name="vat_adjustment_norm_id"
attrs="{'invisible': ['|',('country_code', '!=', 'PT'),('move_type', 'not in', ['out_refund', 'in_refund'])]}"
attrs="{'invisible': ['|',('is_l10n_vat_enabled', '=', False),('move_type', 'not in', ['out_refund', 'in_refund'])]}"
domain="[('move_type', '=', move_type)]"
/>
</div>
Expand Down

0 comments on commit 076185d

Please sign in to comment.