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.

1

Please help me to check this code below

By
Binh Nguyen
on 10/22/15, 9:57 AM 483 views

from openerp.osv import fields, osv

class ncb_module_test(osv.osv):

_name = "ncb_module_test"

_description = "Module test cua BINHNC"

_column = {

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

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

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

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

'DVT_TIEN':fields.char('Subject', size=4, required=True),

'LOAI_GD': fields.char('LOAI_GD',size=4, required=True),

}


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

<openerp>

<data>

<!-- Main Menu Related Info -->

<menuitem name="NCB TEST MODULE"

id="base.ncb_test_module"

sequence="61"/>

<!-- Sub Menu Related Info -->

<menuitem id="menu_ncb_test_module_root" name="NCB TEST MODULE"

parent="base.ncb_test_module" sequence="2"/>

<!--Daily Transaction Related info-->

<!--Daily Transaction List View-->

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

<field name="name">ncb_module_test.tree</field>

<field name="model">ncb_module_test</field>

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

<!-- this will be our title of list/tree view -->

<tree string="NCB Module test">

<!-- these will automatically map table headers for our list view -->

<field name="TEN_GD"/>

<field name="NGAY_GD"/>

<field name="LOAI_GD"/>

<field name="SO_TIEN"/>

<field name="DVT_TIEN"/>

</tree>

</field>

</record>

<!--Daily Transaction Form View-->

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

<field name="name">ncb_module_test.form.view</field>

<field name="model">ncb_module_test</field>

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

<!-- this will be our title of list/tree view -->

<form string="NCB Module test" version="7.0">

<group>

<field name="TEN_GD"/>

<field name="NGAY_GD"/>

<field name="LOAI_GD"/>

<field name="SO_TIEN"/>

<field name="DVT_TIEN"/>

<field name="GHI_CHU"/>

</group>

</form>

</field>

</record>

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

<field name="name">NCB Module test</field>

<field name="res_model">ncb_module_test</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">Tao mot module moi de ghi nhan giao dich va doanh thu.</field>

</record>

<menuitem action="action_ncb_test_module"

id="menu_action_ncb_test_module"

parent="menu_ncb_test_module_root" sequence="21"/>

</data>

</openerp>


When i install it got error


Odoo Server Error

Traceback (most recent call last):

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\http.py", line 537, in _handle_exception

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\http.py", line 574, in dispatch

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\http.py", line 310, in _call_function

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\service\model.py", line 113, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\http.py", line 307, in checked_call

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\http.py", line 803, in __call__

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\http.py", line 403, in response_wrap

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\openerp\addons\web\controllers\main.py", line 948, in call_button

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 241, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\openerp\addons\base\module\module.py", line 446, in button_immediate_install

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 241, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\openerp\addons\base\module\module.py", line 494, in _button_immediate_function

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\modules\registry.py", line 370, in new

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\modules\loading.py", line 355, in load_modules

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\modules\loading.py", line 255, in load_marked_modules

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\modules\loading.py", line 176, in load_module_graph

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\modules\loading.py", line 118, in _load_data

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\tools\convert.py", line 901, in convert_file

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\tools\convert.py", line 987, in convert_xml_import

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\tools\convert.py", line 853, in parse

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\tools\convert.py", line 763, in _tag_record

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 241, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\openerp\addons\base\ir\ir_model.py", line 1077, in _update

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 241, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\openerp\addons\base\ir\ir_ui_view.py", line 264, in create

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 241, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 336, in old_api

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\models.py", line 4077, in create

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 239, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 463, in new_api

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\models.py", line 4268, in _create

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\api.py", line 239, in wrapper

File "C:\Program Files (x86)\Odoo 8.0-20150728\server\.\openerp\models.py", line 1271, in _validate_fields

ParseError: "ValidateError

Field(s) `arch` failed against a constraint: Invalid view definition

Error details:

Field `LOAI_GD` does not exist

Error context:

View `ncb_module_test.tree`

[view_id: 1321, xml_id: n/a, model: ncb_module_test, parent_id: n/a]" while parsing file:///C:/Program Files (x86)/Odoo 8.0-20150728/server/openerp/addons/ncb_module_test/ncb_module_test_view.xml:13, near

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

<field name="name">ncb_module_test.tree</field>

<field name="model">ncb_module_test</field>

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

<!-- this will be our title of list/tree view -->

<tree string="NCB Module test">

<!-- these will automatically map table headers for our list view -->

<field name="TEN_GD"/>

<field name="NGAY_GD"/>

<field name="LOAI_GD"/>

<field name="SO_TIEN"/>

<field name="DVT_TIEN"/>

</tree>

</field>

</record>

3

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 10/26/15, 4:28 AM

Hi, You forgot to put an 's'. Its _columns not _column. Please change it and check, it works. Like the following:

_columns = {
'TEN_GD': fields.char('Subject', size=128, required=True),
'NGAY_GD': fields.date('date', required=True),
'GHI_CHU': fields.text('Notes'),
'SO_TIEN': fields.float('Amount', required=True),
'DVT_TIEN':fields.char('Subject', size=4, required=True),
'LOAI_GD': fields.char('LOAI_GD',size=4, required=True)}

thanks for your help Akhil. i appreciate it.

Binh Nguyen
on 10/27/15, 10:50 AM
0

Axel Mendoza

--Axel Mendoza--
10205
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/22/15, 2:04 PM

You need to define your field names in lowercase, define your model as:

rom openerp.osv import fields, osv

class ncb_module_test(osv.osv):

_name = "ncb_module_test"

_description = "Module test cua BINHNC"

_columns = {
   'ten_gd': fields.char('Subject', size=128, required=True),
    'ngay_gd': fields.date('date', required=True),
    'ghi_chu': fields.text('Notes'),
    'so_tien': fields.float('Amount', required=True),
    'dvt_tien':fields.char('Subject', size=4, required=True),
    'loai_gd': fields.char('LOAI_GD',size=4, required=True),
}

Also change the field names in the view

thank you, it's working now

Binh Nguyen
on 10/26/15, 4:20 AM

Hi Axel, there was nothing wrong the case I think. I checked by running his code, only "_columns" was the problem. If you put it as "_column" after changing the case, you will get the same error.

Akhil P Sivan
on 10/26/15, 4:27 AM

Indeed, I did not repare on that, and also don't test it. Thanks, I fixed now

Axel Mendoza
on 10/26/15, 4:29 AM

Hi Alex and Akhil, i change the "_column" -> "columns" and also define these fields name are in lowercase and now it's working. Thank you guys for your strong support.

Binh Nguyen
on 10/26/15, 4:32 AM

Ok binh, keep learning :) thank you

Akhil P Sivan
on 10/26/15, 4:48 AM

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

1 follower(s)

Stats

Asked: 10/22/15, 9:57 AM
Seen: 483 times
Last updated: 10/28/15, 2:41 AM