This question has been flagged
1 Reply
3144 Views

An exception occurred while I'm trying to write my module.

This is a part of my .py file:

class classroom(osv.osv):
    _name = 'course.classroom'
    _description = 'Classrooms'
    columns = {
               'building' : fields.char('Building', size=64, required=True),
               'room_num' : fields.char('Room Number', size=64, required=True),
               'seats' : fields.integer(string='Seats', required=True), }

And this for view.xml file:

<record model="ir.ui.view" id="course_classroom_form">
    <field name="name">Classroom</field>
    <field name="model">course.classroom</field>
    <field name="arch" type="xml">
        <form string="Classroom" >
            <field name="building" />
            <field name="room_num" />
            <field name="seats" />
        </form>
    </field>
</record>

When I install the module, it prompt the message below:

ParseError: "ValidateError The field(s) arch, model failed against a constraint: The model name does not exist or the view architecture cannot be rendered." while parsing file:///D:/Work%20Files/Project%20Files/workspace/openerp-8.0dev-20131208-000101/openerp/addons/course/course_view.xml:5, near <record model="ir.ui.view" id="course_classroom_form"> <field name="name">Classroom</field> <field name="model">course.classroom</field> <field name="arch" type="xml"> <form string="Classroom"> <field name="building"/> <field name="room_num"/> <field name="seats"/> </form> </field> </record>

I couldn't figure it out after spending a lot of time, could anyone help me? Thank u.

Avatar
Discard
Best Answer

Hi,

Try to do the following:

In py file :

class classroom(osv.osv):
    _name = 'course.classroom'
    _description = 'Classrooms'
    _columns = {
               'building' : fields.char('Building', size=64, required=True),
               'room_num' : fields.char('Room Number', size=64, required=True),
               'seats' : fields.integer(string='Seats', required=True), }
classroom()

In xml file:

<record model="ir.ui.view" id="course_classroom_form">
    <field name="name">Classroom</field>
    <field name="model">course.classroom</field>
    <field name="arch" type="xml">
        <form string="Classroom" >
            <field name="building" />
            <field name="room_num" />
            <field name="seats" />
        </form>
    </field>
</record>

You can also refer the following links: http://www.ibcscorp.com/openerp-custom-module-development-quick-start-guide/ or https://doc.openerp.com/v6.1/developer/03_modules_1/ or https://accounts.openerp.com/forum/Help-1/question/16336

Avatar
Discard
Author

Thanks for help, I've added "classroom()" to the py file, but it still prompt the same error. My heart broken T T.

Have you restarted the server? The changes of py file always needs to restart server, and changes in xml file needs to upgrade of module.

Author

maybe I forgot the "_" before "columns", = = what a shame... I'll try again, thank u.

Author

That's it!!! Sorry for wasting your time.And thanks a lot.