Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
4990 Widoki

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.

Awatar
Odrzuć

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

Autor

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.

Autor
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
Najlepsza odpowiedź

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()


Awatar
Odrzuć
Autor Najlepsza odpowiedź

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 ([...])

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
paź 23
6499
2
lis 22
6880
0
wrz 21
2991
4
sie 20
7797
2
mar 20
11693