I try to override a basic workflow of the account.invoice model. I made a module with some a view that add two button, type 'action' calling two methods of a model that inherit of account.invoice. When I presse any of those two buttons odoo rise an error meaning the action isnt defined in account.invoice. I expected to move forward through the pipeline.
here is my model:
from odoo import api,fields,models, _
class Account_invoice_custom(models.Model):
_inherit ='account.invoice'
state = fields.Selection(selection_add([('brocker', 'Brocker'),('furnisher','Furnisher')]))
@api.multi
def action_invoice_brocker(self):
self.state = 'brocker'
return true
@api.multi
def action_invoice_furnisher(self):
self.state = 'furnisher'
return true
Here is my view:
<odoo>
<record model="ir.ui.view" id="view_invoice_form">
<field name="name">account.invoice.form.custom</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<xpath expr="/form/header/field" position="before">
<button name="action_invoice_brocker" states="paid" string="brocker" type="object" class="oe_highlight o_invoice_validate" groups="account.group_account_invoice"/>
</xpath>
<xpath expr="/form/header/field" position="before">
<button name="action_invoice_furnisher" states="paid" string="furnisher" type="object" class="oe_highlight o_invoice_validate" groups="account.group_account_invoice"/>
</xpath>
<xpath expr="/form/header/field[@name='state']" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft,open,paid,brocker,furnisher" />
</xpath>
</field>
</record>
</odoo>