跳至内容
菜单
此问题已终结
1 回复
3262 查看

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?    

形象
丢弃
最佳答案

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

形象
丢弃
编写者

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

编写者

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.

编写者

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

相关帖文 回复 查看 活动
0
8月 25
112
1
8月 25
340
1
8月 25
382
1
8月 25
715
0
8月 25
463