| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
from odoo import api, models |
| 4 |
from odoo.exceptions import UserError |
| 5 |
from odoo.tools.translate import _ |
| 6 |
|
| 7 |
|
| 8 |
class PosConfig(models.Model): |
| 9 |
_inherit = 'pos.config' |
| 10 |
|
| 11 |
def open_ui(self): |
| 12 |
for config in self: |
| 13 |
if not config.company_id.country_id: |
| 14 |
raise UserError(_("You have to set a country in your company setting.")) |
| 15 |
return super().open_ui() |
| 16 |
|
| 17 |
@api.model |
| 18 |
def _load_pos_data_read(self, records, config): |
| 19 |
data = super()._load_pos_data_read(records, config) |
| 20 |
|
| 21 |
if data and self.env.company.country_id.code == 'SA': |
| 22 |
l10n_sa_reason_field = self.env['ir.model.fields']._get('account.move', 'l10n_sa_reason') |
| 23 |
data[0]['_zatca_refund_reasons'] = [ |
| 24 |
{'value': refund_reason.value, 'name': refund_reason.name} |
| 25 |
for refund_reason in l10n_sa_reason_field.selection_ids |
| 26 |
] |
| 27 |
|
| 28 |
return data |