Skip to Content
Menu
This question has been flagged
1 Reply
12233 Views

def _action_cancel(self):
for move in self:
if move.created_purchase_line_id:
try:
activity_type_id = self.env.ref('mail.mail_activity_data_todo').id
except ValueError:
activity_type_id = False
self.env['mail.activity'].create({
'activity_type_id': activity_type_id,
'note': _('A sale order that generated this purchase order has been deleted. Check if an action is needed.'),
'user_id': move.created_purchase_line_id.product_id.responsible_id.id,
'res_id': move.created_purchase_line_id.order_id.id,
'res_model_id': self.env.ref('purchase.model_purchase_order').id,
})
return super(StockMove, self)._action_cancel()

Avatar
Discard
Best Answer

You just need to inherit the object and override that method you want to.

class StockMove(models.Model):
_inherit = 'stock.move'

@api.multi
def _action_cancel(self):
# Your code goes here
return super(StockMove, self)._action_cancel()
Avatar
Discard
Author

i did't want all the function to override completely i just want to change a single line of code that defined in the parent class function

This way you can override the function, write your code. You need to call the super before / after your code.

If you want to change the existing line in the method, in this can you need to overwrite the whole method in your module and then change the code accrodingly.