Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3 Antworten
2432 Ansichten

Hello together,


can you please give me a hint what I am doing wrong? I trie to update every contact and company via scheduled action. Here you can find the python code:


# select all contacts
contacts = env['res.partner'].search([])

# query all contacts
for contact in contacts:
contact['mobile'] = "1234"
Avatar
Verwerfen
Autor Beste Antwort

Thank you for your answer, Cybrosys Techno Solutions Pvt.Ltd. Unfortunately that did not work


Also thank you Niyas for your answer. When I take a look into the log I can see some entries like those below. I trigger the action manually by button click.


2res.partner(99747,)Serverodoo.addons.base.models.ir_actionsinfoaction
07/25/2023 10:31:29mtls-odoo-mtls-odoo-erp-demo-intern-8847727res.partner(101969,)Serverodoo.addons.base.models.ir_actionsinfo
07/25/2023 10:31:29mtls-odoo-mtls-odoo-erp-demo-intern-8847727res.partner(102424,)Serverodoo.addons.base.models.ir_actionsinfo
07/25/2023 10:31:29mtls-odoo-mtls-odoo-erp-demo-intern-8847727res.partner(103795,)Serverodoo.addons.base.models.ir_actionsinfo
07/25/2023 10:31:29mtls-odoo-mtls-odoo-erp-demo-intern-8847727res.partner(103209,)Serverodoo.addons.base.models.ir_actionsinfo
07/25/2023 10:31:29mtls-odoo-mtls-odoo-erp-demo-intern-8847727res.partner(90039,)Serverodoo.addons.base.models.ir_actionsinfo


Avatar
Verwerfen
Beste Antwort

Hi,

Please try this you can use the update() method directly on the search result to update the 'mobile' field for all contacts in a single database query:


# Update all contacts' mobile fields to "1234"
contacts = env['res.partner'].search([])
contacts.update({'mobile': '1234'})


Hope it helps.

Avatar
Verwerfen
Beste Antwort

Hi,

It is expected to update the mobile number of contacts to 1234 . If this is not updating, see the result you get when searching in contacts.

Just add log(str(contacts)) and see the Logging menu under Settings -> Technical. Also you can add sudo to bypass access rights if any.

Also how you trigger this server action ? Using run button or ?


Thanks

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Okt. 20
3975
5
Okt. 19
9752
1
Mai 24
2759
2
Mai 24
6642
1
Apr. 24
2549