Is it possible to create entities with Many2One relations without creating the relatet entity first?

I’m interacting with trytond via json rpc.

When I create a entity which has a Many2Many or a One2Many relation/field, I am able to create the related entities when I call create on the entity that has the relation.

(model-create session "party.party"
                            [{:name "name-test"
                              :code "code-test-1"
                              :identifiers [["create" [{:code "test-1"}]]]}])

Can I do the same or similar with a Many2One field? It’s not clear to me per documentation which are the expected values of a Many2One.
I know that I could pass the id of the entity that the Many2One makes reference to.
By looking at he code of Many2One it seems like I should be able to pass a dictionary but it fails on creation if the dictionary has no id. I would like to create both the entities with a single call if possible.

(model-create session "company.company"
                     [{:currency 44
                       :party {:code "company-test-code"}}])

Is it possible to create entities with Many2One relations without creating the related entity first in a previous call?

No it is not possible with the standard API. But you can still define your own RPC call which does it.

This is quite a bit off-topic but what language are you using it looks like lisp but it isn’t?

The language is clojure / clojurescript (cljs)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.