From 48a30be23407de7b0509c65caa5af1209f80084a Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Tue, 1 Mar 2016 15:29:31 +0100 Subject: [PATCH] [FIX] website_quote: set default template on new SOs Commit 7270780 removed the default for the 'template_id' field, but other modules assumes SOs are created with it. If not, you cannot view the quote in the frontend and if you change the template afterward, you lose all the lines currently in the quote. This commit restores the behaviour from 9.0. Since the commit that removed them did not mention why it did (not even remotely), I'll assume it was unintentional and/or not thought through. --- addons/website_quote/models/order.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/website_quote/models/order.py b/addons/website_quote/models/order.py index f2f6caa8308..ac1bbaf117a 100644 --- a/addons/website_quote/models/order.py +++ b/addons/website_quote/models/order.py @@ -166,8 +166,16 @@ class sale_order(osv.osv): ], 'Payment', help="Require immediate payment by the customer when validating the order from the website quote"), } + def _get_template_id(self, cr, uid, context=None): + try: + template_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'website_quote', 'website_quote_template_default')[1] + except ValueError: + template_id = False + return template_id + _defaults = { 'access_token': lambda self, cr, uid, ctx={}: str(uuid.uuid4()), + 'template_id': _get_template_id, } def open_quotation(self, cr, uid, quote_id, context=None):