[FIX] stock: inventory at date for single product
On stock list view of a single product, when user click on "Inventory at Date" button, the displayed report shows all products. This commit makes the report only shows the current product. Task #2039731
This commit is contained in:
@@ -34,14 +34,22 @@ var InventoryReportListController = ListController.extend({
|
||||
* inventory at a given date.
|
||||
*/
|
||||
_onOpenWizard: function () {
|
||||
var state = this.model.get(this.handle, {raw: true});
|
||||
var stateContext = state.getContext();
|
||||
var context = {
|
||||
active_model: this.modelName,
|
||||
};
|
||||
if (stateContext.default_product_id) {
|
||||
context.product_id = stateContext.default_product_id;
|
||||
} else if (stateContext.product_tmpl_id) {
|
||||
context.product_tmpl_id = stateContext.product_tmpl_id;
|
||||
}
|
||||
this.do_action({
|
||||
res_model: 'stock.quantity.history',
|
||||
views: [[false, 'form']],
|
||||
target: 'new',
|
||||
type: 'ir.actions.act_window',
|
||||
context: {
|
||||
active_model: this.modelName,
|
||||
}
|
||||
context: context,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
class StockQuantityHistory(models.TransientModel):
|
||||
@@ -15,6 +16,13 @@ class StockQuantityHistory(models.TransientModel):
|
||||
def open_at_date(self):
|
||||
tree_view_id = self.env.ref('stock.view_stock_product_tree').id
|
||||
form_view_id = self.env.ref('stock.product_form_view_procurement_button').id
|
||||
domain = [('type', '=', 'product')]
|
||||
product_id = self.env.context.get('product_id', False)
|
||||
product_tmpl_id = self.env.context.get('product_tmpl_id', False)
|
||||
if product_id:
|
||||
domain = expression.AND([domain, [('id', '=', product_id)]])
|
||||
elif product_tmpl_id:
|
||||
domain = expression.AND([domain, [('product_tmpl_id', '=', product_tmpl_id)]])
|
||||
# We pass `to_date` in the context so that `qty_available` will be computed across
|
||||
# moves until date.
|
||||
action = {
|
||||
@@ -23,7 +31,7 @@ class StockQuantityHistory(models.TransientModel):
|
||||
'view_mode': 'tree,form',
|
||||
'name': _('Products'),
|
||||
'res_model': 'product.product',
|
||||
'domain': "[('type', '=', 'product')]",
|
||||
'domain': domain,
|
||||
'context': dict(self.env.context, to_date=self.inventory_datetime),
|
||||
}
|
||||
return action
|
||||
|
||||
Reference in New Issue
Block a user