Odoo Help


[V11] Can't refresh One2many field on popup after wizard action

Benoît Fontaine
on 4/4/18, 3:37 AM 337 views


I added a One2many field on res.partner, that appears on child_ids popup. This field is updated with a wizard action, but there is a refresh issue.

My code :

class Param(models.Model):
_name = 'mymodule.param'
name = fields.Char('Name', required=True)
partner_id = fields.Many2one('res.partner', ondelete='cascade', string='Contact'

class ResPartner(models.Model):
_inherit = 'res.partner'
option = fields.Selection([
('option1', 'Option 1'),
('option2', 'Option 2'),
('option3', 'Option 3),
param_ids = fields.One2many('mymodule.param', 'partner_id', string='Params')

def open_wizard(self):
form_id = self.env.ref('mymodule.wizard', False)
return {
'type': 'ir.actions.act_window',
        'target': 'new',
        'view_mode': 'form',
        'view_type': 'form',
        'views': [(form_id.id, 'form)],
        'view_id': form_id.id,
        'res_model': 'res.partner',
        'res_id': self.id,
        'name': _('Add param'),

    def btn_apply(self):
        self.comment = sef.option
        self.param_ids = [(0, 0, {'name': self.option})]

 And XML:

<record id="wizard" model="ir.ui.view">
    <field name="name">wizard</field>
    <field name="model">res.partner</field>
    <field name="arch" type="xml">
                    <field name="option">
                <button name="btn_apply" type="object" string="Confirm" clas="oe_highlight"/>
                <button special="cancel" string="Cancel" class="oe_link"/>

<record id="view_partner_form_inherit" model="ir.ui.view">
    <field name="name">base.partner.form.mymodule.inherit</field>
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <xpath expr="//notebook//form/sheet" position="before">
                <button name="open_wizard" type="object" string="Open wizard" class="oe_highlight"/>
        <xpath expr="//notebook//form//group/group[2]" position="after">
            <group attrs="{'invisible': [('type', '!=', 'contact')]}">
                <field name="param_ids"/>

After the action, the "comment" field is refreshed, but not the "param_ids" field.

I don't want to reloading all page after the action so I added :

    def btn_apply(self):
        self.comment = self.option
        self.param_ids = [(0, 0, {'name': self.option})]
return {
            'type': 'ir.actions.client',
            'tag': 'refresh',

And Javascript:

odoo.define('mymodule.refresh', function(require) {

    var core = require('web.core')

    function Refresh(parent, action) {
        return {'type': 'ir.actions.act_window_close'}
    core.action_registry.add('refresh', Refresh);

And I don't need to reload the page, but I need to close and reopen the popup to refresh param_ids field.

Any idea about that ?

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/4/18, 3:37 AM
Seen: 337 times
Last updated: 4/4/18, 4:44 AM