diff --git a/addons/account_analytic_default/models/product.py b/addons/account_analytic_default/models/product.py index 8a6da483d11..a755fb893fc 100644 --- a/addons/account_analytic_default/models/product.py +++ b/addons/account_analytic_default/models/product.py @@ -26,8 +26,8 @@ class ProductTemplate(models.Model): @api.multi def action_view_rules(self): - result = self._get_act_window_dict('account_analytic_default.action_product_default_list') - result['domain'] = "[('product_id','in',[" + ','.join(map(str, self._get_products())) + "])]" + result = self.env.ref('account_analytic_default.action_product_default_list').read()[0] + result['domain'] = [('product_id', 'in', self.mapped('product_variant_ids').ids)] # Remove context so it is not going to filter on product_id with active_id of template result['context'] = "{}" return result diff --git a/addons/mrp/product.py b/addons/mrp/product.py index 585901137bd..41e6d0a9049 100644 --- a/addons/mrp/product.py +++ b/addons/mrp/product.py @@ -32,16 +32,15 @@ class product_template(osv.osv): _defaults = { 'produce_delay': 0, } - - + def action_view_mos(self, cr, uid, ids, context=None): - products = self._get_products(cr, uid, ids, context=context) - result = self._get_act_window_dict(cr, uid, 'mrp.act_product_mrp_production', context=context) - if len(ids) == 1 and len(products) == 1: - result['context'] = "{'default_product_id': " + str(products[0]) + ", 'search_default_product_id': " + str(products[0]) + "}" + product_ids = [variant.id for template in self.browse(cr, uid, ids, context=context) for variant in template.product_variant_ids] + result = self.pool['ir.actions.act_window'].for_xml_id(cr, uid, 'mrp', 'act_product_mrp_production') + if len(ids) == 1 and len(product_ids) == 1: + result['context'] = {'default_product_id': product_ids[0], 'search_default_product_id': product_ids[0]} else: - result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]" - result['context'] = "{}" + result['domain'] = [('product_id', 'in', product_ids)] + result['context'] = {} return result @@ -59,7 +58,7 @@ class product_product(osv.osv): } def action_view_bom(self, cr, uid, ids, context=None): - result = self.pool.get("product.template")._get_act_window_dict(cr, uid, 'mrp.product_open_bom', context=context) + result = self.pool['ir.actions.act_window'].for_xml_id(cr, uid, 'mrp', 'product_open_bom') templates = [product.product_tmpl_id.id for product in self.browse(cr, uid, ids, context=context)] # bom specific to this variant or global to template context = {