[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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user