[IMP] point_of_sale: prevent use of the cash control without profit and loss account

Prevent the use of the point of sale when the cash control is used and there is no
profit and loss account on cash jornals linked to payment method.

closes odoo/odoo#43493

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Robin Heinz
2020-01-17 14:01:13 +00:00
committed by Pierre Masereel
parent cdc4547168
commit 2c76d365e4
@@ -320,6 +320,12 @@ class PosConfig(models.Model):
if self.journal_id and self.journal_id.company_id.id != self.company_id.id:
raise ValidationError(_("The sales journal and the point of sale must belong to the same company."))
def _check_profit_loss_cash_journal(self):
if self.cash_control and self.payment_method_ids:
for method in self.payment_method_ids:
if method.is_cash_count and (not method.cash_journal_id.loss_account_id or not method.cash_journal_id.profit_account_id):
raise ValidationError(_("You need a loss and profit account on your cash journal."))
@api.constrains('company_id', 'invoice_journal_id')
def _check_company_invoice_journal(self):
if self.invoice_journal_id and self.invoice_journal_id.company_id.id != self.company_id.id:
@@ -547,6 +553,7 @@ class PosConfig(models.Model):
self._check_company_invoice_journal()
self._check_company_payment()
self._check_currencies()
self._check_profit_loss_cash_journal()
self.env['pos.session'].create({
'user_id': self.env.uid,
'config_id': self.id