[FIX] stock_account: valuation report needs company_owned in context

When calculating the stock_value of a product,
the system will take into account all the locations
that have this company as company.  (that way if owner_id
is not set, the company_id on the location is the owner (virtual: not set))

The Qty on Hand field takes into account however
the quantities that are in the warehouses.

This could lead to weird situations where the Quantity On Hand is 0
and so the record is not shown, while the stock value is positive.
(e.g. stock in Transit)

In order to use the same logic for both fields, we pass company_owned=True
in the context.
This commit is contained in:
Josse Colpaert
2018-04-18 17:42:22 +02:00
parent 05589db823
commit 8c64159b88
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -95,7 +95,7 @@
<field name="view_type">form</field>
<field name="view_id" ref="view_stock_product_tree2"/>
<field name="domain">[('type', '=', 'product'), ('qty_available', '!=', 0)]</field>
<field name="context">{}</field>
<field name="context">{'company_owned': True}</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
If there are products, you will see its name and valuation.
@@ -24,7 +24,7 @@ class StockQuantityHistory(models.TransientModel):
'name': _('Products'),
'res_model': 'product.product',
'domain': "[('type', '=', 'product'), ('qty_available', '!=', 0)]",
'context': dict(self.env.context, to_date=self.date),
'context': dict(self.env.context, to_date=self.date, company_owned=True),
}
return action
else: