This question has been flagged
1 Reply
4663 Views

                                                                                                        This is my mail.message pythoncode

values = {
'body': nl2br("""<b style="font-weight:600">Reject Reason:</b> """),
'model': self._name,
'message_type': 'comment',
'no_auto_thread': False,
'res_id': self.id,
'notification': True,
}
mail_id = self.env['mail.message'].create(values)
form_view = self.env.ref('hr_timesheet_sheet.view_message_form_log')
context = dict(self.env.context)
context['form_view_initial_mode'] = 'edit'

return {'name': _('Reject Reason'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.message',
'res_id': mail_id.id,
'views': [(form_view.id, 'form'), ],
'target': 'new',
}
api.multi
def refuse(self):
mail_values_refuse = {
# 'email_from': self.employee_id,work_email,
'email_to': 'self.employee_idwork_email',
'subject': 'rejected by' + self.employee_id.parent_id.name,
'body_html': '',
                                                     '//I need to display Here mail.message body content How?
'notification': True,
}
mail = self.env['mail.mail'].create(mail_values_refuse)
mail.send()



                                                                This is my mail.message xml code

<record model="ir.ui.view" id="view_message_form_log">
<field name="name">mail.message.form</field>
<field name="model">mail.message</field>
<field name="priority">25</field>
<field name="arch" type="xml">
<form string="Message">
<sheet>
<field name="body" options="{'style-inline': true}"/>
<footer>
<button name="refuse" type="object" string="Submit Reason"
confirm="Are you sure ??"
class="oe_highlight"/>
<button string="Discard" class="btn-default" special="cancel"/>
</footer>

</sheet>
</form>
</field>
</record>




My question is , If I click save button (save button is placed inside 'mail.message' class) the 'body 'content of mail.message will be passed to the mail.mail 'body_html'.

It shows an error like mail.message doesn't have

refuse

How to Solve it??
                                                            
 




Avatar
Discard
Best Answer

Change this context

context = dict(self.env.context) to context = {
'any_field_name' : self.id
}

Avatar
Discard