writing one2many and many2many fields
Hello,
I have been trying most OERPLib and I'm happy with what it does except in writing one2many and many2many fields.
If you read an object, you have nicely mapped one2many and many2many fields to a generator of browse_record instances. However, if you write an object you have to use the awkward openerp syntax. It would be great if you let us to use browse_record instances or ids like you're doing in the many2one fields. As the usual stuff to do in one2many and many2many fields is (6, 0,[ids]), you can make that the default behaviour. If the user wants to do something more obscure with the relationship he can use the usual openerp syntax.
A little test of what I'm saying is:
# helpers
def new_object(
object_id = oerp.create(
return oerp.browse(
def map2many(
return [(6, 0, [x.id for x in browse_objs])]
# create a partner with its one2many and many2many records
partner = new_object(
print partner.name
partner.ref = "12345678"
addresses = []
addresses.
addresses.
partner.address = map2many(addresses)
categories = []
categories.
categories.
partner.category_id = map2many(
oerp.write_
# update many2many record to use only one category
partner = oerp.browse(
cat1 = oerp.browse(
partner.category_id = map2many([cat1])
oerp.write_
Please, think about it,
Manu.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- OERPLib Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Manu
- Solved:
- Last query:
- Last reply: