Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to display many2one fields within form view

By
xiaolong97427
on 3/19/13, 7:40 AM 3,047 views

Hi,

I have the field:

'merged_porder_id' : fields.many2one('purchase.order', 'purchase_id'),

And display this field with:

<field name="merged_porder_id"/>

How can I tell the system that I want to input several values ? The UI control is a simple Textbox, do the user have to separate the Purchase_id by some separator ? if yes which one ?

May be you need "fields.one2many" ?

Vasiliy Birukov
on 3/20/13, 1:48 AM
1

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 3/20/13, 5:20 AM

If you want to attach more than one purchase order you have to use a field of type many2many or one2many.

The difference is:

  • If you use many2many then every purchase order can be assigned more than once in the field merged_porder_id. A separate relation table is used in the background.
  • If you use one2many then every purchase order can only be assigned to one field merged_porder_id. In this case you also have to create a many2one field in the purchase order for the relation to the model of field merged_porder_id.

Thank you for your comment, makes more clear the way the design the relation. Therefore I added a one2many: 'sourceOfMerged' : fields.many2one('purchase.order', 'purchase_id'). Trying to display it with <field name="syongOne2Many"> <tree string="Notes" editable="bottom"> <field name="name"/> </tree> </field>, I have an error : ProgrammingError: operator does not exist: character varying = integer LINE 1: ...M "purchase_order" WHERE ("purchase_order"."name" in (16)) O...

xiaolong97427
on 3/20/13, 5:45 AM

Full error message: ProgrammingError: operator does not exist: character varying = integer LINE 1: ...M "purchase_order" WHERE ("purchase_order"."name" in (16)) O... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

xiaolong97427
on 3/20/13, 5:46 AM

in model purchase.order you need a many2one field and in your new model needs a one2many field

Andreas Brueckl
on 3/20/13, 5:50 AM

I created both field: one2many and many2one on PurchaseOrder. Andreas you mean I should create another object for instance: MergedFrom, and this object would contains the one2many field ?

xiaolong97427
on 3/20/13, 7:53 AM

See have the relation between purchase.order and purchase.order.line is handled here: http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/view/head:/purchase/purchase.py

Andreas Brueckl
on 3/20/13, 7:55 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/19/13, 7:40 AM
Seen: 3047 times
Last updated: 3/16/15, 8:10 AM