I have button method that works to change the state of all records by clicking on it.
But here I have called this method by adding server action in action menu but it is showing error, while similar method works on button finely.
Here Is my Method which use to change the state in my case:
---------------------------------------------------------------------------------------------------------------------------------------------------------
@api.multi
def action_publish_appraisal(self):
print("Method called sucessfully from xml")
state = self.env['hr.appraisal'].search([])
rec = self.env['hr.appraisal.stages'].search([('sequence', '=', 6)])
for record in state:
record.state = rec
return True
Here is My view that add a extra option to Action menu in tree view :
----------------------------------------------------------------------------------------------
<record id="publish_appraisal_action" model="ir.actions.server">
<field name="name">Publish Appraisal</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="kw_appraisal.model_hr_appraisal"/>
<field name="binding_model_id" ref="kw_appraisal.model_hr_appraisal" />
<field name="state">code</field>
<field name="code">action = model.action_publish_appraisal()</field>
</record>
What the error which you got?
Server Action in Odoo: http://learnopenerp.blogspot.com/2020/01/odoo-server-action.html