跳至内容
菜单
此问题已终结
3 回复
2333 查看

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"
形象
丢弃
编写者 最佳答案

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


形象
丢弃
最佳答案

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.

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
0
10月 20
3863
5
10月 19
9660
1
5月 24
2716
2
5月 24
6574
1
4月 24
2444