Skip to Content
Menu
This question has been flagged
2 Replies
2981 Views

As we all know, @api.model_create_multi allows us to insert or create values at once from a list, instead of doing it one by one. As example, if we have:

values = [{...}, {...}]

Doing

record.create(values)

is better than

for val in values:
    record.create(val)

The other thing to take into consideration is that regarding the res.partner model, everywhere there is a create() method, it has the decorator @api.model_create_multi which allows us to pass a list of values to res.partner when we want to create records.

Now, the problem we are facing (only in odoo.sh) is that we are creating some partners from some data we take to another system via a connector. Those data are coming fine, and we have a list of all required data we are passing to the create().

If we have 5 contacts, the action we are calling will create only one contact and then one other, and then another one, etc... but in our local it's working fine, all the 5 contacts are created at once.

Here is the code: https://gist.github.com/nasser-bloopark/dfe8c5b42d6f2bd84ae37aafc0e4f468

After some investigations, we found that the issue is in the line destination_model.create(create_values).

Note that we didn't override the method create() anywhere, and we are using the OCA module partner_firstname as dependency to this custom module.

So, my question is: is there something I missed here or some other tips we can use from the ORM to fix this issue ?

Avatar
Discard
Best Answer

Hello Abdou Nasser,
May I recommend to open a ticket ?
The code you provide seems unrelated to the issue you describe. As you expect since you say the problem only occurs in odoo.sh. Therefore it's hard to debug something like this.

Generally speaking, I would expect records to be created one by one if there's inter-dependency among the created records or if a sequence is used in their creation.

Also generally speaking, your odoo.sh instance may have less resources, for example less available threads.

I see the module partner_firstname does override the create() method, but if it works properly in local that shouldn't be the issue.

Avatar
Discard
Author

Thank you Stanislas Gueniffey
I have contacted the odoo support and waiting
For now, i have put the create() in the for loop

Best Answer

Check if any of the code you have in the instance is overwriting the create method of res.partner and mangling the super calling.

Avatar
Discard
Related Posts Replies Views Activity
1
May 25
2069
1
Apr 25
3130
1
Apr 25
3908
1
Apr 25
1450
4
Mar 25
6415