Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python odoo中的字段错误(openerp)?_Python_Xml_Odoo_Openerp 7 - Fatal编程技术网

Python odoo中的字段错误(openerp)?

Python odoo中的字段错误(openerp)?,python,xml,odoo,openerp-7,Python,Xml,Odoo,Openerp 7,我是开发模块odoo的初学者,因此在运行我的模块odoo时,我得到以下结果: 模块架构是: init.py(其中我导入module.py) openerp.py(依赖项:Base) _module.py(在这里我得到了主代码,一切正常) xml(主视图与主代码一致,没有问题) 下面是template.xml文件: <?xml version="1.0" encoding="utf-8"?> <openerp> <data>

我是开发模块odoo的初学者,因此在运行我的模块odoo时,我得到以下结果:

模块架构是: init.py(其中我导入module.py) openerp.py(依赖项:Base) _module.py(在这里我得到了主代码,一切正常) xml(主视图与主代码一致,没有问题)

下面是template.xml文件:

    <?xml version="1.0" encoding="utf-8"?>
        <openerp>
        <data>

<menuitem name="Documents" id="menu_list_doc" parent="Doc_Bin" sequence="10" />            

    <!-- Form example --> 
     <record model="ir.ui.view" id="document_form">
      <field name="name">document.form</field>
      <field name="model">document_binov.document_binov</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
       <form string="Documents">
         <field name="titre"/> 
        <field name="description"/> 
         <field name="type"/> 
        </form>
      </field>
    </record> 

    <!--Tree view example -->
    <record model="ir.ui.view" id="document_tree_view">
     <field name="name">document.tree.view</field>
     <field name="model">document_binov.document_binov</field>
     <field name="type">tree</field>
     <field name="arch" type="xml">
      <tree string="Documents">
          <field name="titre"/>   
          <field name="description"/>
          <field name="type" />
      </tree>
    </field>
    </record>   

     <!-- déclaration d'action -->

     <record model="ir.actions.act_window" id="action_document_work"> 
      <field name="name">Liste des documents</field>
      <field name="res_model">document_binov.document_binov</field>
      <field name="view_type">form</field>
      <field name="view_mode">tree,form</field>
      <!-- <field name="help" type="html"/> --> 
      <field name="document_tree_view" ref="document_form"></field>

    </record>


     <!--déclaration menu -->

    <!-- déclaration de menu niveai 1.1(sans action=non cliquable) -->
    <menuitem id="document_menu" name="Liste des documents" parent="menu_list_doc" action="action_document_work" sequence="10"/> 

        </data>
    </openerp>

文件格式
文件
形式
document.tree.view
文件
树
文档列表
文件
形式
树

Python通过每行中选项卡的数量来识别块。在您的情况下,title、description和type在类之外,因此它们没有声明为属性。这就是为什么系统返回title不是有效字段的原因

将python代码更改为

class document_binov(models.Model):
     _name = 'document_binov.document_binov'
     _description = 'visualise les documents'

     titre = fields.Char(string='binov')
     description = fields.Char(string='binov1')
     type = fields.Char(string='binov2')
这意味着您的view.xml中有一个错误。titre字段不存在于python模型字段中

以下是如何在模型中声明字段:

_columns={

            'titre': fields.char('titre' , help="titre"),
     }
有关模块创建的更多信息,请参阅odoo文档:


我希望这会有所帮助。

您需要调整python填充,使字段成为类的一部分。如果你觉得一切都好。尝试重新启动服务器,以便考虑.py修改,然后重新更新模块。这种定义字段的方法是正确的(使用_列)。此外,问题中对它们的定义是正确的。区别在于旧API(openERP 7及以下版本)中使用的第一种方式,以及新API(odoo 8)中使用的第二种方式。@iouhammi你错了,
\u columns
是旧API(
class document_binov(models.Model):
     _name = 'document_binov.document_binov'
     _description = 'visualise les documents'

     titre = fields.Char(string='binov')
     description = fields.Char(string='binov1')
     type = fields.Char(string='binov2')
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Error details:
Field `titre` does not exist
_columns={

            'titre': fields.char('titre' , help="titre"),
     }