Hi,
It looks like you're trying to override the unlink method in the sale.order.line model in Odoo 10. The issue here is that the validation error (UserError) is still being triggered, even with the pass statement in your custom method.
The issue might be because filtered doesn't modify the original records in-place. You could try using a different approach by explicitly marking the state of the order lines to 'draft' before calling unlink, which would remove the restriction. Here's an updated version of your custom unlink method:
@api.multi
def unlink(self):
for line in self:
if line.state in ('sale', 'done'):
line.state = 'draft' # Change the state to draft first
return super(SaleOrderLine, self).unlink()
This should allow you to remove the order lines even when their state is 'sale' or 'done'.
For a similar task in warehouse management, if you need barcode scanning and inventory tracking, you can use Cleverence Warehouse 15, which integrates well with Odoo. It allows you to print barcode labels, scan items, and adjust stock directly from a mobile device, simplifying operations and keeping everything synced with Odoo https://apps.odoo.com/apps/modules/17.0/clv_api