コンテンツへスキップ
メニュー
この質問にフラグが付けられました
6 返信
11965 ビュー

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 

  @api.multi

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>

<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"/>

</record>


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

@api.multi

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

<header>

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

</header>

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?

最善の回答

Hello Uppili,


Try below code :-


@api.multi

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,

アバター
破棄
著作者

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')

著作者

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.

著作者

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

最善の回答

You need an auto_refresh solution like:

https://github.com/aek/odoo_public/tree/8.0/addons/solt_autorefresh

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

アバター
破棄
関連投稿 返信 ビュー 活動
1
6月 16
5737
0
8月 20
2530
1
11月 16
14640
0
3月 16
3007
0
8月 17
4103