Debian Codegraph @

addons/l10n_sa_edi/models/account_tax.py

raw symbols SCIP
1 from odoo import fields, models, api, _
2 from odoo.exceptions import UserError
3
4
5 EXEMPTION_REASON_CODES = [
6 ('VATEX-SA-29', 'VATEX-SA-29 Financial services mentioned in Article 29 of the VAT Regulations.'),
7 ('VATEX-SA-29-7', 'VATEX-SA-29-7 Life insurance services mentioned in Article 29 of the VAT Regulations.'),
8 ('VATEX-SA-30', 'VATEX-SA-30 Real estate transactions mentioned in Article 30 of the VAT Regulations.'),
9 ('VATEX-SA-32', 'VATEX-SA-32 Export of goods.'),
10 ('VATEX-SA-33', 'VATEX-SA-33 Export of Services.'),
11 ('VATEX-SA-34-1', 'VATEX-SA-34-1 The international transport of Goods.'),
12 ('VATEX-SA-34-2', 'VATEX-SA-34-2 The international transport of Passengers.'),
13 ('VATEX-SA-34-3', 'VATEX-SA-34-3 Services directly connected and incidental to a Supply of international passenger transport.'),
14 ('VATEX-SA-34-4', 'VATEX-SA-34-4 Supply of a qualifying means of transport.'),
15 ('VATEX-SA-34-5', 'VATEX-SA-34-5 Any services relating to Goods or passenger transportation, as defined in article twenty five of these Regulations.'),
16 ('VATEX-SA-35', 'VATEX-SA-35 Medicines and medical equipment.'),
17 ('VATEX-SA-36', 'VATEX-SA-36 Qualifying metals.'),
18 ('VATEX-SA-EDU', 'VATEX-SA-EDU Private education to citizen.'),
19 ('VATEX-SA-HEA', 'VATEX-SA-HEA Private healthcare to citizen.'),
20 ('VATEX-SA-OOS', 'VATEX-SA-OOS Not subject to VAT.')
21 ]
22
23
24 class AccountTax(models.Model):
25 _inherit = 'account.tax'
26
27 l10n_sa_is_retention = fields.Boolean("Is Retention", default=False,
28 help="Determines whether or not a tax counts as a Withholding Tax")
29
30 l10n_sa_exemption_reason_code = fields.Selection(string="Exemption Reason Code",
31 selection=EXEMPTION_REASON_CODES, help="Tax Exemption Reason Code (ZATCA)")
32
33 @api.onchange('amount')
34 def onchange_amount(self):
35 super().onchange_amount()
36 self.l10n_sa_is_retention = False
37
38 @api.constrains("l10n_sa_is_retention", "amount", "type_tax_use")
39 def _l10n_sa_constrain_is_retention(self):
40 for tax in self:
41 if tax.amount >= 0 and tax.l10n_sa_is_retention and tax.type_tax_use == 'sale':
42 raise UserError(_("The tax is unable to be set as Retention as the Amount is greater than or equal to 0."))