Hi, i'm beginer in odoo. would you please give an example or tutorial how to add some custom one2many field in any object (for example in sale form)?
many thanks for the answer.
*i'm sorry for my terrible english. :)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi, i'm beginer in odoo. would you please give an example or tutorial how to add some custom one2many field in any object (for example in sale form)?
many thanks for the answer.
*i'm sorry for my terrible english. :)
here is official documentation for fields: https://www.odoo.com/documentation/8.0/reference/orm.html#fields
thanks for the fast reply...
here is my code:
<script type="text/javascript"> from openerp import models, fields, api class my_sites(models.Model): _name = 'stock.site' sitecode = fields.Char(string="Site", size=30, required=True) name = fields.Char(string="Description", size=60) warehouse_id = fields.Many2One('stock.warehouse', ondelete = 'cascade', string = 'Warehouse') class my_warehouse(models.Model): _inherit = 'stock.warehouse' site = fields.One2Many('stock.site', 'site_id', string = 'Site') </script>
and here is my xml file:
<script type="text/javascript"> <openerp> <data> <record model="ir.ui.view" id="site_tree_view"> <field name="name">my.site.view</field> <field name="model">my.site</field> <field name="arch" type="xml"> <tree string="Sites"> <field name="sitecode"/> <field name="name"/> </tree> </field> </record> <record model="ir.ui.view" id="site_form_view"> <field name="name">my.site.form</field> <field name="model">my.site</field> <field name="arch" type="xml"> <form string="Site"> <sheet> <group> <field name="sitecode"/> <field name="name"/> </group> </sheet> </form> </field> </record> <record id="my_warehouse_site_inherit" model="ir.ui.view"> <field name="name">stock.warehouse.inherit</field> <field name="model">stock.warehouse</field> <field name="inherit_id" ref="stock.view_warehouse"/> <field name="arch" type="xml"> <xpath expr="//field[@name='code']" position="after"> <field name="sitecode"/> <field name="name"/> </xpath> </field> </record> </data> </openerp> </script>
when i install it, i got error:
Internal server error:
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
here is the log file:
2015-08-24 14:35:53,572 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:35:53,605 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.03s, 0 queries 2015-08-24 14:35:53,737 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:35:53,786 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:35:53] "GET / HTTP/1.1" 500 - 2015-08-24 14:35:53,825 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:35:53,878 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:35:53,898 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.02s, 0 queries 2015-08-24 14:35:53,941 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:35:53,953 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:35:53] "GET /favicon.ico HTTP/1.1" 500 - 2015-08-24 14:35:53,966 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:37:08,298 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:37:08,309 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries 2015-08-24 14:37:08,344 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:37:08,355 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:37:08] "GET /web? HTTP/1.1" 500 - 2015-08-24 14:37:08,368 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:37:08,542 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:37:08,551 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries 2015-08-24 14:37:08,586 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:37:08,601 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:37:08] "GET /favicon.ico HTTP/1.1" 500 - 2015-08-24 14:37:08,609 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:37:19,302 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:37:19,325 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.02s, 0 queries 2015-08-24 14:37:19,361 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:37:19,368 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:37:19] "GET /web/database/selector HTTP/1.1" 500 - 2015-08-24 14:37:19,385 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:37:19,546 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:37:19,569 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.02s, 0 queries 2015-08-24 14:37:19,658 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:37:19,671 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:37:19] "GET /favicon.ico HTTP/1.1" 500 - 2015-08-24 14:37:19,680 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:37:25,289 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:37:25,302 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries 2015-08-24 14:37:25,342 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:37:25,357 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:37:25] "GET /web/database/selector HTTP/1.1" 500 - 2015-08-24 14:37:25,371 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template' 2015-08-24 14:37:25,686 2128 INFO odoo openerp.modules.loading: loading 1 modules... 2015-08-24 14:37:25,701 2128 INFO odoo openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries 2015-08-24 14:37:25,733 2128 INFO odoo openerp.modules.loading: loading 39 modules... 2015-08-24 14:37:25,749 2128 INFO odoo werkzeug: 127.0.0.1 - - [24/Aug/2015 14:37:25] "GET /favicon.ico HTTP/1.1" 500 - 2015-08-24 14:37:25,749 2128 ERROR odoo werkzeug: Error on request: Traceback (most recent call last): File "werkzeug\serving.py", line 177, in run_wsgi File "werkzeug\serving.py", line 165, in execute File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\server.py", line 290, in app return self.app(e, s) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\service\wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1290, in __call__ return self.dispatch(environ, start_response) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1264, in __call__ return self.app(environ, start_wrapped) File "werkzeug\wsgi.py", line 579, in __call__ File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 1426, in dispatch ir_http = request.registry['ir.http'] File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\http.py", line 346, in registry return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 339, in get update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 370, in new openerp.modules.load_modules(registry._db, force_demo, status, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 351, in load_modules force, status, report, loaded_modules, update_module) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 255, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\loading.py", line 152, in load_module_graph models = registry.load(cr, package) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 163, in load model = cls._build_model(self, cr) File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\models.py", line 596, in _build_model original_module = pool[name]._original_module if name in parents else cls._module File "C:\Program Files (x86)\Odoo 8.0-20150723\server\openerp\modules\registry.py", line 102, in __getitem__ return self.models[model_name] KeyError: 'product.template'
what shoud i do? please help me to resolve this problem.
thanks...
Regards,
Pamungkas
it's not correct to use <script type="text/javascript"> in odoo module, as you're using... you should put python code in python files (with .py extension) and xml code in xml files... also you should follow directory structure and create __odoo__.py manifiest as well.
Because someone undervoted my answer, I want to try and improve it:
If you want to add new one to many field 'others' to you model 'module.model' using code, you should create a many2one field to the table you want to link to, if that table doesn't already have it. Let's call the link table 'module.other'.
If you already have many2one field in the other table (where you want to have one2many) go to step 2.
(At database level, one2many does not exist, it is a reference to many2one field in the other table. )
Step 1:
Create many2one field in 'module.other':
- Create a new file module_other.py
- into this file write:
Old api:
from openerp.osv import fields, osv
class module_other(osv.osv):
_inherit = 'module.other'
_colums = {
'model_id': fields.many2one('module.model', 'Model', required=True),
}
New api:
from openerp import models, fields, api
class module_other(models.Model):
_inherit = 'module.other'
_colums = {
'model_id': fields.Many2one('module.model', string='Model')
}
Step 2:
Create one2many field in 'module.model':
- Create a new file module_model.py
- into this file write:
Old api:
from openerp.osv import fields, osv
class module_model(osv.osv):
_inherit = 'module.model'
_colums = {
'others': fields.one2many('module.other', 'model_id', 'Others'),
}
New api:
from openerp import models, fields, api
class module_other(models.Model):
_inherit = 'module.other'
_colums = {
'others': fields.One2many('module.other', 'model_id', string='Others') ,
}
Note that in code I did add:
_inherit = 'module.other'
_inherit = 'module.model'
This line should be added only if you are adding custom field to existing model.
Step 3:
Add field to the view. In new file called module_model_view.xml write:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_module_model_form" model="ir.ui.view">
<field name="name">Add custom one2many</field>
<field name="model">module.model</field>
<field name="inherit_id" ref="module.old_view_name"/>
<field name="arch" type="xml">
<field name="existing_field" position="after">
<field name="others" />
</field>
</field>
</record>
</data>
</openerp>
This is the case of adding the field to an existing view.
http://maheshwarimayur.blogspot.com/2013/02/how-to-add-new-field-on-any-object-in.html
thanks Dani...
You are welcome :)
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Sep 22
|
7896 | ||
|
2
Apr 22
|
2462 | ||
|
0
Jul 21
|
5326 | ||
|
1
Mar 21
|
3344 | ||
|
5
Aug 20
|
16305 |
it's recommended to use github version of odoo for development purposes, follow install from github. follow "Source Install" section here
as operation system, it's recommended to use Ubuntu linux, if you can use it. if not, then windows is ok also...
we do everything through modules in odoo. so good starting point for you should be the module tutorial follow it and create some simple module, in order to get familiar with module structure and architecture...
good luck...