Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4652 Widoki

When user create a record, there are message at the bottom "Note by XXXX - xx:xx PM Partner Created".

How to call this function. Let say when user run workflow and move to another node at workflow, system will take note or give note.


Thanks and Regards,

Andreas


Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

1. Add a dependency for the module mail in __openerp__.py.

2. Inherit model mail.thread into your new model

class my_model(models.Model):
_name = 'my.model'
    _inherit = ['mail.thread']

3. Here you want to create the msg on changing states in a workflow. So call a python method from the node or workflow activity defined in the xml file.

4. In that python method, at the end, you can call message_post(), which will display the note.

For eg: Here am calling message_post() on record creation

@api.model    
def create(self, vals):
    new_trip = super(my_model, self).create(vals)
    new_trip.message_post(body="Trip created")
    return new_trip

5. To show the note area, you need add two fields from the mail.thread model in your form view like this:

<record model='ir.ui.view' id='my_model_form'>
    <field name="name">my.model.form</field>
    <field name="model">my.model</field>
    <field name="arch" type="xml">
        <form string="Vehicle">
            <sheet>
             ............
             ............
             ............
             </sheet>
             <div class="oe_chatter">
                <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
                <field name="message_ids" widget="mail_thread"/>
             </div>
        </form>
     </field>
     </record>

Note: The above steps is to add the message feature to new models. For existing models like res.partner, sale.order etc mail.thread is already inherited, so no need to inherit again or add the fields in xml file. You just need to call the message_post(body="Your note") from your desired python method in your inherited class.

Hope this helps

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
gru 18
6778
2
paź 15
9450
1
kwi 19
4690
5
cze 18
8440
1
mar 18
4273