콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3307 화면

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

관련 게시물 답글 화면 활동
1
8월 25
202
1
8월 25
108
0
8월 25
124
1
8월 25
305
3
8월 25
302