2

I am working on a Rails app that has a form that makes 1st party API requests to Odoo v12, where I have all of my data stored. When a user submits 2 forms simultaneously, if there's any delay in the API response (as few as .2 seconds), the server begins work on the other request, which is expected.

However, when the responses come back in the order they were made, rails assign the response to the request with an open connection. (For e.g. response 1 is being assigned to request 2, and response 2 is being assigned to request 1.)

Inspecting the request_ids confirms that this is what is happening. Example of created record IDs returning to the wrong request

res.partner create

Starting api call for res.partner on request 63f02dd4-8242-4043-9926-1e34133be2e1 at 1576616788523

[{:odoo_po=>"7643153000", :quickbooks_invoice_url=>"", :deal_name=>"Delete ME PLEASE", :deal_id=>"427759097", :reorder=>0, :company=>333, :sale_contact=>337, :submitted_by=>98, :approver=>119, :hubspot_id=>"427759097", :shipping_deadline=>"2020-01-07", :delivery_deadline=>"2020-01-13", :knitting_deadline=>"2020-01-03", :internal_notes=>"", "distributor_po"=>"14215", "kit_arrays"=>"1,85996,15578;2,15578,85996;"}]

sale_form.sale_form create

Starting api call for sale_form.sale_form on request 673fa655-907a-416f-8ed9-7c97d220fc0b at 1576616788650

18805 _
673fa655-907a-416f-8ed9-7c97d220fc0b

51 ms api call for sale_form.sale_form on request 673fa655-907a-416f-8ed9-7c97d220fc0b

9067 _ 63f02dd4-8242-4043-9926-1e34133be2e1

680 ms api call for res.partner on request 63f02dd4-8242-4043-9926-1e34133be2e1

In the code above, the '9067' should be record_id associated with the sale_form.sale_form request(request_id 673fa655-907a-416f-8ed9-7c97d220fc0b), while the '18805' should be the record_id associated with the res.partner request(request_id 63f02dd4-8242-4043-9926-1e34133be2e1)

The code runs fine when forms are submitted more than a few seconds apart so I don't think it is an issue with the code I've written. Is this an issue with Rails/Puma/some other Gem? Or should I shift my focus towards how Odoo is handling the requests/responses?

Sam Joshua
  • 310
  • 6
  • 17
Josh Joll
  • 33
  • 3
  • I know this is an old question but, we are facing a similar issue. Did you end finding the cause for this? – luispcosta May 28 '21 at 13:17
  • @luispcosta I never did. I think the main thing we did was reduce the number of API calls to try to limit the frequency this was happening. If you're self-hosting Odoo, I did find something in the base code that I think would fix the thread handling on the Odoo end. I was not self hosting though (using Odoo.sh), so I wasn't able to verify that it would work, and I don't remember what it was to be able to share with you, but you could focus your attention there. – Josh Joll May 31 '21 at 07:09
  • Are you used the external api of Odoo or have you a custom url ? – jo541 Jun 02 '21 at 15:35
  • We are using the external api of Odoo – Josh Joll Jun 04 '21 at 14:56

0 Answers0