[英]error > /home/odoo/odoo-dev/odoo/odoo/api.py(685)call_kw() -> method = getattr(type(model), name) (Pdb) statusbar odoo module
I'm working on a module in odoo that allows the change of states.我正在 odoo 中开发一个允许更改状态的模块。
The data register is ok, but i would like change the state of register.数据寄存器没问题,但我想改变寄存器的状态。
I do not know what's wrong我不知道怎么了
statusbar_model.py statusbar_model.py
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class statusbar(models.Model):
_name = 'statusbar.demo'
name = fields.Char('Name', required=True)
state = fields.Selection([
('concept', 'Concept'),
('started', 'Started'),
('progress', 'In progress'),
('finished', 'Done'),
],default='concept')
@api.multi
def concept_progressbar(self):
self.state = 'concept'
@api.multi
def started_progressbar(self):
self.state = 'started'
@api.multi
def progress_progressbar(self):
self.state = 'progress'
@api.multi
def done_progressbar(self):
self.state = 'finished'enter code here
statusbar_view.xml statusbar_view.xml
<?xml version="1.0"?>
<odoo>
<record model="ir.ui.view" id="view_statusbar_form">
<field name="name">Statusbar</field>
<field name="model">statusbar.demo</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Workflow record">
<header>
<button string="Set to concept" type="object" name="concept_progressbar"
attrs="{'invisible': [('state', '=', 'concept')]}"/>
<button string="Set to started" type="object" name="started_progressbar"
class="oe_highlight" attrs="{'invisible': [('state','!=','concept')]}"/>
<button string="In progress" type="object" name="progress_progressbar"
attrs="{'invisible': [('state','=','progress')]}"/>
<button string="Done" type="object" name="done_progressbar" attrs="
{'invisible': [('state','=','finished')]}"/>
<!--This will create the statusbar, thanks to the widget. -->
<field name="state" widget="statusbar"/>
</header>
<group>
<field name="name"/>
</group>
</form>
</field>
</record>
</odoo>
but for example when I click on set to start但例如当我点击设置开始
get this error:得到这个错误:
> /home/odoo/odoo-dev/odoo/odoo/api.py(685)call_kw()
-> method = getattr(type(model), name)
(Pdb)
any help is welcome thanks in advance欢迎任何帮助提前致谢
You could use in every method:您可以在每种方法中使用:
self.write({'state': 'key_state_selected'})
return True #to update the view
I hope this can be helful for you.我希望这对你有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.