[FIX] stock: Show only affected products for lot_id name_search

What are the steps to reproduce your issue ?

    1. Install 'stock'
    2. Create 'ProductA' with 'Tracking By Lots'
    3. Create some 'Lots/Serial Numbers', for example 'CodeA0 and 'CodeA1'
    4. Go to 'Reporting/Inventory Report'
    5. Remove 'Product > Location' from the search bar.
    6. Click 'Create' and select 'ProductA' with 'WH/Stock' Location

What is currently happening ?

    When you set 'Lot/Serial Number', the available lots to choose
    are not limited to the selected product only.

What are you expecting to happen ?

    Show only lots of the selected product.

Why is this happening ?

    The domain contained no condition which depended on the product.

How to fix the bug ?

    Addition of a condition that depends on the product.

opw-238143

closes odoo/odoo#62046

X-original-commit: 3b33f1d3f5cb5182d5577176640bcf7427757ed2
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Achraf (abz)
2020-11-19 18:03:11 +00:00
parent 695e482b5e
commit 336192256d
+3 -1
View File
@@ -33,10 +33,12 @@ class StockQuant(models.Model):
]
if self.env.context.get('active_model') == 'product.product':
domain.insert(0, "('product_id', '=', %s)" % self.env.context.get('active_id'))
if self.env.context.get('active_model') == 'product.template':
elif self.env.context.get('active_model') == 'product.template':
product_template = self.env['product.template'].browse(self.env.context.get('active_id'))
if product_template.exists():
domain.insert(0, "('product_id', 'in', %s)" % product_template.product_variant_ids.ids)
else:
domain.insert(0, "('product_id', '=', product_id)")
return '[' + ', '.join(domain) + ']'
def _domain_product_id(self):