This question has been flagged
2 Replies
6049 Views

*__init__.py*

import person

__openerp__.py

{
    'name': 'Person Data Storage',
    'version': '2.0',
    'author': 'Praveen',
    'depends': ['base'],
    'data': [  # data files to load at module install
        'view/menu.xml',  
    ], 
    'demo': [],  # demo data (for unit tests)
} 

person.py

from osv import osv, fields

    class person(osv.Model):
        _name = 'person.person'
        _columns = 
{
                       'name': fields.char('Name', size = 100), 
                       'dob': fields.date('Date of birth'),
                       'father_name': fields.char('Father Name', size = 100),
}
     person()

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
       <menuitem id="person_main_menu" name="Persons"/>



     <record id="person_person_tree_view" model="ir.ui.view">
        <field name="name">person.person.tree</field>
        <field name="model">person.person</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="Persons">
                <field name="name"/>
                <field name="dob"/>
                <field name="father_name"/>
            </tree>
        </field>
    </record>

    <record id="person_person_form_view" model="ir.ui.view">
        <field name="name">person.person.form</field>
        <field name="model">person.person</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Persons">
                <field name="name"/>
                <field name="dob"/>
                <field name="father_name"/>
            </form>
        </field>
    </record>

    <record id="person_normal_action" model="ir.actions.act_window">
        <field name="name">Person</field>
        <field name="res_model">person.person</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem id="section_main_menu" parent="person_main_menu" name = "View"/>
        <menuitem id="person_real_menu" parent="section_main_menu" action="person_normal_action"/>

    </data>
</openerp>
Avatar
Discard
Best Answer

Hey Praveen,

are you working in OpenERP 7 version??, If yes then you should do following changes,

  • Remove <field name="type">form</field> from form view.

  • Replcae <form string="Persons"> with <form string="Persons" version="7.0">

  • Replace from osv import osv, fields with from openerp.osv import osv, fields

from openerp.osv import osv, fields

person.py

class person(osv.Model):
    _name = 'person.person'
    _columns = {
       'name': fields.char('Name', size = 100), 
       'dob': fields.date('Date of birth'),
       'father_name': fields.char('Father Name', size = 100),
}

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <menuitem id="person_main_menu" name="Persons"/>

         <record id="person_person_tree_view" model="ir.ui.view">
            <field name="name">person.person.tree</field>
            <field name="model">person.person</field>
            <field name="arch" type="xml">
                <tree string="Persons">
                    <field name="name"/>
                    <field name="dob"/>
                    <field name="father_name"/>
                </tree>
            </field>
        </record>

        <record id="person_person_form_view" model="ir.ui.view">
            <field name="name">person.person.form</field>
            <field name="model">person.person</field>
            <field name="arch" type="xml">
                <form string="Persons" version="7.0">
                    <group>
                        <field name="name"/>
                        <field name="dob"/>
                        <field name="father_name"/>
                    </group>
               </form>
            </field>
        </record>

        <record id="person_normal_action" model="ir.actions.act_window">
            <field name="name">Person</field>
            <field name="res_model">person.person</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

        <menuitem id="section_main_menu" parent="person_main_menu" name = "View"/>
        <menuitem id="person_real_menu" parent="section_main_menu" action="person_normal_action"/>

    </data>
</openerp>

Hope it work for you.

Avatar
Discard
Author

thanks Ghanshyam Prajapati for your replay the same error occurs after replacing all of the above

Hi Praveen, if my answer solved your problem, then please mark this answer as solved, Thanks.

have you updated your module, after made changes?? please restart your server and then update your module.

Author

same error occurs when me try to install this module after replacing all of the above fields

Hey Praveen I installed your module with my changes and its working fine. See my updated answer

Author

but it doesn't work for me pls share your work files

https://www.dropbox.com/s/fhor2fx6blp8onr/test_module.zip download my module. and please mark my answer as solved if your problem is solved, Thanks. :)

Author

Your module was successfully working. But i didn't find the error in my module. If you know it pls help me.

Best Answer

I have been having that error problem for weeks now. I changed the view as suggested by many still no luck. I even removed openerp and installed the current release. I hope this thread can find solution to my problem.

Avatar
Discard
Author

is it worked for u

No, It did not work. I believe there is something else that is causing this error apart from xml views. example, I managed to install custom hotel management module in earlier opener 7.0 releases without problem. I then removed openerp and reinstalled the stable openerp 7.0 release. now I cannot install the same custom Hotel module because of this error. nothing has change regarding custom Module. this tells me that the problem might be a bug. thus why Ghanshyam Prajapati can install the same module while you cannot

Author

Hi Alec Mouti, I got the solution when me deleted all the data regarding to the current module,delete the module from add ones and restarted the server. Then i copied the module to addone and updated then installed. Its now working. Hopes it will helps you too

I installed the same module with the updated code as a new module.But my issue is the module is not shown in the Installed Modules list though it is there in the addons folder of my openerp 7.What can be done to resolve this issue