コンテンツへスキップ
メニュー
この質問にフラグが付けられました
4 返信
8488 ビュー

Hello,

I have 2 fields like this:


'field1': fields.many2many('res.country'),
'field2': fields.many2many('res.country'),


Now when I put data in the first field and I save that, it puts automatic the same value in the second field. Why is that so?

How Can I fix this issue?


I want that the user can handle the two fields seperate. 

Thank You


アバター
破棄
最善の回答

You need to define relation tables or its ids, because many2many field creates one new table in your database. That joints the model together. So,

try like this,

'field1': fields.many2many('res.country','rel_country_table1','current_model_id1','country_model_id1'),
'field2': fields.many2many('res.country','rel_country_table2','current_model_id2','country_model_id2'),

In this example this will create two new tables in your database.

that is rel_country_table1 and rel_country_table2 with two columns 'current_model_id','country_model_id'

アバター
破棄
著作者

ProgrammingError: column rel_country_table2.country_model_id2 does not exist

LINE 1: SELECT rel_country_table2.country_model_id2, rel_country_tab...

著作者

It's not working, I really don't know how I can fix that.

You just need to remove your old database and try with new one.

最善の回答

Hello

you can use second syntax of Many2many field

1> field_ids = fields.Many2many('<<model.name>>')

2> field1_ids = fields.Many2many('<<model.Name>>','table_name', 'column1','other_col_name') 

アバター
破棄
著作者

And what we put in those relation, column1 and column2?

著作者

this is not working with your solution!!!

field1_ids = fields.Many2many('<<model.Name>>','table_name', 'column1','other_col_name')

try this

in relation field you can specify the new table name

in column1 and column2 field you can specify the name of colums

after that you can show this table in database with named as you pass name in second parameter with two colums that specified in third and fourth parameter

関連投稿 返信 ビュー 活動
1
6月 16
3253
1
5月 17
5193
1
3月 16
22232
5
3月 16
10196
3
5月 24
15108