Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Field 'name' does not exist - Odoo 9

By
Azzedine
on 5/12/16, 8:25 AM 1,171 views

Hello :)

I'm trying to add a new module on Odoo 9 following instructions of this (cool ?) tutorial :

http://fr.slideshare.net/TarunBehal1/odoo-open-erp-creating-a-module-37569034

but i'm getting "ParseError: "Invalid view definition Error details Field `name` " when installing the module on odoo ? any idea ?

Pic_Import.py

from openerp.osv import osv

from openerp.osv import fields

class Pic_Import(osv.osv):

_name = 'pic.import'

_description = "Module test pour importer une images"

_columns = {

'subject' : fields.char('Subject',size=128,required=True),

'date' : fields.date('Date',required=True),

'note' : fields.text('Notes'),

'amount': fields.float('Amount',required=True),

'type':fields.selection([

('transport','Transport'),

('household','Household'),

('personal','Personal'),

],

'Type',required=True),

}

__openerp__.py


 # -*- coding: utf-8 -*-

{

'name': 'Picture Importer',

'summary': "Module de test",

'description': """Chargement d'une image ?""",

'author': "Batman",

'website': "localhost:8069",

# Categories can be used to filter modules in modules listing

# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml

# for the full list

'category': 'Test',

'version': '0.1',

# any module necessary for this one to work correctly

'depends': ['base'],

# always loaded

'data': [

# 'security/ir.model.access.csv',

'views/Pic_Import_view.xml',

],

# only loaded in demonstration mode

'images': [],

'test':[],

'installable': True,

}

  

__init__.py

# -*- coding: utf-8 -*-
import Pic_Import

Pic_Import_view.xml

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

<openerp>

<data>

<!-- FORM -->

<record id="view_pic_importer_form" model="ir.ui.view">

<field name="name">pic.import.form.view</field>

<field name="model">pic.import</field>

<field name="arch" type="xml">

<form string="Picture importer" version="1.0">

<group>

<field name="name"/>

<field name="date"/>

<field name="type"/>

<field name="note"/>

</group>

</form>

</field>

</record>

<!-- View -->

<record id="view_pic_importer_tree" model="ir.ui.view">

<field name="name">pic.import.tree</field>

<field name="model">pic.import</field>

<field name ="arch" type="xml">

<tree string="Import pic">

<field name="name"/>

<field name="date"/>

<field name ="type"/>

</tree>

</field>

</record>

<!-- ACTION -->

<record id="action_pic_import" model="ir.actions.act_window">

<field name="name">Import</field>

<field name="res_model">pic.import</field>

<field name="view_type">form</field>

<field name="view_mode">tree,form</field>

<field name="search_view_id" eval="False"/>

<field name="context">{}</field>

<field name="help">Import new picture</field>

</record>

<!--Menu-->

<menuitem name="Picture Importer" id = "base.pic_import_root" sequence="60"/>

<menuitem id="menu_import_pic_root" name="Picture importer" parent="base.pic_import_root" sequence="1"/>

<menuitem action="action_pic_import" id="menu_action_pic_import" parent="menu_import_pic_root" sequence="20"/>

</data>

</openerp>

1

Yenthe

--Yenthe--
6676
| 7 7 8
Turnhout, Belgium
--Yenthe--

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

Yenthe
On 5/12/16, 8:33 AM

Hi Azzedine,

When you look at your Python code you have a model named 'pic.import' but on this model you have no field with the name 'name':

class Pic_import(osv.osv):
    _name = 'pic.import'

This created your model name but in the XML code you have this line:

<field name="name"/>

So you're calling the field 'name' on the model 'pic.import' while you don't have this field. Simply add one line to the colums for the field 'name':

_columns = {

'subject' : fields.char('Subject',size=128,required=True), 'name': fields.Char('Name'), }

This will add the field to the model and your view will not crash anymore.

Yenthe

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 5/12/16, 8:25 AM
Seen: 1171 times
Last updated: 5/12/16, 2:14 PM