summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-02-22 09:45:47 +0100
committerLucas Perais (lpe) <lpe@odoo.com>2018-02-22 10:17:56 +0100
commitab37094ec44ff841a0d9a20781622565b52b844c (patch)
tree7173ab0b9859cb0cbacef3accd07ca687231fdf3
parentaad677c338ccd50c14e7a10314e3d18e76fe3f88 (diff)
[FIX] website_quote: default require_payment instead of compute
Commit a0f8ee92c3692f7d12652ec38a5e62f2cbddf0a8 solved the use case where a quotation was created through the website shop and where the default quote's template's require payment should be transmitted to the quote. However, this commit made the field readonly This present commit solves both problems by assigning a default to the problematic field rather than computing it OPW 817510
-rw-r--r--addons/website_quote/models/sale_order.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/addons/website_quote/models/sale_order.py b/addons/website_quote/models/sale_order.py
index b66e09f87c4..96b34ef657b 100644
--- a/addons/website_quote/models/sale_order.py
+++ b/addons/website_quote/models/sale_order.py
@@ -49,6 +49,15 @@ class SaleOrder(models.Model):
def _get_default_template_id(self):
return self.env.ref('website_quote.website_quote_template_default', raise_if_not_found=False)
+ def _default_require_payment(self):
+ default_template = self._get_default_template_id()
+ if self.template_id:
+ return self.template_id.require_payment
+ elif default_template:
+ return default_template.require_payment
+ else:
+ return 0
+
access_token = fields.Char(
'Security Token', copy=False, default=lambda self: str(uuid.uuid4()),
required=True)
@@ -68,14 +77,7 @@ 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", 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
+ ], 'Payment', help="Require immediate payment by the customer when validating the order from the website quote", default=_default_require_payment)
@api.multi
def copy(self, default=None):