Please sign in to comment.
[IMP] point_of_sale: accounting lock dates and POS sessions
Forbid locking the fiscal year or period in case there is an open POS session into it. Without that, it will be impossible to close these sessions, as the lock date will not allow posting accounting entries for them. Also forbid to create a session before lock date, as it would be impossible to close.
- Loading branch information...
Showing with 31 additions and 0 deletions.
|@@ -0,0 +1,21 @@|
|# -*- coding: utf-8 -*-|
|from odoo import api, models, fields, _|
|from odoo.exceptions import ValidationError|
|_inherit = 'res.company'|
|""" This constrains makes it impossible to change the period lock date if|
|some open POS session exists into it. Without that, these POS sessions|
|would trigger an error message saying that the period has been locked when|
|trying to close them.|
|pos_session_model = self.env['pos.session']|
|for record in self:|
|sessions_in_period = pos_session_model.search([('state', '!=', 'closed'), '|', ('start_at', '<=', record.period_lock_date), ('start_at', '<=', record.fiscalyear_lock_date)])|
|sessions_str = ', '.join(sessions_in_period.mapped('name'))|
|raise ValidationError(_("Please close all the point of sale sessions in this period before closing it. Open sessions are: %s ") % (sessions_str))|