Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
2327 Vizualizări

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"
Imagine profil
Abandonează
Autor Cel mai bun răspuns

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


Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
oct. 20
3858
5
oct. 19
9638
1
mai 24
2714
2
mai 24
6573
1
apr. 24
2439