Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
5 Відповіді
4988 Переглядів

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.

Аватар
Відмінити

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

Автор

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.

Автор
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
Найкраща відповідь

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


Аватар
Відмінити
Автор Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
жовт. 23
6498
2
лист. 22
6879
0
вер. 21
2987
4
серп. 20
7797
2
бер. 20
11686