From a0f8ee92c3692f7d12652ec38a5e62f2cbddf0a8 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 14 Feb 2018 10:52:13 +0100 Subject: [PATCH] [FIX] website_quote: require payment field should be given by the template When having a default template for quotation Doing a sale order through the website Before this commit: The field require_payment on the SO was not matching the one on the template This leads to confusion at config time when on the backend something is set on the template as default while not matching what actually happens After this commit: The field require_payment on the SO is computed from the template OPW 807946 --- addons/website_quote/models/sale_order.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/website_quote/models/sale_order.py b/addons/website_quote/models/sale_order.py index 88a2015566a..b66e09f87c4 100644 --- a/addons/website_quote/models/sale_order.py +++ b/addons/website_quote/models/sale_order.py @@ -68,7 +68,14 @@ class SaleOrder(models.Model): (0, 'Not mandatory on website quote validation'), (1, 'Immediate after website order validation'), (2, 'Immediate after website order validation and save a token'), - ], 'Payment', help="Require immediate payment by the customer when validating the order from the website quote") + ], 'Payment', help="Require immediate payment by the customer when validating the order from the website quote", compute='_compute_require_payment', store=True) + + @api.one + @api.depends('template_id') + def _compute_require_payment(self): + # Do not overwrite if the field is already set + if self.template_id and (self.require_payment is None or self.require_payment is False): + self.require_payment = self.template_id.require_payment @api.multi def copy(self, default=None):