Hello,
I created a server action to get views through the menu (menuitem). Everything works great, then I clicked a refresh button on the browser (f5) and I saw that the server action didn't call again. Any resolve for this? I also set debug mode in PyCharm to check what is problem, and the method has never called. Work only on the click (menu).
Here is my code.
py method
@api.multi
def action_view_other_persons(self):
action = self.env.ref('open_view_other_person_list_my').read()[0]
other_person_contracts = self.env['hr.contract'].search([('type_id.contract_type', '=', 'other_person')])
other_person_ids = list(set([c.employee_id.id for c in other_person_contracts]))
all_contract_persons = self.env['hr.contract'].search([])
all_contract_person_ids = list(set([c.employee_id.id for c in all_contract_persons]))
no_contract_persons = self.env['hr.employee'].search([('id', 'not in', all_contract_person_ids)])
no_contract_person_ids = list(set([e.id for e in no_contract_persons]))
merged_person_ids = list(set(other_person_ids + no_contract_person_ids))
all_other_persons = self.env['hr.employee'].search([('id', 'in', merged_person_ids)])
all_other_person_ids = list(set([e.id for e in all_other_persons]))
action['domain'] = f"[('id', 'in', {all_other_person_ids})]"
return action
my xml menu action
<!-- Other Persons menu -->
<record model="ir.actions.server" id="action_hr_other_persons">
<field name="name">Other Persons</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_hr_employee"/>
<field name="state">code</field>
<field name="code">
action = model.action_view_other_persons()</field>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
<menuitem
id="hr_menu_other_persons"
name="Other Persons"
action="action_hr_other_persons"
parent="hr.menu_hr_root"
sequence="3"
groups="hr.group_hr_user"/>
and ir.actions.act_window (inherit of original hr action)
this is called in py code.
<record id="open_view_other_person_list_my" model="ir.actions.act_window">
<field name="inherit_id" ref="hr.open_view_employee_list_my"/>
<field name="name">Other Persons</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add a new other person
</p><p>
With just a quick glance on the Odoo employee screen, you
can easily find all the information you need for each person;
contact data, job position, availability, etc.
</p>
</field>
</record>
Results: Images will be deleted after a week.
when I click on menu Other Person (Druge osobe in Croatian) method will be called
https://ibb.co/GQW5R5Z
after I clicked reload (refresh) button the method will not be called and this is the result of that
https://ibb.co/kG6ZrM2