Skip to content

Commit 6cfaf10

Browse files
authored
[MERGE][FIX] survey, 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/pull/65772 ENT odoo/enterprise/pull/16221 closes odoo#65772 Related: odoo/enterprise#16221 Signed-off-by: Thibault Delavallee (tde) <[email protected]>
2 parents 41b0d78 + 842a993 commit 6cfaf10

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

addons/survey/wizard/survey_invite.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def _get_default_author(self):
2828
return self.env.user.partner_id
2929

3030
# composer content
31-
subject = fields.Char('Subject', compute='_compute_template_values', readonly=False, store=True)
32-
body = fields.Html('Contents', sanitize_style=True, compute='_compute_template_values', readonly=False, store=True)
31+
subject = fields.Char('Subject', compute='_compute_subject', readonly=False, store=True)
32+
body = fields.Html('Contents', sanitize_style=True, compute='_compute_body', readonly=False, store=True)
3333
attachment_ids = fields.Many2many(
3434
'ir.attachment', 'survey_mail_compose_message_ir_attachments_rel', 'wizard_id', 'attachment_id',
3535
string='Attachments')
@@ -139,15 +139,20 @@ def _onchange_partner_ids(self):
139139
))
140140

141141
@api.depends('template_id')
142-
def _compute_template_values(self):
142+
def _compute_subject(self):
143143
for invite in self:
144-
if not invite.subject:
145-
invite.subject = ''
146-
if not invite.body:
147-
invite.body = ''
148144
if invite.template_id:
149145
invite.subject = invite.template_id.subject
146+
elif not invite.subject:
147+
invite.subject = False
148+
149+
@api.depends('template_id')
150+
def _compute_body(self):
151+
for invite in self:
152+
if invite.template_id:
150153
invite.body = invite.template_id.body_html
154+
elif not invite.body:
155+
invite.body = False
151156

152157
@api.model
153158
def create(self, values):

addons/website_slides/wizard/slide_channel_invite.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class SlideChannelInvite(models.TransientModel):
1818
_description = 'Channel Invitation Wizard'
1919

2020
# composer content
21-
subject = fields.Char('Subject', compute='_compute_template_values', readonly=False, store=True)
22-
body = fields.Html('Contents', default='', sanitize_style=True, compute='_compute_template_values', readonly=False, store=True)
21+
subject = fields.Char('Subject', compute='_compute_subject', readonly=False, store=True)
22+
body = fields.Html('Contents', sanitize_style=True, compute='_compute_body', readonly=False, store=True)
2323
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
2424
template_id = fields.Many2one(
2525
'mail.template', 'Use template',
@@ -30,11 +30,20 @@ class SlideChannelInvite(models.TransientModel):
3030
channel_id = fields.Many2one('slide.channel', string='Slide channel', required=True)
3131

3232
@api.depends('template_id')
33-
def _compute_template_values(self):
33+
def _compute_subject(self):
3434
for invite in self:
3535
if invite.template_id:
3636
invite.subject = invite.template_id.subject
37+
elif not invite.subject:
38+
invite.subject = False
39+
40+
@api.depends('template_id')
41+
def _compute_body(self):
42+
for invite in self:
43+
if invite.template_id:
3744
invite.body = invite.template_id.body_html
45+
elif not invite.body:
46+
invite.body = False
3847

3948
@api.onchange('partner_ids')
4049
def _onchange_partner_ids(self):

0 commit comments

Comments
 (0)