Hello,
I am on odoo 12.
I have two companies and different quantities for the same product.
I have a custom model with a field related to the product qty_available
qty_available = fields.Float(related='product_id.qty_available', string="Qté Disponible")
The problem is that I got the quantity of both company in my view.
I've tried this option :
qty_available = fields.Float(related='product_id.qty_available', string="Qté Disponible", company_dependent=True)
Nothing changes.
The closest I can get to the issue is in the module stock, product.py, def _get_domain_locations(self):
The instruction line 205
Warehouse.search([]).idsIt returns current company locations and the other company locations.
I know that there is something related to the context but I can't figure out what, there is something I am missing concerning multi company, your help would be very appreciated :)
Most of my knowledge is coming from this article: https://www.cybrosys.com/blog/how-to-handle-multi-company-odoo-custom-module
For the moment I've got around the issue using compute attribute just like that, its working fine but I am not fully satisfied, I want to understand :) Thank you in advance
qty_available = fields.Float(string="Qté Disponible", store=False, readonly=True, compute='_compute_qty_available')def _compute_qty_available(self):
for line in self:
line.qty_available = line.product_id.qty_available