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.

2

View error: u"Can't find field 'field_name' [Closed]

By
Atchuthan
on 5/16/13, 3:47 AM 3,911 views

The Question has been closed

by
Atchuthan
on 06/11/2013 07:33:30

Since I am new to OpenERP 7, I stumbled upon the problem of how defined binary field not available in the view providing View Error: u"Can't find field 'photo'.

__init__.py
import sample


sample_view.xml
<?xml version="1.0" encoding="UTF-8"?>
    <openerp>
        <data>
            <record model="ir.ui.view" id="test_tree_view">
                <field name="name">test.tree</field>
                <field name="model">sample</field>
                <field name="type">tree</field>
                <field name="arch" type="xml">
                    <tree string="test">
                        <field name="name" />
                    </tree>
                </field>
            </record>

            <record model="ir.ui.view" id="test_form_view">
                <field name="name">test.form</field>
                <field name="model">sample</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="test">
                        <field name="name" select="1" />
                        <field name="photo" />
                    </form>
                </field>
            </record>

            <record model="ir.actions.act_window" id="action_test_form">
                <field name="name">test</field>
                <field name="res_model">sample</field>
                <field name="view_type">form</field>
                <field name="view_mode">tree,form</field>
            </record>

            <menuitem name="testParent" icon="terp-project" id="testParent_menu" />

            <menuitem name="NotesChild" parent="testParent_menu" id="NotesChild_menu" />

            <menuitem name="Header" parent="NotesChild_menu" id="Header_menu_mainform"
                action="action_test_form" />
        </data>
    </openerp>



sample.py
from osv import fields, osv
import time

class sample(osv.osv):
    _name = "sample"
    _description = "Simple Form"
    _columns = {
             'name':fields.char('Name', size=32, required=True),
             'photo': fields.binary('Photo'),
    }

sample()

in openerp-server log:
  raise except_orm('View error', msg)
except_orm: ('View error', u"Can't find field 'photo' in the following view parts composing the view of object model 'sample':\n * test.form\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model")
2013-05-16 05:42:03,461 3491 ERROR tryme openerp.tools.convert: Parse error in /var/app/openerp/addons/sample/sample_view.xml:7: 
<record model="ir.ui.view" id="test_form_view">
            <field name="name">test.form</field>
            <field name="model">sample</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="test">
                    <field name="name" select="1"/>
                    <field name="photo"/>

                </form>
            </field>
        </record>

got answer means put vote up me...

sridhar
on 5/16/13, 5:19 AM
3
Atchuthan
On 5/31/13, 8:16 AM
Hi,
     I checked on various sites regarding this issue but no correct answer was provided for:      u"Can't find field 'photo' in the following view parts composing the view of object model".

     This error can be removed when the **OpenERP server is restarted**. This is simply because the fields updated are not available at database layer.
0
sridhar
On 5/16/13, 4:25 AM

from tools.translate import _

import the file and execute it should run.

can u please explain this answer.. i cant get your view

Atchuthan
on 5/17/13, 7:55 AM

from tools.translate import _ from osv import fields, osv import time

class sample(osv.osv): _name = "sample" _description = "Simple Form" _columns = { 'name':fields.char('Name', size=32, required=True), 'photo': fields.binary('Photo'), } sample() check this code

sridhar
on 5/17/13, 8:08 AM

when i tried the same code in other Database... binary field worked... Do you know any reason why this happened.

Atchuthan
on 5/20/13, 2:52 AM

from tools.translate import _ this for importing tool, if u put it will work.

sridhar
on 5/20/13, 4:23 AM

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 5/16/13, 3:47 AM
Seen: 3911 times
Last updated: 3/16/15, 8:10 AM