Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3643 Lượt xem

hello guys i have an issue about record in many2many fields, when on edit mode the record that i selected is appear but when i save it's not visible, when i check the database it stored.. anyone can help me? im using odoo 13

here are my code:

```

    def onchange_postal_code_id(self):
        query = """ 
            select 
                village_id 
            from 
                res_area_villages_rel """
        self._cr_read.execute(query)
        villages = self._cr_read.fetchall()
        villages = [i[0]for i in villages]
        return [('id''not in', villages)]  

    postal_code = fields.Many2many('villages','res_area_villages_rel',
        'area_id','village_id'
        string='Postal Code'
        track_visibility='onchange'
        domain=onchange_postal_code_id,
        required=True 
    )

                    <notebook>
                        <page string="Postal Code">
                            <field name="postal_code" 
                            context="{'postal_code': name}"
                            options="{'no_create': True}" attrs="{'invisible': [('boolean','=',False)]}">
                                <tree string="Postal Code">
                                    <field name="postal_code"/>
                                    <field name="name"/>
                                    <field name="parent_code" string="Districts"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
```
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello rehan,

you can add force save =1 in xml file if the record does not save when click on save button

                       <field name="parent_code" string="Districts" force_save="1" />

Thanks...

For more information Contact us: -  https://kanakinfosystems.com/odoo-development-services

Ảnh đại diện
Huỷ bỏ
Tác giả

hello i've tried this but still my context is clear, it's stored to database but didnt show up in tree view many2many fields

postal_code = fields.Many2many('villages','res_area_villages_rel',

'area_id','village_id',

string='Postal Code',

track_visibility='onchange',

domain=onchange_postal_code_id,

required=True

store = True

)

have you tried like this, including store = true and using force_save=1 in xml

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 21
8604
0
thg 3 21
2281
1
thg 8 24
2706
4
thg 5 24
12563
1
thg 4 24
3196