建立角色組分類
理解base.group_user 是內部使用者,是所有內部使用者基礎,base.group_system 也是繼承它
建立角色組
建立模型
class Lift(models.Model):
_name = 'tw.base.lift'
_description = "電梯臺賬"
_order = 'id desc'
uuid = fields.Char(string=u"多方唯一電梯識別")
code = fields.Char(string=u"救援編號", size=100, index=True)
en_code = fields.Char(string=u"加密編號", index=True)
device_code = fields.Char(string=u"裝置程式碼", size=100, index=True)
factory_number = fields.Char(string=u'出廠編號', size=50)
lift_img = fields.Char(u"電梯照片")
use_address = fields.Char(string=u'電梯地址', size=100)
設計模型介面
<record id="tw_base_lift_form" model="ir.ui.view">
<field name="name">tw.base.lift.form</field>
<field name="model">tw.base.lift</field>
<field name="arch" type="xml">
<form string="Tags">
<sheet>
<group>
<group col="4" string="基礎資訊">
<field name="code"/>
<field name="en_code"/>
<field name="device_code"/>
<field name="factory_number"/>
<field name="lift_img"/>
<field name="use_address"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="tw_base_lift_tree" model="ir.ui.view">
<field name="name">tw.base.lift.tree</field>
<field name="model">tw.base.lift</field>
<field name="arch" type="xml">
<tree string="Lifts">
<field name="code"/>
<field name="device_code"/>
<field name="factory_number"/>
<field name="use_address"/>
</tree>
</field>
</record>
<record id="tw_base_lift_search" model="ir.ui.view">
<field name="name">tw.base.lift.search</field>
<field name="model">tw.base.lift</field>
<field name="arch" type="xml">
<search>
<field name="code"/>
<field name="device_code"/>
<field name="factory_number"/>
<field name="use_address"/>
</search>
</field>
</record>
<record id="action_tw_base_lift" model="ir.actions.act_window">
<field name="name">電梯臺賬</field>
<field name="res_model">tw.base.lift</field>
<field name="view_mode">tree,form</field>
</record>
</data>
給內部使用者設定表許可權
access_tw_lift_all,tw_base.tw_lift_all,model_tw_base_lift,base.group_system,1,1,1,1