[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
This commit is contained in:
Denis Ledoux
2015-09-10 15:56:05 +02:00
parent d7eb2c0397
commit 63a5bc8c5f
+7
View File
@@ -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"