[FIX] stock: show product qty on searched location

The location_id and warehouse_id fields on product.template are just
dummy field intended to add something in the context that will be used
to compute the data being rendered (eg. for location, the quantity
displayed is the quantity of the product in the searched location).

But the feature was broken at a point, and has been solved in 11.0 with
7c7b099273.

This solution was not implemented in 10.0 up to saas-15 since this is
not acceptable for a stable version.

This changeset is only for 10.0 up to saas-15 to implement the fix
differently.

opw-1945417
closes #31475
This commit is contained in:
Nicolas Lempereur
2019-02-28 12:42:18 +00:00
parent 28f33dc150
commit 15ea753a0f
+19
View File
@@ -4,6 +4,7 @@
from odoo import api, fields, models, _
from odoo.addons import decimal_precision as dp
from odoo.exceptions import UserError
from odoo.osv import expression
from odoo.tools.float_utils import float_round
from datetime import datetime
import operator as py_operator
@@ -370,6 +371,15 @@ class Product(models.Model):
def action_view_routes(self):
return self.mapped('product_tmpl_id').action_view_routes()
@api.model
def search(self, domain=None, *args, **kwargs):
# ONLY FOR 10.0 UP TO SAAS-15
# ignore dummy fields used for search context²
for index in range(len(domain or [])):
if domain[index][0] in ('location_id', 'warehouse_id'):
domain[index] = expression.TRUE_LEAF
return super(Product, self).search(domain, *args, **kwargs)
@api.multi
def write(self, values):
res = super(Product, self).write(values)
@@ -505,6 +515,15 @@ class ProductTemplate(models.Model):
def onchange_tracking(self):
return self.mapped('product_variant_ids').onchange_tracking()
@api.model
def search(self, domain=None, *args, **kwargs):
# ONLY FOR 10.0 UP TO SAAS-15
# ignore dummy fields used for search context
for index in range(len(domain or [])):
if domain[index][0] in ('location_id', 'warehouse_id'):
domain[index] = expression.TRUE_LEAF
return super(ProductTemplate, self).search(domain, *args, **kwargs)
@api.multi
def write(self, vals):
if 'uom_id' in vals: