summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2021-02-08 14:17:40 +0000
committerstd-odoo <std@odoo.com>2021-03-01 13:40:17 +0000
commitd7e559266f203d601ac676bc4af8f9dce343f621 (patch)
tree1edaa1f9a28a9d9a3159b3c19b50b8905ccff2eb
parent41b0d78c861a94630be28a16a13f2bae1b629777 (diff)
[REF] website_slides: 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
-rw-r--r--addons/website_slides/wizard/slide_channel_invite.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/addons/website_slides/wizard/slide_channel_invite.py b/addons/website_slides/wizard/slide_channel_invite.py
index b2a0d334632..737651e6a35 100644
--- a/addons/website_slides/wizard/slide_channel_invite.py
+++ b/addons/website_slides/wizard/slide_channel_invite.py
@@ -18,8 +18,8 @@ class SlideChannelInvite(models.TransientModel):
_description = 'Channel Invitation Wizard'
# composer content
- subject = fields.Char('Subject', compute='_compute_template_values', readonly=False, store=True)
- body = fields.Html('Contents', default='', 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', string='Attachments')
template_id = fields.Many2one(
'mail.template', 'Use template',
@@ -30,11 +30,20 @@ class SlideChannelInvite(models.TransientModel):
channel_id = fields.Many2one('slide.channel', string='Slide channel', required=True)
@api.depends('template_id')
- def _compute_template_values(self):
+ def _compute_subject(self):
for invite in self:
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.onchange('partner_ids')
def _onchange_partner_ids(self):