itssajan
itssajan

Reputation: 830

Can I convert an Odoo browse object to JSON

I'm trying to integrate reactjs with Odoo, and successfully created components. Now my problem is that I cant get the JSON via odoo. The odoo programmer has to write special api request to make this happen. This is taking more time and code repetitions are plenty.

I tried may suggestions and none worked.

Is there a better way to convert the browse objects, that odoo generate, to JSON ?

Note: Entirely new to python and odoo, please forgive my mistakes, if any mentioned above.

Upvotes: 4

Views: 3573

Answers (1)

Dachi Darchiashvili
Dachi Darchiashvili

Reputation: 769

maybe this will help you:

Step 1: Create js that runs reqiest to /example_link

Step 2: Create controller who listens that link @http.route('/example_link', type="json")

Step 3: return from that function json return json.dumps(res) where res is python dictionary and also dont forget to import json.

Thats all, it's not very hard, hope I helped you, good luck.

Upvotes: 2

Related Questions