Skip to content
Snippets Groups Projects
Commit 2c76d365 authored by Robin Heinz's avatar Robin Heinz Committed by Pierre Masereel
Browse files

[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: default avatarpimodoo <pimodoo@users.noreply.github.com>
parent cdc45471
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment