Reputation: 3897
I'm doing a workflow in a my module, I've declared the workflow xml in my __openerp__
file, did all the button functions, added state
selection field, and also have the statusbar
in my view, this is one of the button functions:
def budget_validate(self,cr, uid, ids, context=None):
if context is None:
context = {}
self.write(cr, uid, ids, {'state': 'validate'}, context=context)
return True
Just one, because no matter which I click, the error is the same, this is my field:
state = fields.Selection([
('draft', 'Draft'),
('confirm', 'Confirm'),
('validate', 'Validate'),
('last', 'Last'),
('current1', 'Current1'),
('current2', 'Current2'),
('current', 'Current'),
('next', 'Next'),
('adjusted', 'Adjusted'),
('done', 'Done'),
], string="State", readonly=True, copy=False)
My view xml:
<record id="view_order_form" model="ir.ui.view">
<field name="name">account.budget.bsi.form</field>
<field name="model">account.budget.bsi</field>
<field name="arch" type="xml">
<form string="Sales Order">
<header>
<button string="Confirm" name="confirm" states="draft" type="object" class="oe_highlight"/>
<button string="Approve" name="validate" states="confirm" type="object" class="oe_highlight"/>
<button string="Last" name="last" states="confirm" type="object" class="oe_highlight"/>
<button string="Current 1" name="current1" states="last" type="object" class="oe_highlight"/>
<button string="Current 2" name="current2" states="current1" type="object" class="oe_highlight"/>
<button string="Current" name="current" states="current2" type="object" class="oe_highlight"/>
<button string="Next" name="next" states="current" type="object" class="oe_highlight"/>
<button string="Adjusted" name="adjusted" states="next" type="object" class="oe_highlight"/>
<button string="Done" name="done" states="adjusted" type="object" class="oe_highlight"/>
<button name="draft" states="cancel" string="Reset to Draft" type="object" class="oe_highlight"/>
<button string="Cancel Budget" name="cancel" states="confirm,validate" type="object" />
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,last,current1,current2,current,next,adjusted,done,cancel" clickable="True"/>
</header> ...
Every time I click on any button it throws me:
Traceback (most recent call last):
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files\Odoo 8.0-20170809\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 948, in call_button
File "C:\Program Files\Odoo 8.0-20170809\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
AttributeError: 'account.budget.bsi' object has no attribute 'validate'
Originally, I've had those buttons as type="workflow"
but in that case the buttons don't do anything. No error whatsoever, but states won't change.
So, any ideas?
Upvotes: 1
Views: 468
Reputation: 3897
This is how I solved it:
@api.one
def budget_validate(self):
self.write({'state': 'validate',})
Leave the select
field as it is, and leave the buttons as objects on xml view.
Upvotes: 1