summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2021-02-08 13:45:07 +0000
committerstd-odoo <std@odoo.com>2021-03-01 13:40:17 +0000
commit842a9936d5b4ad8ffee4daf4c25e47118a4fe846 (patch)
tree16bcdda961795c2c64cab3f05f8331282e9eb40e /addons
parentd7e559266f203d601ac676bc4af8f9dce343f621 (diff)
[REF] survey: split computed editable fields
Purpose ======= Some computed stored editable fields are computed in the same method. In that case, when one of the value is provided in a create / write call, the computed method is not called and other fields computed in the same method do not have the right value. Task 2377119 COM odoo/odoo/pull/65772 ENT odoo/enterprise/pull/16221
Diffstat (limited to 'addons')
-rw-r--r--addons/survey/wizard/survey_invite.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/addons/survey/wizard/survey_invite.py b/addons/survey/wizard/survey_invite.py
index df14dc1afd9..8543587e519 100644
--- a/addons/survey/wizard/survey_invite.py
+++ b/addons/survey/wizard/survey_invite.py
@@ -28,8 +28,8 @@ class SurveyInvite(models.TransientModel):
return self.env.user.partner_id
# composer content
- subject = fields.Char('Subject', compute='_compute_template_values', readonly=False, store=True)
- body = fields.Html('Contents', sanitize_style=True, compute='_compute_template_values', readonly=False, store=True)
+ subject = fields.Char('Subject', compute='_compute_subject', readonly=False, store=True)
+ body = fields.Html('Contents', sanitize_style=True, compute='_compute_body', readonly=False, store=True)
attachment_ids = fields.Many2many(
'ir.attachment', 'survey_mail_compose_message_ir_attachments_rel', 'wizard_id', 'attachment_id',
string='Attachments')
@@ -139,15 +139,20 @@ class SurveyInvite(models.TransientModel):
))
@api.depends('template_id')
- def _compute_template_values(self):
+ def _compute_subject(self):
for invite in self:
- if not invite.subject:
- invite.subject = ''
- if not invite.body:
- invite.body = ''
if invite.template_id:
invite.subject = invite.template_id.subject
+ elif not invite.subject:
+ invite.subject = False
+
+ @api.depends('template_id')
+ def _compute_body(self):
+ for invite in self:
+ if invite.template_id:
invite.body = invite.template_id.body_html
+ elif not invite.body:
+ invite.body = False
@api.model
def create(self, values):