Odoo 12
I have a calculation in my model A that gets a total result from a line
Model A
_inherit = 'stock.landed.cost'
total_former_cost = fields.Float(string="total", compute='_compute_total_former_cost', compute_sudo=True, store=True)
@api.depends('valuation_adjustment_lines.former_cost')
def _compute_total_former_cost(self)
for gastos in self:
gastos.total_former_cost =
round(sum(gastos.valuation_adjustment_lines.mapped(''former_cost)), 2)
Example_Result = 20
I need to capture that result, store it and use it in another line calculation
Model B
external_model = fields.Many2one('stock.landed.cost', string="gastos")
total = fields.Float(string="porrateo", compute="def_compute_prueba", compute_sudo=True, store=True)
@api.one
@api.depends('external_model.total_former_cost')
def _compute_prueba(self):
self.total = self.external_model.total_former_cost + 5
Expected result = 5 + 20 = 25
Result = 5
The problem is that no matter what i do, or what i try, i always get 0 from the function, i have tried other fields like, the product.product.qty or name and i get it right, so the inheriting is ok.
Do someone have an idea how to store and use that total, what should i try?.