This question has been flagged
1 Reply
5231 Views

Hello all i try to override unlink method of sale order line. Function called but raise UserError validation not removed. 

Odoo default function:

@api.multi

def unlink(self):

if self.filtered(lambda x: x.state in ('sale', 'done')):

raise UserError(_('You can not remove a sale order line.\nDiscard changes and try setting the quantity to 0.'))

return super(SaleOrderLine, self).unlink()

Custom Override function:

@api.multi

def unlink(self):

if self.filtered(lambda x: x.state in ('sale', 'done')):

pass

return super(test, self).unlink()



Thanks in advance.


Avatar
Discard
Best Answer

Hi,

If you have to change the original function completely into new, don't user super. When using super the both the function will get executed, if you don't want to execute the original unlink function, remove the super from yours.


Thanks

Avatar
Discard
Author

Thanks Niyas, Now only single function work. But sale order line not unlink yet.