Skip to content
Snippets Groups Projects
Commit 9c8dec30 authored by rhe-odoo's avatar rhe-odoo
Browse files

[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#109073

Signed-off-by: default avatarTrinh Jacky (trj) <trj@odoo.com>
parent 02f1546e
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,8 @@ odoo.define('l10n_gcc_pos.OrderReceipt', function (require) {
get receiptEnv() {
let receipt_render_env = super.receiptEnv;
let receipt = receipt_render_env.receipt;
receipt.is_gcc_country = ['SA', 'AE', 'BH', 'OM', 'QA', 'KW'].includes(receipt_render_env.order.pos.company.country.code);
let company = this.env.pos.company;
receipt.is_gcc_country = company.country ? ['SA', 'AE', 'BH', 'OM', 'QA', 'KW'].includes(company.country.code) : false;
return receipt_render_env;
}
}
......
......@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import pos_order
from . import pos_config
# -*- 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()
......@@ -16,7 +16,7 @@ var _super_order = models.Order.prototype;
models.Order = models.Order.extend({
export_for_printing: function() {
var result = _super_order.export_for_printing.apply(this,arguments);
if (this.pos.company.country.code === 'SA') {
if (this.pos.company.country && this.pos.company.country.code === 'SA') {
const codeWriter = new window.ZXing.BrowserQRCodeSvgWriter()
let qr_values = this.compute_sa_qr_code(result.company.name, result.company.vat, result.date.isostring, result.total_with_tax, result.total_tax);
let qr_code_svg = new XMLSerializer().serializeToString(codeWriter.write(qr_values, 150, 150));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment