diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 77974a7ee7b96c5493e90957993d23f6dcfc91cc..130c5b0d88ce2245c21a6b8b504b9d0c09ea0860 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -1426,6 +1426,13 @@ class product_template(osv.osv): 'available_in_pos': True, } + def unlink(self, cr, uid, ids, context=None): + if self.search(cr, uid, [('id', 'in', ids), ('available_in_pos', '=', True)], context=context): + if self.pool['pos.session'].search(cr, uid, [('state', '!=', 'closed')], context=context): + raise osv.except_osv(_('Error!'), + _('You cannot delete a product saleable in point of sale while a session is still opened.')) + return super(product_template, self).unlink(cr, uid, ids, context=context) + class res_partner(osv.osv): _inherit = 'res.partner'