Skip to Content
Menu
This question has been flagged
1 Reply
2422 Views

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>
```
Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

Related Posts Replies Views Activity
2
Sep 21
7018
0
Mar 21
1370
1
Aug 24
1526
4
May 24
10077
1
Apr 24
1566