Skip to Content
Menú
This question has been flagged
3 Respostes
2228 Vistes

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
Descartar
Autor Best Answer

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
Descartar
Best Answer

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
Descartar
Best Answer

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
Descartar
Related Posts Respostes Vistes Activitat
0
d’oct. 20
3762
5
d’oct. 19
9529
1
de maig 24
2599
2
de maig 24
6458
1
d’abr. 24
2375