[IMP] point_of_sale: Warning no chart of account

Point of sale config have multiple fields that depends on the accounting
localisation, but when you create a new company, the default values for
the journals, accounts, etc are not yet created because there is no
chart of account installed for the company.

So to avoid user that create a pos config to manually create accounting
journals and accounts, we are warning them to install first an
accounting localisation that will create them all necessaries account
and journals.

TASK-ID: 2028954

closes odoo/odoo#35042

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Gert Pellin
2019-08-13 13:13:04 +00:00
committed by Pierre Masereel
parent 08f3f3dffb
commit 2f6b2da914
2 changed files with 13 additions and 0 deletions
@@ -201,6 +201,15 @@ class PosConfig(models.Model):
"closing a session, for non-POS managers. If this maximum is reached, the user will have an error message at "
"the closing of his session saying that he needs to contact his manager.")
payment_method_ids = fields.Many2many('pos.payment.method', string='Payment Methods', default=lambda self: self._default_payment_methods())
company_has_template = fields.Boolean(string="Company has chart of accounts", compute="_compute_company_has_template")
@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
def _compute_is_installed_account_accountant(self):
account_accountant = self.env['ir.module.module'].sudo().search([('name', '=', 'account_accountant'), ('state', '=', 'installed')])
@@ -33,6 +33,7 @@
<field name="active" invisible="1"/>
<field name="currency_id" invisible="1"/>
<field name="is_installed_account_accountant" invisible="1"/>
<field name="company_has_template" invisible="1"/>
<div class="oe_title" id="title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
@@ -42,6 +43,9 @@
<div class="o_setting_right_pane">
<label for="company_id"/>
<div><field name="company_id" readonly="1"/></div>
<div class="o_notification_alert alert alert-warning" attrs="{'invisible':[('company_has_template','=',True)]}" role="alert">
There is no Chart of Accounts configured on the company. Please go to the invoicing settings to install a Chart of Accounts.
</div>
</div>
</div>
</div>