| 1 | from odoo import api, fields, models |
| 2 | |
| 3 | |
| 4 | class AccountMove(models.Model): |
| 5 | _inherit = "account.move" |
| 6 | |
| 7 | l10n_tr_gib_invoice_scenario = fields.Selection( |
| 8 | selection=[ |
| 9 | ("TEMELFATURA", "Basic"), |
| 10 | ("KAMU", "Public Sector"), |
| 11 | ], |
| 12 | default="TEMELFATURA", |
| 13 | string="Invoice Scenario", |
| 14 | help="The scenario of the invoice to be sent to GİB.", |
| 15 | ) |
| 16 | l10n_tr_gib_invoice_type = fields.Selection( |
| 17 | compute="_compute_l10n_tr_gib_invoice_type", |
| 18 | store=True, |
| 19 | readonly=False, |
| 20 | default="SATIS", |
| 21 | string="GIB Invoice Type", |
| 22 | selection=[ |
| 23 | ("SATIS", "Sales"), |
| 24 | ("TEVKIFAT", "Withholding"), |
| 25 | ("IHRACKAYITLI", "Registered for Export"), |
| 26 | ("ISTISNA", "Tax Exempt"), |
| 27 | ], |
| 28 | help="The type of invoice to be sent to GİB.", |
| 29 | ) |
| 30 | l10n_tr_is_export_invoice = fields.Boolean(string="Is GIB Export") |
| 31 | l10n_tr_shipping_type = fields.Selection( |
| 32 | selection=[ |
| 33 | ("1", "Sea Transportation"), |
| 34 | ("2", "Railway Transportation"), |
| 35 | ("3", "Road Transportation"), |
| 36 | ("4", "Air Transportation"), |
| 37 | ("5", "Post"), |
| 38 | ("6", "Combined Transportation"), |
| 39 | ("7", "Fixed Transportation"), |
| 40 | ("8", "Domestic Water Transportation"), |
| 41 | ("9", "Invalid Transportation Method"), |
| 42 | ], |
| 43 | string="Shipping Method", |
| 44 | help="The type of shipping.", |
| 45 | ) |
| 46 | l10n_tr_exemption_code_id = fields.Many2one( |
| 47 | "l10n_tr_nilvera_einvoice_extended.account.tax.code", |
| 48 | compute="_compute_l10n_tr_exemption_code_id", |
| 49 | store=True, |
| 50 | readonly=False, |
| 51 | string="Exemption Reason", |
| 52 | help="The exception reason of the invoice.", |
| 53 | ) |
| 54 | l10n_tr_exemption_code_domain_list = fields.Binary(compute="_compute_l10n_tr_exemption_code_domain_list") |
| 55 | l10n_tr_nilvera_customer_status = fields.Selection( |
| 56 | string="Partner Nilvera Status", |
| 57 | related="partner_id.l10n_tr_nilvera_customer_status", |
| 58 | ) |
| 59 | |
| 60 | @api.depends("l10n_tr_gib_invoice_scenario", "l10n_tr_gib_invoice_type", "l10n_tr_is_export_invoice") |
| 61 | def _compute_l10n_tr_exemption_code_domain_list(self): |
| 62 | for record in self: |
| 63 | domain = [] |
| 64 | if record.l10n_tr_gib_invoice_type == "ISTISNA": |
| 65 | domain.extend(("exception", "export_exception")) |
| 66 | if record.l10n_tr_gib_invoice_type == "IHRACKAYITLI": |
| 67 | domain.append("export_registration") |
| 68 | if record.l10n_tr_is_export_invoice: |
| 69 | domain.append("export_exception") |
| 70 | record.l10n_tr_exemption_code_domain_list = domain |
| 71 | |
| 72 | @api.depends("l10n_tr_gib_invoice_scenario", "l10n_tr_is_export_invoice") |
| 73 | def _compute_l10n_tr_gib_invoice_type(self): |
| 74 | for record in self: |
| 75 | record.l10n_tr_gib_invoice_type = False |
| 76 | |
| 77 | @api.depends("l10n_tr_gib_invoice_scenario", "l10n_tr_gib_invoice_type", "partner_id") |
| 78 | def _compute_l10n_tr_exemption_code_id(self): |
| 79 | for record in self: |
| 80 | record.l10n_tr_exemption_code_id = False |
| 81 | |
| 82 | def _get_partner_l10n_tr_nilvera_customer_alias_name(self): |
| 83 | self.ensure_one() |
| 84 | if self.l10n_tr_is_export_invoice: |
| 85 | return self.company_id.l10n_tr_nilvera_export_alias |
| 86 | return super()._get_partner_l10n_tr_nilvera_customer_alias_name() |