From 96a293f55e1c824f14e54d88ab33880d773ed8b6 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Mon, 2 Jul 2018 13:51:59 +0200 Subject: [PATCH] [IMP] sale, website_quote: default value in settings & templates Commit 2fa469c5e5e implemented the possibility to sign and pay (one after the other) a sale order to validate it. The option to sign and/or pay is activated in the sales settings but can be overrided by a template. Two improvements needs to be made: 1. Creating a new template should use the sale settings as default value for sign and pay confirmation mode. Note: If none has been enabled, sign should be forced. 2. Default value in sale settings should remains as it was before, nothing activated by default. opw-1818837 (Added specs with fgi) --- addons/sale/models/res_company.py | 2 +- addons/website_quote/models/sale_quote.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/sale/models/res_company.py b/addons/sale/models/res_company.py index d868ca91638..6ad140861ea 100644 --- a/addons/sale/models/res_company.py +++ b/addons/sale/models/res_company.py @@ -8,5 +8,5 @@ class ResCompany(models.Model): _inherit = "res.company" sale_note = fields.Text(string='Default Terms and Conditions', translate=True) - portal_confirmation_sign = fields.Boolean(string='Digital Signature', default=True) + portal_confirmation_sign = fields.Boolean(string='Digital Signature') portal_confirmation_pay = fields.Boolean(string='Electronic Payment') diff --git a/addons/website_quote/models/sale_quote.py b/addons/website_quote/models/sale_quote.py index 6456cb8e762..0acf90b1731 100644 --- a/addons/website_quote/models/sale_quote.py +++ b/addons/website_quote/models/sale_quote.py @@ -11,6 +11,16 @@ class SaleQuoteTemplate(models.Model): _name = "sale.quote.template" _description = "Sale Quotation Template" + def _get_default_require_signature(self): + # A confirmation mode (sign or pay) is mandatory on a quotation template + # If none has been activated in the settings, we force 'sign' as confirmation mode + if not self.env.user.company_id.portal_confirmation_pay: + return True + return self.env.user.company_id.portal_confirmation_sign + + def _get_default_require_payment(self): + return self.env.user.company_id.portal_confirmation_pay + name = fields.Char('Quotation Template', required=True) website_description = fields.Html('Description', translate=html_translate, sanitize_attributes=False) quote_line = fields.One2many('sale.quote.line', 'quote_id', 'Quotation Template Lines', copy=True) @@ -18,8 +28,8 @@ class SaleQuoteTemplate(models.Model): options = fields.One2many('sale.quote.option', 'template_id', 'Optional Products Lines', copy=True) number_of_days = fields.Integer('Quotation Duration', help='Number of days for the validity date computation of the quotation') - require_signature = fields.Boolean('Digital Signature', default=True, help='Request a digital signature to the customer in order to confirm orders automatically.') - require_payment = fields.Boolean('Electronic Payment', help='Request an electronic payment to the customer in order to confirm orders automatically.') + require_signature = fields.Boolean('Digital Signature', default=_get_default_require_signature, help='Request a digital signature to the customer in order to confirm orders automatically.') + require_payment = fields.Boolean('Electronic Payment', default=_get_default_require_payment,help='Request an electronic payment to the customer in order to confirm orders automatically.') mail_template_id = fields.Many2one( 'mail.template', 'Confirmation Mail', domain=[('model', '=', 'sale.order')],