[FIX] l10n_gcc_pos: fix country undefined

When the country is not defined on the company, there was an error when using the gcc l10n.
To fix this, we check if the country is set before going further.

closes odoo/odoo#111325

X-original-commit: 0ac8554751fbe22d58108eda0ac24edc933a41d8
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
This commit is contained in:
rhe-odoo
2023-02-01 14:37:50 +01:00
parent e177ce3d21
commit de6a9a9ee2
4 changed files with 18 additions and 4 deletions
@@ -8,9 +8,7 @@ patch(OrderReceipt.prototype, "l10n_gcc_pos.OrderReceipt", {
const receipt_render_env = this._super(...arguments);
const receipt = receipt_render_env.receipt;
const country = receipt_render_env.order.pos.company.country;
receipt.is_gcc_country = ["SA", "AE", "BH", "OM", "QA", "KW"].includes(
country && country.code
);
receipt.is_gcc_country = country ? ["SA", "AE", "BH", "OM", "QA", "KW"].includes(country && country.code) : false;
return receipt_render_env;
},
});
+1
View File
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import pos_order
from . import pos_config
+15
View File
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.exceptions import UserError
from odoo.tools.translate import _
class pos_config(models.Model):
_inherit = 'pos.config'
def open_ui(self):
for config in self:
if not config.company_id.country_id:
raise UserError(_("You have to set a country in your company setting."))
return super(pos_config, self).open_ui()
+1 -1
View File
@@ -6,7 +6,7 @@ import { patch } from "@web/core/utils/patch";
patch(Order.prototype, "l10n_sa_pos.Order", {
export_for_printing() {
const result = this._super(...arguments);
if (this.pos.company.country.code === "SA") {
if (this.pos.company.country && this.pos.company.country.code === "SA") {
result.is_settlement = this.is_settlement();
if (!result.is_settlement) {
const codeWriter = new window.ZXing.BrowserQRCodeSvgWriter();