[FIX] point_of_sale: fix pos created when download pos restaurant

Prior to this commit, when creating a database with pos_restaurant,
a classic point_of_sale was created with the name Shop but without
all the settings of the previous Shop that was archived by
the installation of pos_restaurant. We do not want this so we remove
this behaviour.

We also fix another bug. The bug is that, if a starting pos config is
archived and that the user wants to download the demo data from the
frontend after that, the server will raise an error. This is because
the pos config is archived and the pos session will try to create orders
and use payment methods from the archived pos config. We also fix this
in this commit by not taking into account the
point_of_sale_onboarding_main_config.xml file if the pos config is
inactive.

closes odoo/odoo#146833

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Adrien Guilliams (adgu)
2023-12-19 17:32:18 +00:00
parent 88f1b488c5
commit aaaaddd4f5
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -6,7 +6,7 @@ from uuid import uuid4
import pytz
from odoo import api, fields, models, _, Command
from odoo.osv.expression import OR
from odoo.osv.expression import OR, AND
from odoo.exceptions import ValidationError, UserError
@@ -612,7 +612,11 @@ class PosConfig(models.Model):
if not companies:
companies = self.env['res.company'].search([])
for company in companies.filtered('chart_template'):
pos_configs = self.search([('company_id', '=', company.id), ('module_pos_restaurant', '=', False)])
domain = AND([
[('company_id', '=', company.id), ('module_pos_restaurant', '=', False)],
OR([[('active', '=', True)], [('active', '=', False)]]),
])
pos_configs = self.search(domain)
if not pos_configs:
self = self.with_company(company)
pos_configs = self.env['pos.config'].create({
+1 -1
View File
@@ -2241,7 +2241,7 @@ class PosSession(models.Model):
def _load_onboarding_data(self):
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:
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({