【问题标题】:Error in creating many2one field with odoo使用 odoo 创建 many2one 字段时出错
【发布时间】:2016-10-26 11:56:35
【问题描述】:

我是 odoo ERP 的新手,我正在尝试创建一个新的学习模块 我需要创建一个从 postgres 数据库中获取值的下拉列表 但我在日志文件中收到以下错误: 'module' 对象没有属性 'many2one'

这是我的 xml 代码:

<!--COSTCENTER-->
<!--Cost Center Form-->
<record model="ir.ui.view" id="cc_form">
    <field name="name">cc.form</field>
    <field name="model">cc.cc</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="Cost Center" version="1.0">

        <group colspan="2" col="2">
            <field name="cc_code" required="1"  widget="selection"/>
            <field name="cc_name"/>
             <field name="notes"/>

        </group>
    </form>
  </field>
</record>

<!--Cost Center Tree-->
<record model="ir.ui.view" id="cc_tree_view">
 <field name="name">cc.tree</field>
 <field name="model">cc.cc</field>
 <field name="type">tree</field>
 <field name="arch" type="xml">
     <tree string="Cost Center">
        <field name="cc_code"/>
        <field name="cc_name"/>
            <field name="notes"/>
          </tree>
   </field>
</record>

<!--Cost Center Action-->
<record id="action_cc" model="ir.actions.act_window">   
<field name="name">Cost Center</field>
<field name="res_model">cc.cc</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<!--EQUIPMENTS-->
<!--Equipments Form-->
<record model="ir.ui.view" id="eqp_form">
<field name="name">eqp.form</field>
<field name="model">eqp.eqp</field>
<field name="type">form</field>
<field name="arch" type="xml">
    <form string="Equipments" version="1.0">

        <group colspan="4" col="4">
            <field name="asset_no" required="1"/>
            <field name="used_by"/>
            <field name="cc_code"/>

        </group>
    </form>
</field>
</record>

<!--Equipments Tree-->
<record model="ir.ui.view" id="eqp_tree_view">
 <field name="name">eqp.tree</field>
 <field name="model">eqp.eqp</field>
 <field name="type">tree</field>
 <field name="arch" type="xml">
     <tree string="Equipments">
        <field name="asset_no" required="1"/>
        <field name="used_by"/>
        <field name="cc_code"/>
          </tree>
 </field>
</record>

python 代码:

from openerp  import models, fields, api, _

class cc(models.Model):

    _name = "cc.cc"
    _description = "Testing cc "

    cc_code = fields.Char(string='Cost Center Code', required=True, index=True, translate=True, help='Requierd to enter cost center code')
    cc_name = fields.Char(string='Cost Center Name', help='Enter cost center name')
    notes = fields.Text(string='Notes', help='Enter notes')

class eqp(models.Model):

    _name = "eqp.eqp"
    _description = "Testing eqp "

    asset_no = fields.Char(string='Asset No')
    used_by = fields.Char(string='Used By')
    cc_code = fields.many2one('cc.cc_code', string='cc_code')

问候,

【问题讨论】:

  • 使用Many2one 而不是many2one

标签: python postgresql odoo-8


【解决方案1】:

你只需要定义:

cc_code = fields.many2one('cc.cc', string='cc_code')

【讨论】:

    【解决方案2】:

    您需要将 many2one 编辑为 Many2one

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多