From 0d01328a7b8f75af0cce72417315182cd4bf9c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 15 Jun 2015 00:59:32 +0200 Subject: [PATCH] Use the recomputed cost price as default new cost price for the update cost price wizard. issue4729 review6251002 --- product.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/product.py b/product.py index 154ef6756c..00654280cb 100644 --- a/product.py +++ b/product.py @@ -243,19 +243,27 @@ class UpdateCostPrice(Wizard): }) def default_ask_price(self, fields): + pool = Pool() + Product = pool.get('product.product') + Template = pool.get('product.template') + context = Transaction().context + default = {} if ('product' in fields and context['active_model'] == 'product.product'): - return { - 'product': context['active_id'], - } + product = Product(context['active_id']) + template = product.template + default['product'] = product.id elif ('template' in fields and context['active_model'] == 'product.template'): - return { - 'template': context['active_id'], - } + template = Template(context['active_id']) + product = template.products[0] + default['template'] = template.id else: - return {} + return default + default['cost_price'] = getattr(product, 'recompute_cost_price_%s' % + product.cost_price_method)() + return default @staticmethod def get_product():