| 1 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 |
from odoo import api, fields, models |
| 3 |
|
| 4 |
|
| 5 |
class AccountTax(models.Model): |
| 6 |
_inherit = 'account.tax' |
| 7 |
|
| 8 |
l10n_ar_type_tax_use = fields.Selection( |
| 9 |
selection=[ |
| 10 |
('sale', 'Sales'), |
| 11 |
('purchase', 'Purchases'), |
| 12 |
('none', 'Other'), |
| 13 |
('supplier', 'Vendor Payment Withholding'), |
| 14 |
('customer', 'Customer Payment Withholding') |
| 15 |
], |
| 16 |
compute='_compute_l10n_ar_type_tax_use', inverse='_inverse_l10n_ar_type_tax_use', |
| 17 |
string="Argentina Tax Type" |
| 18 |
) |
| 19 |
l10n_ar_withholding_payment_type = fields.Selection( |
| 20 |
selection=[('supplier', 'Vendor Payment'), ('customer', 'Customer Payment')], |
| 21 |
string="Argentina Withholding Payment Type", |
| 22 |
help="Withholding tax for supplier or customer payments.") |
| 23 |
l10n_ar_tax_type = fields.Selection( |
| 24 |
string='WTH Tax', |
| 25 |
selection=[ |
| 26 |
('earnings', 'Earnings'), |
| 27 |
('earnings_scale', 'Earnings Scale'), |
| 28 |
('iibb_untaxed', 'IIBB Untaxed'), |
| 29 |
('iibb_total', 'IIBB Total Amount'), |
| 30 |
] |
| 31 |
) |
| 32 |
l10n_ar_withholding_sequence_id = fields.Many2one( |
| 33 |
'ir.sequence', |
| 34 |
string='WTH Sequence', |
| 35 |
copy=False, check_company=True, |
| 36 |
help='If no sequence provided then it will be required for you to enter withholding number when registering one.') |
| 37 |
l10n_ar_code = fields.Char('ARCA Code') |
| 38 |
l10n_ar_non_taxable_amount = fields.Float( |
| 39 |
string='Non Taxable Amount', |
| 40 |
digits='Account', |
| 41 |
help="Until this base amount, the tax is not applied." |
| 42 |
) |
| 43 |
l10n_ar_minimum_threshold = fields.Float( |
| 44 |
string="Minimum Treshold", |
| 45 |
help="If the calculated withholding tax amount is lower than minimum withholding threshold then it is 0.0.") |
| 46 |
l10n_ar_state_id = fields.Many2one( |
| 47 |
'res.country.state', string="Jurisdiction", ondelete='restrict', domain="[('country_id', '=?', country_id)]") |
| 48 |
l10n_ar_scale_id = fields.Many2one( |
| 49 |
comodel_name='l10n_ar.earnings.scale', |
| 50 |
string="Scale", help="Earnings table scale if tax type is 'Earnings Scale'." |
| 51 |
) |
| 52 |
|
| 53 |
@api.depends('type_tax_use', 'l10n_ar_withholding_payment_type') |
| 54 |
def _compute_l10n_ar_type_tax_use(self): |
| 55 |
for tax in self: |
| 56 |
if tax.country_code == 'AR': |
| 57 |
if tax.type_tax_use in ('sale', 'purchase'): |
| 58 |
tax.l10n_ar_type_tax_use = tax.type_tax_use |
| 59 |
elif tax.l10n_ar_withholding_payment_type in ('supplier', 'customer'): |
| 60 |
tax.l10n_ar_type_tax_use = tax.l10n_ar_withholding_payment_type |
| 61 |
else: |
| 62 |
tax.l10n_ar_type_tax_use = 'none' |
| 63 |
else: |
| 64 |
tax.l10n_ar_type_tax_use = 'none' |
| 65 |
|
| 66 |
@api.onchange('l10n_ar_type_tax_use') |
| 67 |
def _inverse_l10n_ar_type_tax_use(self): |
| 68 |
for tax in self.filtered(lambda t: t.country_code == 'AR'): |
| 69 |
if tax.l10n_ar_type_tax_use in ('sale', 'purchase'): |
| 70 |
tax.type_tax_use = tax.l10n_ar_type_tax_use |
| 71 |
tax.l10n_ar_tax_type = False |
| 72 |
tax.l10n_ar_state_id = False |
| 73 |
tax.l10n_ar_withholding_payment_type = False |
| 74 |
else: |
| 75 |
if tax.l10n_ar_type_tax_use in ('supplier', 'customer'): |
| 76 |
tax.l10n_ar_withholding_payment_type = tax.l10n_ar_type_tax_use |
| 77 |
else: |
| 78 |
tax.l10n_ar_withholding_payment_type = False |
| 79 |
tax.l10n_ar_tax_type = False |
| 80 |
tax.type_tax_use = 'none' |