Skip to Content
Menu
This question has been flagged

In the res.partner form view of a company, there is a tab named Contacts, in which we can see all the employees who work for that company. If you click on Edit, you will be able to see a X button, and if you click on it, the record of the employee is removed from res.partner. I'd like to add to that button a confirm message. As the attribute confirm does not work in this case (I guess because it only works on status bars), I had to create a wizard to emulate the confirm message.

Everything seems to be OK, but in the wizard, when I click in Confirm, I get a JS error:

Uncaught Record not correctly loaded

And in spite of this error, the record is removed from the database correctly. How can I avoid that? I tried adding the options reload_on_button and always_reload (both True) to the child_ids field (as you may know, this one is the one2many pointing to the employees), but nothing happened.

This is the Confirm wizard button code:

@api.one
def unlink_partner_from_company(self):
     partners = self.env['res.partner'].search([('id', 'in', self.env.context.get('active_ids', []))]
     return partners.unlink()

I've also tried returning this instead of returning the result of the unlink:

     return {
          'type': 'ir.actions.client',
          'tag': 'reload',
     }

But the same error arises. Can anyone help me please?!

Avatar
Discard
Author

I've just checked that it's not a issue of time, because I've added a delay of 20 seconds after the deletion, and then I called again the form with an action window. The error is still there!

Related Posts Replies Views Activity
2
Dec 23
11087
3
Jul 22
20952
2
Jun 21
16960
0
Sep 20
2617
0
May 16
2893