I'm using odoo 10 i inherited from module stock.quant, i add a new attribute and a new method.
i want my method execute after each creating a new object in stock.quant.
This is my code.
Thanks for help.
class stock_quant(models.Model):
_inherit = 'stock.quant'
inventory_value_charge = fields.Float('Total Value',store=True,compute='update_stock_value')
@api.one
@api.depends('qty')
def update_stock_value(self):
stock_price_obj = self.env['stock.price.partition'].search([('id', '!=', False)])
val_obj = stock_price_obj.search([('reception.pack_operation_product_ids.pack_lot_ids.lot_id.id', '=', self.lot_id.id)])
if val_obj!= False:
val_obj.calccule_price()
else:
self.inventory_value_charge=self.inventory_value
#stock_price_obj = self.env['stock.price.partition'].search([('reception.pack_operation_product_ids.pack_lot_ids.lot_id.id', '=', self.lot_id.id)])
return True
Thanks a lot
Create Method: https://www.youtube.com/watch?v=_-fs_NBeOLI