Just return a client reload action at the end of your code:
def your_method(self):
# your code ends with
self.action_archive()
# line to add
return { 'type': 'ir.actions.client', 'tag': 'reload' }
Just return a client reload action at the end of your code:
def your_method(self):
# your code ends with
self.action_archive()
# line to add
return { 'type': 'ir.actions.client', 'tag': 'reload' }
Hello and thank you for your question regarding Odoo's One2many field behavior.
This issue occurs because the Odoo client-side framework does not automatically refresh the view when a record in a One2many field is archived programmatically. To ensure the UI reflects the change, you can trigger a refresh in your code. Here's how you can do it:
1. Use the trigger_up
method to signal the need for a refresh. This method allows you to interact with the Odoo framework to update the UI.
2. In your custom JavaScript widget or action, after archiving the record, call this.trigger_up('reload');
if you're within a widget, or use trigger_up('reload', {keepChanges: true});
for more complex scenarios where you want to keep unsaved changes visible.
3. Ensure that your JavaScript code is properly integrated with Odoo's asset management system to ensure it's loaded and executed as expected.
For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html