0

I want to create new form view associated to new data model, I create a new menu item "menu1" that has a submenu "menus" and then, I want to customize the action view. This is my code:

My xml file:

My data model:

from openerp.osv import fields, osv

class hr_cutomization(osv.osv):

_inherit = "hr.employee"

_columns = {
  'new_field_ID': fields.char('new filed ID',size=11)
}

_default={
  'new_field_ID':0
}

hr_cutomization()

class hr_newmodel(osv.osv):

_name = "hr.newmodel"

_columns = {
  'field1': fields.char('new filed1',size=11),
  'field2': fields.char('new filed2',size=11)
}

_default={
  'field1':0
}

hr_newmodel()

When I update my module, I got this error:

ParseError: "ValidateError Field(s) arch failed against a constraint: Invalid view definition Error details: Element '

what's doing wrong in my code ?

Jainik Patel
  • 2,284
  • 1
  • 15
  • 35
nayomi
  • 137
  • 1
  • 5
  • 20

2 Answers2

0

Just Update your view action in your xml file some think like this

<record id="new_action" model="ir.actions.act_window">
        <field name="name">New</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">hr.newmodel</field>
        <field name="view_type">form</field>
        <field name="view_mode">form,tree</field>
        <field name="view_id" ref="view_new_form"/>
    </record>

Just update your py file

from openerp.osv import fields, osv

class hr_cutomization(osv.osv):

_inherit = "hr.employee"

_columns = {
  'new_field_ID': fields.char('new filed ID',size=11)
}

_default={
  'new_field_ID':'0'
}

hr_cutomization()

class hr_newmodel(osv.osv):

_name = "hr.newmodel"

_columns = {
  'field1': fields.char('new filed1',size=11),
  'field2': fields.char('new filed2',size=11)
}

_default={
  'field1':'0'
}

hr_newmodel()

In this .py your are assign as char field but you are using _defaults as 0 (as integer) you must have to pass it as character not the integer in your _default attributes.

and you are creating your module in OpenERP 7.0 then the add the new form Attribute as the version="7.0" in your form tag of your view. If it is in odoo 8.0 then it is not needed to do so.

DASADIYA CHAITANYA
  • 2,850
  • 3
  • 18
  • 41
0

I got the same error, and in my case it was because of a wrong indentation in my .py file. Try doing the indentation in the correct way, something like this:

from openerp.osv import fields, osv

class hr_cutomization(osv.osv):

    _inherit = "hr.employee"

    _columns = {
      'new_field_ID': fields.char('new filed ID',size=11)
    }

    _default={
      'new_field_ID':'0'
    }

    hr_cutomization()

class hr_newmodel(osv.osv):

    _name = "hr.newmodel"

    _columns = {
      'field1': fields.char('new filed1',size=11),
      'field2': fields.char('new filed2',size=11)
    }

    _default={
      'field1':'0'
    }

    hr_newmodel()

I think that way could work