From 63a5bc8c5f6f814246453f7a9f6980285f47e4d2 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 10 Sep 2015 15:48:01 +0200 Subject: [PATCH] [FIX] website_quote: default quote template values Once the website_quote module installed, the "default template" is set by default on all new quotations. There is an onchange on the field `template_id`, setting some values according to the template, including the description in the website quote. When creating the quotation / sale order from the web interface, the on change is triggered, and the values related to the template are correctly loaded. However, when the quotation is created through the code or the API, the default `template_id` was correctly set, but as the onchange wasn't triggered, as onchanges are automatically triggered only through the webclient creations, the related values, issued from the template, were not, such as the quote website description, or the date expiration, and so on. In particular, this happen when creating a quotation from an opportunity, through the "Convert to quotation" button. opw-648920 --- addons/website_quote/models/order.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index 04a7b0a5058..291d88a610e 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -306,6 +306,13 @@ class sale_order(osv.osv): return True return False + def create(self, cr, uid, values, context=None): + if not values.get('template_id'): + defaults = self.default_get(cr, uid, ['template_id'], context=context) + template_values = self.onchange_template_id(cr, uid, [], defaults.get('template_id'), partner=values.get('partner_id'), fiscal_position=values.get('fiscal_position'), context=context)['value'] + values = dict(template_values, **values) + return super(sale_order, self).create(cr, uid, values, context=context) + class sale_quote_option(osv.osv): _name = "sale.quote.option"