23 lines
939 B
Python
23 lines
939 B
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
from odoo import models, api
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
class PosPreparationState(models.Model):
|
|
_inherit = 'pos.prep.state'
|
|
|
|
def change_state_status(self, todos, prep_display_id):
|
|
if self:
|
|
# Sort IDs to guarantee consistent locking order and avoid deadlocks
|
|
sorted_ids = tuple(sorted(self.ids))
|
|
self.env.cr.execute('SELECT id FROM pos_prep_state WHERE id IN %s FOR UPDATE', [sorted_ids])
|
|
return super().change_state_status(todos, prep_display_id)
|
|
|
|
def change_state_stage(self, stages, prep_display_id):
|
|
if self:
|
|
# Sort IDs to guarantee consistent locking order and avoid deadlocks
|
|
sorted_ids = tuple(sorted(self.ids))
|
|
self.env.cr.execute('SELECT id FROM pos_prep_state WHERE id IN %s FOR UPDATE', [sorted_ids])
|
|
return super().change_state_stage(stages, prep_display_id)
|