Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
6202 มุมมอง

Hello everybody , i work with openerp v 7 i want to add a field , i've created a module named "champ" that contains the following files :


__init__.py

import test

__openerp__.py

{
"name" : "Test",
"version" : "7",
"author" : "me",
"website" : "",
"category" : "General",
"depends" : ["base"],
"description" : "",
"init_xml" : ["test_view.xml"],
"demo xml" : [],
"update_xml" : [ "test_view.xml"],
"installable": True,
"active": False,
"certificate" : ""
}

test.py

from openerp.osv import fields, osv
class Partner(osv.osv):
    _inherit = 'res.partner'
    _columns = {
        'champ' : fields.char('champ', size=128),
    }

Partner()

test_view.xml

<?xml version="1.0"?>

<openerp>
 <data>

<record model="ir.ui.view" id="view_partner_form2">
    <field name="name">res.partner.form.inherit2</field>
    <field name="model">res.partner</field>
<field name="type">form</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <field name="phone" position="before">
<field name="champ"/>
          </field></field>
</record>

</data>
</openerp>

the module is imported with success , but it is impossible for me to see my new fields (champ) When I redirected to the new module 'test' I can not find the extensions 'pyc' is that it may be my problem of this (compilation)?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Your code is fine. Did you restart your server?

Make following changes in __openerp__.py:

Remove following lines:

"init_xml" : ["test_view.xml"],
"demo xml" : [],
"update_xml" : ["test_view.xml"],
"active": False,

and add "data": ["test_view.xml"],

Restart server and then update module.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Your code is right but <field name="type">form</field> is depricated in 7.0.

อวตาร
ละทิ้ง

It doesn't make any difference. It will only give you warning on console.

ผู้เขียน คำตอบที่ดีที่สุด

Even if I put "data": ["test view.xml"] But the same error appears he can not add the new field. error

(_inherit = 'Res.partner'             ^ IndentationError: expected an indented block)

I do not know for what reason, I have this problem, I use Open ERP 'Version 7.0-20130305-002149'

อวตาร
ละทิ้ง

You must leave 4 space for indentation.

IndentationError means you have either a mix of tabs and spaces in your code or you missed an indentation level

ผู้เขียน

4 spaces!! this is weird It works perfectly. Thank you

ผู้เขียน

problem solved thank you very much

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 21
7588
1
พ.ย. 24
1545
1
ก.ย. 21
9318
1
ม.ค. 24
16906
1
มี.ค. 15
9819