| 1 |
from odoo import api, fields, models |
| 2 |
|
| 3 |
|
| 4 |
class PosConfig(models.Model): |
| 5 |
_inherit = "pos.config" |
| 6 |
|
| 7 |
is_spanish = fields.Boolean(string="Company located in Spain", compute="_compute_is_spanish") |
| 8 |
l10n_es_simplified_invoice_journal_id = fields.Many2one( |
| 9 |
comodel_name='account.journal', |
| 10 |
domain=[('type', '=', 'sale')], |
| 11 |
check_company=True, |
| 12 |
) |
| 13 |
simplified_partner_id = fields.Many2one( |
| 14 |
comodel_name="res.partner", |
| 15 |
string="Simplified invoice partner", |
| 16 |
compute="_compute_simplified_partner_id", |
| 17 |
) |
| 18 |
|
| 19 |
@api.depends("company_id") |
| 20 |
def _compute_is_spanish(self): |
| 21 |
for pos in self: |
| 22 |
pos.is_spanish = pos.company_id.country_code == "ES" and pos.l10n_es_simplified_invoice_journal_id |
| 23 |
|
| 24 |
def _compute_simplified_partner_id(self): |
| 25 |
for config in self: |
| 26 |
config.simplified_partner_id = self.env.ref("l10n_es.partner_simplified").id |
| 27 |
|
| 28 |
def get_limited_partners_loading(self, offset=0): |
| 29 |
|
| 30 |
|
| 31 |
res = super().get_limited_partners_loading(offset) |
| 32 |
if (self.simplified_partner_id.id,) not in res: |
| 33 |
res.append((self.simplified_partner_id.id,)) |
| 34 |
return res |