+3 votes
61 views
def action_count_student(self):
    return {
        'name': 'action',
        'type': 'ir.actions.act_window',
        'view_mode': 'tree,form,search',
        'res_model': 'registration.student',
        'res_id': self.id,
        }
<div class="oe_button_box" name="button_box"> <button class="oe_stat_button" type="object" name="action_count_student" icon="fa-graduation-cap" > <field name="count" string="Student" widget="statinfo"/> </button> <button class="oe_stat_button" type="object" name="action_count_teacher" icon="fa-teacher" > <field name="count_teacher" string="Teacher" widget="statinfo"/> </button> </div>
in Back-end by (5.3k points)
edited by | 61 views

1 Answer

+3 votes
 you can add domain to filter record in your action
@api.multi  
 def action_count_student(self):
        self.ensure_one()
        return {
            'name': 'action',
            'type': 'ir.actions.act_window',
            'view_mode': 'tree,form', # and remove search because it appears automatically in searchable view like tree view 
            'res_model': 'registration.student',
            # id don't know the name of m2o in student registration is assumed it's school_id
            'domain': [('school_id', '=', self.id)],  
            'res_id': self.id,
            }
by (8.8k points)
202 questions
179 answers
35 comments
180,289 users