Odoo Help

0

0
5 Antwoorden
0
Justin Chen
12-06-19 00:25

I finally got it figured out.  For future reference,  

To Log note in the chatter.  There is a built-in function available named "message_post".  

There's no need to directly call the built-in wizard, I can create my own wizard and just write an action to use "message_post".  

"message_post" is available by _inherit = ['mail.thread', 'mail.activity.mixin'], which is needed for the xml form view to display chatter section anyway.  

Example:  

# This method overrides action_cancel and calls my own wizard.
def action_cancel(self):
view = self.env.ref('mymodule.xmlid_of_wizard')
wiz = self.env['action.cancel.confirm'].create({})
_logger.info("Action Cancel is overrided.")
super(Picking, self).action_cancel()
return {
'name': _('Your Reason to Cancel?'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'action.cancel.confirm',
'views': [(view.id, 'form')],
'view_id': view.id,
'target': 'new',
'res_id': wiz.id,
'context': {'parent_model': self._name,
'parent_id': self.id},
}


# Method in the wizard to Log
def action_confirm(self):
parent = self.env[self._context['parent_model']].browse(self._context['parent_id'])
msg = "Log to write"
parent.message_post(body=msg)
0
Avatar

Sudhir Arya (ERP Harbor Consulting Services) India

--Sudhir Arya (ERP Harbor Consulting Services)--
26907
| 8 9 10
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

ERP Harbor Consulting Services

Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services) India
06-06-19 01:11

Pass message_type field and it's value ("comment" or "notification") in the context when you return an action.

'default_message_type': 'comment',


3 Opmerkingen
Justin Chen
06-06-19 01:51

thx for reply, I just tried but still not working.

I also looked into mail_compose_message.py,

line 125: message_type = fields.Selection(default="comment")

I think without default_, on creation, message_type has already been comment.

Sudhir Arya (ERP Harbor Consulting Services) India
06-06-19 02:09

Try with notification as well in place of comment.

Justin Chen
06-06-19 02:27

It seems like if I pass default_message_type in context regardless the value, the wizard cannot be opened, and caused odoo-server error:

The requested operation cannot be completed due to security restrictions. Please contact your system administrator.

(Document type: Email composition wizard, Operation: create)

is_log = fields.Boolean('Log an Internal Note', help='Whether the message is an internal note (comment mode only)')

Field is_log says it only works in comment mode, I am so lost.

Stel een vraag
Schrijver
Blijf op de hoogte
1 volger(s)
Over deze community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now