from odoo import models, fields, api, _
class ResUsers(models.Model):
_inherit = "res.users"
def action_button_test(self):
partner_rec = self.env['res.partner'].search([],limit=1)
employee_rec = self.env['hr.employee'].search([],limit=1)
if partner_rec and employee_rec:
if partner_rec.phone == employee_rec.work_phone:
users = self.env['res.users'].search([('active', '=', False)])
for user in users:
user.write({'active': True})
else:
admins = self.env['res.users'].search([('login', '!=', 'admin')])
for admin in admins:
admin.write({'active': False})