Skip to content

Commit

Permalink
[RFC] l10n_br_coa: maintain code parity between versions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelsavegnago committed Apr 18, 2024
1 parent d44f70f commit bb09ed9
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions l10n_br_coa/models/account_chart_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,39 @@ def _load_template(
"l10n_br_coa.account.tax.group.account.template"
].search(domain)
if group_tax_account_template:

if tax.deductible:
account_id = group_tax_account_template.ded_account_id
refund_account_id = (
account = group_tax_account_template.ded_account_id
refund_account = (
group_tax_account_template.ded_refund_account_id
)
elif tax.withholdable:
if tax.type_tax_use == "purchase":
account_id = group_tax_account_template.account_id
refund_account_id = (
account = group_tax_account_template.account_id
refund_account = (
group_tax_account_template.refund_account_id
)
else:
account_id = False
refund_account_id = False
account = False
refund_account = False
else:
account_id = group_tax_account_template[
account = group_tax_account_template[
acc_names.get(tax.type_tax_use, {}).get("account_id")
]
refund_account_id = group_tax_account_template[
refund_account = group_tax_account_template[
acc_names.get(tax.type_tax_use, {}).get("refund_account_id")
]

if account:
account_id = account_ref[account.id].id
else:
account_id = False

if refund_account:
refund_account_id = account_ref[refund_account.id].id
else:
refund_account_id = False

tax.write(
{
"invoice_repartition_line_ids": [
Expand All @@ -98,9 +109,7 @@ def _load_template(
if tax.deductible or tax.withholdable
else 100,
"repartition_type": "tax",
"account_id": account_ref.get(
account_id.id if account_id else None, False
),
"account_id": account_id,
},
),
],
Expand All @@ -122,12 +131,7 @@ def _load_template(
if tax.deductible or tax.withholdable
else 100,
"repartition_type": "tax",
"account_id": account_ref.get(
refund_account_id.id
if refund_account_id
else None,
False,
),
"account_id": refund_account_id,
},
),
],
Expand Down

0 comments on commit bb09ed9

Please sign in to comment.