This question has been flagged
5 Replies
3853 Views

I have a server action (with id 421) that changes the field value of a specific partner.

Then I have a scheduled action that calls the server action like this:

Object: ir.actions.server
Method: _run_actions
Arguments: ([421],)

The server action, if started from the "more" menu, works but if I manually start the scheduled action, nothing happens and I don't even have any errors.

Avatar
Discard

I don't think you can use a Scheduled Action to do that. Maybe someone with more technical knowledge will explain why!

Author

I got to this point following other forum posts so I assume it can be done but there is something in my odoo that is not right.

Author
I'm new to Python ... is this useful?

@api.model
    def _run_actions(self, ids):
        """
            Run server actions with given ids.
            Allow crons to run specific server actions
        """
        return self.browse(ids).run()

Thank you very much
Best Answer

Probably from the scheduler you don't have active records/IDs and I think that is why your code is not working from the scheduler.

From more, it is working because you have active records. If this is the case, please search the records when the method is called from the scheduler.

It would be more helpful to guide you if you share your python code as well.

EDIT:

Your python code should search the records because when the method is called from the scheduler, you will not have IDs.

def _run_actions(self, ids):
if not ids:
self.search([]) # Add your conditions in domain to search the records
return self.browse(ids).run()


Avatar
Discard
Author Best Answer

Thank you so much for your help but i am too beginners to fix this.

I have yet to learn domain...

Could you give me an example to understand what to write in self.search ([...])

Avatar
Discard