Debian Codegraph @

addons/l10n_my_edi/models/account_tax.py

raw symbols SCIP
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 # ------------------
9 # Fields declaration
10 # ------------------
11
12 l10n_my_tax_type = fields.Selection(
13 selection=[
14 ('01', "Sales Tax"),
15 ('02', "Service Tax"),
16 ('03', "Tourism Tax"),
17 ('04', "High-Value Goods Tax"),
18 ('05', "Sales Tax on Low Value Goods"),
19 ('06', "Not Applicable"),
20 ('E', "Tax exemption (where applicable)"),
21 ],
22 string="Malaysian Tax Type",
23 compute="_compute_l10n_my_tax_type",
24 store=True,
25 readonly=False,
26 )
27 l10n_my_tax_exemption_reason = fields.Char(
28 string="Malaysian Tax Exemption Reason",
29 help="The reason for tax exemption, used when submitting consolidated invoices including this tax.",
30 )
31
32 # --------------------------------
33 # Compute, inverse, search methods
34 # --------------------------------
35
36 @api.depends('amount', 'country_id', 'tax_scope')
37 def _compute_l10n_my_tax_type(self):
38 """ Compute default tax type based on a few factors. """
39 for tax in self:
40 if tax.country_id.code != 'MY':
41 tax.l10n_my_tax_type = False
42 else:
43 if tax.amount == 0 and tax.tax_scope:
44 tax.l10n_my_tax_type = 'E'
45 elif tax.tax_scope == 'consu':
46 tax.l10n_my_tax_type = '01'
47 elif tax.tax_scope == 'service':
48 tax.l10n_my_tax_type = '02'
49 else:
50 tax.l10n_my_tax_type = '06'