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

Error when edit *xml in my first custom module

By
Hoang Anh
on 11/24/16, 9:39 PM 123 views

my models file

 from openerp import models,fields,api
class Student(models.Model):
     _name="student"
     name = fields.Char('Name',required=True)
     id_student = fields.Char('Student ID',required=True)
     identification = fields.Char('Identification',required=True)
     gender = fields.Selection((('1','Male'),('2','Female'),('3','Other')),'Gender',required=True)
     image = fields.Binary(string="Image")
     birthday = fields.Date('Date of Birth',required=True)
     address = fields.Text()
     phone = fields.Char('Phone number',required=True)
     gpa = fields.Float('Current GPA',required=True)
     classification = fields.Selection((('1','Excellent'),('2','Good'),('3','Average'),('4','Poor')),'Current Classification', compute='set_classification',required=True)
     note = fields.Text()
@api.depends('gpa')
def set_classification(self):
    if self.gpa >= 9.0 :        self.classification = 1
    elif self.gpa < 9 and self.gpa >= 6.5 :
        self.classification = 2
    elif self.gpa < 6.5 and self.gpa >= 5 :
        self.classification = 3
    else :
        self.classification = 4

__openerp__.py

{ 
 "name":"Student Information",
 "category":"ERP Exercise 1",
 "data":['views/student_view.xml',]
}

student_view.xml

<openerp>
     <data>
         <record id="view_student_list" model="ir.ui.view">
             <field name="name">view.student.list</field>
             <field name="model">student</field>
             <field name="arch" type="xml">
                 <tree string="Students">
                     <field name="name"/>
                     <field name="id_student"/>
                     <field name="gender"/>
                     <field name="gpa"/>
                     <field name="classification"/>
                 </tree>
             </field>
         </record>
         <menuitem id="top_menu_students" name="Students" />
         <menuitem id="menu_list_view" name="List view" sequence='5' parent="top_menu_students" action="view_student_list"/>
         <menuitem id="menu_form_view" name="List view" sequence='4' parent="top_menu_students"/>
         <menuitem id="menu_search_view" name="List view" sequence='3' parent="top_menu_students"/>
     </data>
</openerp>

Error

Traceback (most recent call last):
File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 177, in run_wsgi execute(self.server.app)
 File "C:\Python27\lib\site-packages\werkzeug\serving.py", line 165, in execute application_iter = app(environ, start_response)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\service\server.py", line 291, in app return self.app(e, s)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 1297, in __call__ return self.dispatch(environ, start_response)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 1271, in __call__ return self.app(environ, start_wrapped)
 File "C:\Python27\lib\site-packages\werkzeug\wsgi.py", line 588, in __call__ return self.app(environ, start_response) File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 1444, in dispatch result = ir_http._dispatch()
 File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_http.py", line 175, in _dispatch return self._handle_exception(e)
 File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_http.py", line 145, in _handle_exception return request._handle_exception(exception)
File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 673, in _handle_exception return super(HttpRequest, self)._handle_exception(exception)
File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_http.py", line 171, in _dispatch result = request.dispatch()
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 691, in dispatch r = self._call_function(**self.params)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 317, in _call_function return checked_call(self.db, *args, **kwargs)
File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\service\model.py", line 118, in wrapper return f(dbname, *args, **kwargs)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 314, in checked_call return self.endpoint(*a, **kw)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 810, in __call__ return self.method(*args, **kw)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\http.py", line 410, in response_wrap response = f(*args, **kw)
 File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\web\controllers\main.py", line 477, in web_client menu_data = request.registry['ir.ui.menu'].load_menus(request.cr, request.uid, context=request.context)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 268, in wrapper return old_api(self, *args, **kwargs)
 File "<string>", line 2, in load_menus
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\tools\cache.py", line 122, in lookup value = d[key] = self.method(*args, **kwargs)
 File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_ui_menu.py", line 381, in load_menus menu_root_ids = self.get_user_roots(cr, uid, context=context)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 268, in wrapper return old_api(self, *args, **kwargs)
 File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_ui_menu.py", line 355, in get_user_roots return self.search(cr, uid, menu_domain, context=context) File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 268, in wrapper return old_api(self, *args, **kwargs)
 File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_ui_menu.py", line 128, in search result = self._filter_visible_menus(cr, uid, ids, context=context)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 268, in wrapper return old_api(self, *args, **kwargs) File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 399, in old_api result = method(recs, *args, **kwargs)
File "E:\Projects\ERP\Baitap1\odoo-8.0-20161116\openerp\addons\base\ir\ir_ui_menu.py", line 85, in _filter_visible_menus action_menus = menus.filtered('action')
File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5460, in filtered return self.browse([rec.id for rec in self if func(rec)])
File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5459, in <lambda> func = lambda rec: filter(None, rec.mapped(name))
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5435, in mapped recs = recs._mapped_func(operator.itemgetter(name))
File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5415, in _mapped_func vals = [func(rec) for rec in self]
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5653, in __getitem__ return self._fields[key].__get__(self, type(self)) File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\fields.py", line 835, in __get__ self.determine_value(record)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\fields.py", line 928, in determine_value record._prefetch_field(self)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 266, in wrapper return new_api(self, *args, **kwargs) File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 3242, in _prefetch_field result = records.read(list(fnames), load='_classic_write')
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 266, in wrapper return new_api(self, *args, **kwargs)
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 3179, in read self._read_from_database(stored, inherited)
File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 266, in wrapper return new_api(self, *args, **kwargs) File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 3382, in _read_from_database record._cache.update(record._convert_to_cache(vals, validate=False))
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5391, in _convert_to_cache for name, value in values.iteritems()
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\models.py", line 5392, in <dictcomp> if name in fields File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\fields.py", line 1464, in convert_to_cache return record.env[res_model].browse(int(res_id))
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\api.py", line 781, in __getitem__ return self.registry[model_name]._browse(self, ())
 File "E:\Projects\ERP\odoo_8.0.latest\odoo-8.0-20161116\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name]
KeyError: u'ir.actions.view'




4

Jignesh Mehta

--Jignesh Mehta--
2081
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 11/24/16, 11:22 PM

Hello Hoang Anh,


Please refer the following link to learn about creating a module in Odoo:

https://www.odoo.com/documentation/9.0/howtos/backend.html


Hope it will helps you.

Thanks,

0
Hoang Anh
On 11/25/16, 7:07 AM

I'm done, thanks your comments 

0
Prashant Panchal (ppa)
On 11/25/16, 4:48 AM

Hello Hoang,

You called from Menuitem to Action then have to need action: ir.actions.act_window like see below code

 

CODE

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

     <field name="name">view student list</field>

     <field name="type">ir.actions.act_window</field>

    <field name="res_model">student</field>

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

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

</record>

<menuitem id="menu_list_view" name="List view" sequence='5' parent="top_menu_students" action="action_view_student_list"/>

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: 11/24/16, 9:39 PM
Seen: 123 times
Last updated: 11/25/16, 7:07 AM