From 0fd1354c423f6224bd6939f915c47254ebf32713 Mon Sep 17 00:00:00 2001
From: Mylyna Hy <myhy@odoo.com>
Date: Wed, 26 Apr 2023 21:27:29 +0000
Subject: [PATCH] [IMP] point_of_sale: no CoA error visible for pos

Problem: The error "There is no chart of accounts installed for this company..." appears for POS shop configurations
if they don't have a chart template configured for the company. It doesn't take into account if the company has its
own set of accounts so it will always show the error unless the chart template is set.

Solution: Include an additional condition to check if the company has accounting entries which is used to check
if the company has used its own set of chart of accounts for accounting.

Purpose: The error will only appear if the company has no chart template set or no accounting entries.

opw-3291399

closes odoo/odoo#121309

X-original-commit: b5106da3d303a3501eaac9bb4bc8ee3c7feb3eee
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Mylyna Hy (myhy) <myhy@odoo.com>
---
 addons/point_of_sale/models/pos_config.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py
index f93f21727c27..3ce7ce67bdf1 100644
--- a/addons/point_of_sale/models/pos_config.py
+++ b/addons/point_of_sale/models/pos_config.py
@@ -193,10 +193,7 @@ class PosConfig(models.Model):
     @api.depends('company_id')
     def _compute_company_has_template(self):
         for config in self:
-            if config.company_id.chart_template_id:
-                config.company_has_template = True
-            else:
-                config.company_has_template = False
+            config.company_has_template = self.env['account.chart.template'].existing_accounting(config.company_id) or config.company_id.chart_template_id
 
     def _compute_is_installed_account_accountant(self):
         account_accountant = self.env['ir.module.module'].sudo().search([('name', '=', 'account_accountant'), ('state', '=', 'installed')])
-- 
GitLab