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
5068 Widoki

Hello Odders,

Trying to update activities record for custom modules to be changed as "Done" when approval status is set to "Approve".


Awatar
Odrzuć
Najlepsza odpowiedź

To mark activities as done using Python in Odoo, you can use the write method on the 'mail.activity' model to update the activity's state to 'done'. Here is an example:

 Import the mail.activity model
from odoo import models

# Get a reference to the mail.activity model
activity_model = self.env['mail.activity']

# Use the search method to find the activities that need to be marked as done
activities = activity_model.search([('state', '=', 'to_do')])

# Update the state of each activity to 'done'
activities.write({'state': 'done'})

Alternatively, you can use automated actions to mark activities as done. To do this, you can create a new automated action with the following properties:

  • Action Type: Update a record
  • Model: mail.activity
  • Record: Current record
  • Set the following fields: state: Done

Once you have created the automated action, you can then use it in your workflow by adding a new transition with the following properties:

  • Trigger: On Change
  • Filter: approval_status = Approve
  • Action: The automated action you created earlier.

This will mark any activities associated with the record as done when the approval status is set to 'Approve'.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lis 23
1290
0
kwi 23
1813
1
lis 22
3762
2
mar 24
4654
1
mar 23
2566