From 4540b6595ecdd2805120ee080f62c90fb9bf8059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 29 Apr 2016 17:12:37 +0200 Subject: [PATCH] [FIX] mrp, account_analytic_default: removed methods When migrating stock, some dummies methods have been removed. Indeed those calls make more problems than they solve by adding unnecessary complexity around simple methods. However it seems some calls have been left in the process : - _get_act_window_dict which is basically an env.ref or act_window.for_xml_id - _get_products which is basically having all product_ids from template by iterating on product_variant_ids. --- .../account_analytic_default/models/product.py | 4 ++-- addons/mrp/product.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) 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 = {