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

[IMP] l10n_br_account #1077

Open
wants to merge 1 commit into
base: 13.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
26 changes: 25 additions & 1 deletion l10n_br_account/models/account_tax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from odoo import fields, models
from odoo import api, fields, models


class AccountTax(models.Model):
Expand All @@ -20,3 +20,27 @@ class AccountTax(models.Model):
('irrf', 'IRRF'),
('inss', 'INSS'),
('outros', 'Outros')], string="Tipo")
l10n_br_retention = fields.Boolean(string="Retenção?", compute="_compute_retention", inverse="_inverse_retention")

def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False, handle_price_include=True):
taxes = super(AccountTax, self).compute_all(
price_unit, currency, quantity, product, partner,
is_refund, handle_price_include)

return taxes

@api.depends("amount")
def _compute_retention(self):
if self.amount < 0:
self.l10n_br_retention = True
else:
self.l10n_br_retention = False

def _inverse_retention(self):
self.l10n_br_retention = self.l10n_br_retention

@api.onchange("l10n_br_retention")
def _onchange_retention(self):
if (self.l10n_br_retention and self.amount > 0 or
not self.l10n_br_retention and self.amount < 0):
self.amount = self.amount * (-1)
5 changes: 4 additions & 1 deletion l10n_br_account/views/account_tax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<field name="amount_type" position="after">
<field name="domain" />
</field>
<xpath expr="//group/group/div" position="after">
<field name="l10n_br_retention"></field>
</xpath>
</field>
</record>
</odoo>
</odoo>