| 1 |
from odoo import api, models, _ |
| 2 |
from odoo.exceptions import UserError |
| 3 |
|
| 4 |
|
| 5 |
class IrSequence(models.Model): |
| 6 |
_inherit = 'ir.sequence' |
| 7 |
|
| 8 |
@api.ondelete(at_uninstall=False) |
| 9 |
def _unlink_sequence(self): |
| 10 |
configs = self.env['pos.config'].search(domain=[ |
| 11 |
'|', '|', '|', |
| 12 |
('order_seq_id', 'in', self.ids), |
| 13 |
('order_line_seq_id', 'in', self.ids), |
| 14 |
('device_seq_id', 'in', self.ids), |
| 15 |
('order_backend_seq_id', 'in', self.ids) |
| 16 |
]) |
| 17 |
if len(configs): |
| 18 |
raise UserError(_( |
| 19 |
"You cannot delete a sequence used in an active POS config: %s", |
| 20 |
configs.order_seq_id.mapped('name') |
| 21 |
)) |