[FIX] point_of_sale: opening difference account

- Since dd21c708cc08d484530bc7c8433ebbb79f59323a, the opening cash difference is not posted in the suspense account. This commit fixes that.
 - Removes the error preventing the deletion of cash difference journal entries.

 task-id: 3460173

closes odoo/odoo#139975

X-original-commit: 52681b588c8353721f0b3d40f1b013bf0fc23904
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Theo VINCENT (thvi)
2023-11-24 18:46:39 +00:00
parent 1483a4945f
commit 2b875c5870
2 changed files with 4 additions and 8 deletions
@@ -9,9 +9,3 @@ class AccountBankStatementLine(models.Model):
_inherit = 'account.bank.statement.line'
pos_session_id = fields.Many2one('pos.session', string="Session", copy=False)
@api.ondelete(at_uninstall=False)
def _unlink_except_linked_to_pos_session(self):
for bsl in self:
if bsl.pos_session_id:
raise UserError(_("You cannot delete a bank statement line linked to Point of Sale session."))
+4 -2
View File
@@ -381,7 +381,8 @@ class PosSession(models.Model):
self.cash_journal_id.name))
st_line_vals['payment_ref'] = _("Cash difference observed during the counting (Loss)") + (_(' - opening') if is_opening else _(' - closing'))
st_line_vals['counterpart_account_id'] = self.cash_journal_id.loss_account_id.id
if not is_opening:
st_line_vals['counterpart_account_id'] = self.cash_journal_id.loss_account_id.id
else:
# self.cash_register_difference > 0.0
if not self.cash_journal_id.profit_account_id:
@@ -390,7 +391,8 @@ class PosSession(models.Model):
self.cash_journal_id.name))
st_line_vals['payment_ref'] = _("Cash difference observed during the counting (Profit)") + (_(' - opening') if is_opening else _(' - closing'))
st_line_vals['counterpart_account_id'] = self.cash_journal_id.profit_account_id.id
if not is_opening:
st_line_vals['counterpart_account_id'] = self.cash_journal_id.profit_account_id.id
self.env['account.bank.statement.line'].create(st_line_vals)