Odoo Help


Refresh tree view of hr_attendance when some record is deleted?

Uppili Arivukkannu
on 6/29/16, 4:17 AM 2,739 views

I want to refresh the tree view of attendance when some record is deleted.

I'm trying unlink() function to refresh.

The .py code is 


def unlink(self):

res = super(hr_attendance, self).unlink()

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

I don't know how to call this in xml

I have tried 

My xml code is


<record id="your_object_auto_refresh_dashboard" model="ir.actions.client">

<field name="name">refresh</field>

<field name="res_model">hr.attendance</field>

<field name="view_type">tree</field>

<field name="view_mode">tree</field>

<field name="tag">10</field>

<field name="usage">menu</field>

<field name="view_id" ref="view_attendance_who"/>


But its is not working.

How can I achieve this?

Is this is possible in odoo( refresh when record is deleted)?

Provide me some examples for this.

The python program I have changed


def unlink(self):

res = super(hr_attendance, self).unlink()

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

When I delete some record from tree view This unlink() method is called but it is not refreshing the tree view.

I have called this function as button in the form view


<button name="unlink" string="Refresh" type="object" />


When I press this button in the form view it refresh the form view and delete the current record in the form view.

But what I want is when I delete the record in tree view the tree view should be refreshed.

How it can be achieved?

Uppili Arivukkannu
on 6/29/16, 7:23 AM

Jignesh Mehta

--Jignesh Mehta--
| 6 5 8
Surat, India
--Jignesh Mehta--

- I have 3+ years of Industry Experience, specializing Odoo Development, Analysis, Customization, Implementation, Integration.
- I have done many Customization modules in Sale, Purchase, Point of Sale, Inventory, CRM and much more. Also Worked in the Odoo Themes like Business Theme or E-Commerce Theme.
- Develop Jewelery Manufacturing process from Scratch. It have more than 10 Department. Develop PDF and Excel reports for this project around 150 per format.

Jignesh Mehta
On 6/29/16, 8:30 AM

Hello Uppili,

Try below code :-


def unlink(self):

    res = super(hr_attendance, self).unlink()

    return self.return_action_hr_attendance()

def return_action_hr_attendance(self):

     model_obj = self.env['ir.model.data']

     data_id = model_obj._get_id('module_name', 'hr_attendance_tree_id')

     view_id = model_obj.browse(data_id).res_id

     return {

          'type': 'ir.actions.client',

          'tag': 'reload',

          'name': _('Attendance'),

          'res_model': 'hr.attendance',

          'view_type': 'tree',

         'view_mode': 'tree',

         'view_id': view_id,

         'target': 'current',

         'nodestroy': True,


Hope it works for you.


Thanks for your reply.

Your code deletes the record but the page is not refreshing.

data_id = model_obj._get_id('hr_attendance', 'view_attendance_who')

Uppili Arivukkannu
on 6/29/16, 8:54 AM

When I give this method in return_action_hr_attendance in button. While I pressing that button the page is getting refreshed but while deleting the page is not refreshing.

Uppili Arivukkannu
on 6/29/16, 9:30 AM

The same is happening in both of our codes. While passing through unlink() the page refresh is not happening.

Uppili Arivukkannu
on 6/29/16, 9:36 AM

Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 6/29/16, 7:07 PM

You need an auto_refresh solution like:


because the unlink will not trigger any reload and even if it does, it will be for the current user, not for others users

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: 6/29/16, 4:17 AM
Seen: 2739 times
Last updated: 6/29/16, 7:07 PM