[FIX] l10n_in_pos: demo data post installation

To reproduce:
- Install POS with demo data
- Install Indian localization(l10n_in)
- Open POS terminal
- Click on the load demo data
- Traceback thrown

Fix:
The issue occurs when the demo data executes the closing of the sessions.
The l10n_in _post method checks for a company state that is not yet set
at that point. It is important to note that this issue only arises
when loading demo data on a DB that doesn't contain demo data. The solution
is to extract the part of the method that executes the demo data linked to
the main config and to override it to not perform that part in the l10n_in_pos.

closes odoo/odoo#149011

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Loukas Wets (lowe)
2024-01-15 11:11:25 +00:00
parent 179475a54e
commit 7692edf4e8
2 changed files with 18 additions and 7 deletions
+8 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo import models, api
class PosSession(models.Model):
@@ -11,3 +11,10 @@ class PosSession(models.Model):
result = super()._loader_params_product_product()
result['search_params']['fields'].append('l10n_in_hsn_code')
return result
@api.model
def _load_onboarding_main_config_data(self, shop_config):
if shop_config.company_id.country_code == 'IN' and not shop_config.company_id.state_id:
return
super()._load_onboarding_main_config_data(shop_config)
+10 -6
View File
@@ -2242,12 +2242,16 @@ class PosSession(models.Model):
convert.convert_file(self.env, 'point_of_sale', 'data/point_of_sale_onboarding.xml', None, mode='init', kind='data')
shop_config = self.env.ref('point_of_sale.pos_config_main', raise_if_not_found=False)
if shop_config and shop_config.active:
convert.convert_file(self.env, 'point_of_sale', 'data/point_of_sale_onboarding_main_config.xml', None, mode='init', kind='data')
if len(shop_config.session_ids.filtered(lambda s: s.state == 'opened')) == 0:
self.env['pos.session'].create({
'config_id': shop_config.id,
'user_id': self.env.ref('base.user_admin').id,
})
self._load_onboarding_main_config_data(shop_config)
@api.model
def _load_onboarding_main_config_data(self, shop_config):
convert.convert_file(self.env, 'point_of_sale', 'data/point_of_sale_onboarding_main_config.xml', None, mode='init', kind='data')
if len(shop_config.session_ids.filtered(lambda s: s.state == 'opened')) == 0:
self.env['pos.session'].create({
'config_id': shop_config.id,
'user_id': self.env.ref('base.user_admin').id,
})
def _after_load_onboarding_data(self):
config = self.env.ref('point_of_sale.pos_config_main', raise_if_not_found=False)