From f59f2ad8eca10ca511521ba349a3a5b09651af1d Mon Sep 17 00:00:00 2001 From: Renato Date: Sun, 4 Aug 2019 21:24:24 -0300 Subject: [PATCH] [REF] product price history action --- product_usability/models/product.py | 10 +++++----- product_usability/models/product_template.py | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/product_usability/models/product.py b/product_usability/models/product.py index c502ec4..c068b8b 100644 --- a/product_usability/models/product.py +++ b/product_usability/models/product.py @@ -4,6 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, fields +from odoo.tools.safe_eval import safe_eval class ProductProduct(models.Model): @@ -40,9 +41,8 @@ class ProductProduct(models.Model): def show_product_price_history(self): self.ensure_one() - action = self.env.ref(['ir.actions.act_window'].for_xml_id( - 'product_usability', 'product_price_history_action') - action.update({ - 'domain': "[('product_id', '=', %d)]" % self.ids[0], - }) + action = self.env.ref( + 'product_usability.product_price_history_action').read()[0] + action['domain'] = safe_eval(action['domain']) + action['domain'].append(('product_id', '=', self.id)) return action diff --git a/product_usability/models/product_template.py b/product_usability/models/product_template.py index 1e7344e..c1d1d66 100644 --- a/product_usability/models/product_template.py +++ b/product_usability/models/product_template.py @@ -26,7 +26,7 @@ class ProductTemplate(models.Model): purchase_ok = fields.Boolean( track_visibility='onchange') - + active = fields.Boolean( track_visibility='onchange') @@ -34,9 +34,7 @@ class ProductTemplate(models.Model): self.ensure_one() products = self.env['product.product'].search( [('product_tmpl_id', '=', self._context['active_id'])]) - action = self.env['ir.actions.act_window'].for_xml_id( - 'product_usability', 'product_price_history_action') - action.update({ - 'domain': "[('product_id', 'in', %s)]" % products.ids, - }) + action = self.env.ref( + 'product_usability.product_price_history_action').read()[0] + action['domain'] = [('product_id', 'in', products.ids)] return action