Reputation: 485
Below method is existing in
Query 1: stock.move
@api.multi
def action_assign(self, no_prepare=False):
for move in moves:
if move.product_id.type == 'consu'
moves_to_assign |= move
continue
else:
moves_to_do |= move
I just want to add one line changes (i.e)
@api.multi
def action_assign(self, no_prepare=False):
for move in moves:
if move.product_id.type == 'consu' or move.product_id.type == 'service':
moves_to_assign |= move
continue
else:
moves_to_do |= move
I just want to customize only this line
**if move.product_id.type == 'consu' or move.product_id.type == 'service':**
and also Query 2: 'mrp.production' in this method
def _generate_raw_move(self, bom_line, line_data):
I just want to remove the below line
if bom_line.product_id.type not in ['product', 'consu']:
#return self.env['stock.move']
How to do write this methods in Custom module in Odoo 10.
Upvotes: 0
Views: 875
Reputation: 3378
In your addon you want to inherit from this addon stock.move
. Then just take the existing method and paste it into your own model. This will completely overwrite the existing method. So when that method is called it will only call your method and not the previously existing method.
This is the only way to accomplish what you are trying to do. You cant tell the program 'I only want to change these two lines'. When it comes to methods it does not really work that way.
If you wish to leave the existing method intact you can call super
and either execute your processing before or after your call to super
and sometimes this is better than completely overwriting the existing method. It really depends on your circumstance in my opinion.
class ClassName(models.Model):
_inherit = 'stock.move'
@api.multi
def action_assign(self, no_prepare=False):
for move in moves:
if move.product_id.type == 'consu' or move.product_id.type == 'service':
moves_to_assign |= move
continue
else:
moves_to_do |= move
Upvotes: 1