top of page

Odoo - Server Action on Multiple Records

  • Writer: Tek Siong, Hock
    Tek Siong, Hock
  • Mar 2, 2022
  • 1 min read

If you have a requirement to perform certain action on multiple records with a single click, eg, approve multiple payments, then you may consider using the server action.


Select and click "Approve" to approve the multiple vendor payments.



Add the server action "ir.actions.server" model in the xml view, to call action_vendor_payment_approve method in the account.payment class.

<record model="ir.actions.server" id="action_vendor_payment_approve">
    <field name="name">Approve</field>
    <field name="model_id" ref="account.model_account_payment"/>
    <field name="binding_model_id" ref="account.model_account_payment" />
    <field name="state">code</field>
    <field name="code">
        if records:
        action = records.action_vendor_payment_approve()
    </field>
</record>



@api.multi
def action_vendor_payment_approve(self):
    for payment in self:
        payment.write({'state': 'draft'})
        payment.approve_by = self.env.user.id
        payment.approve_date_time = datetime.now()
        payment.post()

Recent Posts

See All
Odoo Performance Profile for debugging

Odoo Performance Profile for debugging, If you are on Odoo 16 and below, and need a good tool for debugging the performance of your Odoo system, this will be the right content for you.

 
 
 

Comments


Subscribe Form

  • facebook
  • linkedin

©2019 by Excelroot Technology Sdn Bhd.

bottom of page