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

Hello,

Please bear with me, as I am very new in Odoo. I just installed Odoo for a few days, and the main requirement is to track equipment maintenance. 

I saw that Odoo doesn't track stage change, but we need to time every stage in each request, like how long it was in requested stage, in-progress stage, or on-hold stage, and determine how many hours the equipment downtime. I don't know where to begin. I know python, and I know SQL, and I code in both. The problem is, that I don't know how to hook into odoo, and to track its changes, and how record them into the new table like maintenance_request_stage_log for example. 

Also, can I add something next to equipment log, regarding its maintenance status? Not that important, but I guess it's just a simple filter for maintenance_request_stage_log. 

Thank you


形象
丢弃
最佳答案

Hello,

If you are looking for a solution to track stage changes, you can easily achieve this by setting tracking=True in the field definition. This feature is provided by Odoo and helps automatically track changes made to the field.

Thank you,

形象
丢弃
编写者 最佳答案

Hello Matesh,


I am sorry, I can't comment on your answer. Not sure why, but nothing happened when I press comment. 

Anyway. tracking is already set as True. And I could see it on the log. By how do I hook into it? Like, subscribe to that particular event, specifically the maintenance request, and export the result to another model, like 'maintenance_request_stage_log'. Or perhaps, put a timer at the chatter message log below the request?

Something like:

Administrator

Yesterday at 16:34

Status changed

  • New RequestRepaired(Stage) : 4h 14m



Engineer

Yesterday at 12:20

Maintenance Request created


Adding that "4h 14m" as the time between 12:20 and 16:34


The view code only include <chatter/> and nothing else.


形象
丢弃
编写者

I had some problem fixing the reply above. It seems the discussion board refuse me to fix the indentation error.

Hello,

To achieve this, you need to post a customized message in the Chatter instead of relying on Odoo's predefined tracking system (e.g., "New stage --> Next Stage"). Here's how you can approach it:

1. When creating the record, ensure that the stage is set to the "Starting Stage" by default.

2. Create a DateTime field to store the time when the record is created. This will be used to calculate the time difference later.

3. Add a button that, when clicked, changes the stage to "Repaired".
Upon clicking the button, record the current time (when the stage changes to "Repaired").

4. Calculate the difference between the time the record was created (stored in the DateTime field) and the time the button was clicked (i.e., when the stage was changed).

5. Finally, use the message_post method to post the calculated time difference in the Chatter, giving a customized message for the stage transition.

相关帖文 回复 查看 活动
2
1月 24
1050
2
12月 23
995
1
12月 23
873
1
6月 23
1318
1
6月 23
4139