我在openerp中创建了一个新的模块名称“活动代码”,我的问题是在视图中我得到所有字段,而且也是随机顺序,
我如何管理视图中的字段,以便它们以定义的顺序出现?
以下是我的代码
from openerp.osv import fields, orm
class activityCode(orm.Model):
_name = 'bbw.activity'
_columns = {
'activitycode' : fields.char('Acitivity code', size=70, required = True, translate=True),
'status' : fields.boolean('Inactive'),
'name' : fields.char('Activity Name',size=70),
'type' : fields.selection([('hourly','Hourly'),('nonhourly','Non-hourly')],'Type'),
'chargestatus' : fields.selection([('charge','Chargeable'),('noncharge','Non-chargeable')],'Status'),
'rate' : fields.selection([('employeebilling','Use Employee Billing Rate'),('customerbilling','Use Customer Billing Rate'),('activityrate','Use Activity Rate')],'Rate'),
'level' : fields.char('Level',size=30),
}
_sql_constraints = [
('name_uniq_1', 'unique(activitycode)', 'Activity code must be unique!')
]
activityCode()
<?xml version="1.0"?>
<openerp>
<data>
<record id="action_bbw_activity" model="ir.actions.act_window">
<field name="name">Activity codes</field>
<field name="res_model">bbw.activity</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="arch" type="xml">
<field name="activitycode" />
<field name="status" />
<field name="name" />
</field>
</record>
<menuitem id="bbw_parent" name="BBW" icon="terp-partner"/>
<menuitem id="menu_office_parent" name="Activity" parent="bbw_parent"></menuitem>
<menuitem action="action_bbw_activity" id="menu_bbw_activity" parent="menu_office_parent" string="Result"/>
</data>
</openerp>
答案 0 :(得分:1)
更新你的xml文件,
<record id="view_bbw_activity" model="ir.ui.view">
<field name="name">Activity codes form</field>
<field name="model">bbw.activity</field>
<field name="arch" type="xml">
<form string="activity codes" version="7.0">
<group>
<field name="activitycode" />
<field name="status" />
<field name="name" />
</group>
</form>
</field>
</record>
<record id="action_bbw_activity" model="ir.actions.act_window">
<field name="name">bbw.activity</field>
<field name="res_model">bbw activity</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_bbw_activity"/>
</record>
<menuitem id="bbw_parent" name="BBW" icon="terp-partner"/>
<menuitem id="menu_office_parent" name="Activity" parent="bbw_parent"/>
<menuitem action="action_bbw_activity" id="menu_bbw_activity" parent="menu_office_parent" string="Result"/>
希望这会对你有所帮助。并查看此链接,其中包含OpenERP的文档相关视图。 https://doc.openerp.com/v6.1/developer/03_modules_3/