Skip to Content
Menu
This question has been flagged
1 Atsakyti
3248 Rodiniai

I have chatter working for individual records of a specific model. For example, when I go into the form view and I update a field, the change is logged in the chatter.

I have an action that is called from a tree view where multiple records of this model are selected. The action updates a field all the records that are selected. This change does not show up on the chatter.

I've tried using message_post but that does not work either. Here is a code example:

def do_action(self):

 items = self.env['model'].browse(
self._context.get('active_ids', []) )
for item in items:
item.update({'status': 'complete'})
item.message_post(body="item status complete.")


How do I get the chatter to show up on the individual records in their form view?    

Portretas
Atmesti
Best Answer

update:

this worked perfectly:


from odoo import fields, models


class FieldTracking(models.Model):
_name = 'practice.field.tracking'
_inherit = ['mail.thread']
_description = 'Field Tracking Demo'
_order = 'sequence, id'

name = fields.Char('Name', required=True, translate=True)
sequence = fields.Integer('Sequence', default=20)
done = fields.Boolean('Request Done', tracking=True) #

def toggle_done(self):
for s in self:
s.done = not s.done



there is a problem with XML tags

Portretas
Atmesti
Autorius

Tracking is added to the field. Updating the field from a form adds chatter. However updating it using the action from a tree view does not add chatter.

maybe the tree action has "tracking_disable" set to True in its context

Autorius

Thank you... I apologize but I realize now that the problem is slightly different than I described. The action is taken from a wizard. So, the workflow is: 1) Check the boxes in the tree view. 2) Select the action from the actions menu. 3) Wizard form opens that allows you to select the status to apply to all the records. 4) Click button in wizard that performs action that updates all the statuses. The records do not have the chatter. I have added the inherited mail modules to the Transient Model in the wizard as well and set tracking=true to the field in the wizard. I am in the process of creating a sample module that shows the problem. I will post a github repo here shortly.

Autorius

So, the error must be on my end somewhere. I created a sample project and proved that using a wizard to take an action on multiple items selected from a tree view does update the chatter. In case anyone else comes across this use case, here is a sample repo with a module: https://github.com/drew-corporate-creations/odoo-wizard-chatter-sample/tree/main

Related Posts Replies Rodiniai Veikla
1
rugp. 25
282
1
rugp. 25
361
1
rugp. 25
708
0
rugp. 25
452
0
liep. 25
1984