Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
8492 Lượt xem

Hi all,

I wish to add a custom field on the cron module (a description field, in order to describe the goal of the cron).

I can add the field on the table ir_cron, but when I try to add that field on the view, the error message is :

openerp.addons.base.ir.ir_ui_view: Can't render view for model: ir.cron

Here is the XML code :

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

<openerp>

    <data>

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

             <field name="name">view.ir.cron.extended</field>

             <field name="model">ir.cron</field>

             <field name="inherit_id" ref="base.ir_cron_view"/>

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

                 <xpath expr="/form/sheet/page[@string='Information']/field@name='doall']" position="after">

                     <field name="description" />

                 </xpath>

             </field>

        </record>

     </data>    

</openerp>


Thank you for your help.

Ảnh đại diện
Huỷ bỏ

please give more details about error log for better understanding

Tác giả

Hi, My custom module seems to be very simple: __init__.py (empty) __openerp__.py (depends on base) ir_cron.py (add the field description to the ir.cron entity) ir_cron_view.xml (add the field on the form view) Here is the full stack when I try to install it : 2015-10-27 08:16:44,038 2216 ERROR openerp_bdd openerp.osv.orm: Can't find field 'description' in the following view parts composing the view of object model 'ir.cron': * view.ir.cron.extended Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model 2015-10-27 08:16:44,039 2216 ERROR openerp_bdd openerp.addons.base.ir.ir_ui_view: Can't render view for model: ir.cron Traceback (most recent call last): File "D:\workspace_luna\openerp_server\openerp-7\openerp\addons\base\ir\ir_ui_view.py", line 126, in _check_render_view fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context) File "D:\workspace_luna\openerp_server\openerp-7\openerp\osv\orm.py", line 2260, in fields_view_get xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx) File "D:\workspace_luna\openerp_server\openerp-7\openerp\osv\orm.py", line 1937, in __view_look_dom_arch raise except_orm('View error', msg) except_orm: ('View error', u"Can't find field 'description' in the following view parts composing the view of object model 'ir.cron':\n * view.ir.cron.extended\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model") 2015-10-27 08:16:44,055 2216 ERROR openerp_bdd openerp.tools.convert: Parse error in file:///D:/workspace_luna/git_repos/openerp_addons_spec/isg_ir_cron_extended/view/ir_cron_view.xml:5: view.ir.cron.extended ir.cron Traceback (most recent call last): File "D:\workspace_luna\openerp_server\openerp-7\openerp\tools\convert.py", line 847, in parse self._tags[rec.tag](self.cr, rec, n) File "D:\workspace_luna\openerp_server\openerp-7\openerp\tools\convert.py", line 814, in _tag_record id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context ) File "D:\workspace_luna\openerp_server\openerp-7\openerp\addons\base\ir\ir_model.py", line 963, in _update res_id = model_obj.create(cr, uid, values, context=context) File "D:\workspace_luna\openerp_server\openerp-7\openerp\addons\base\ir\ir_ui_view.py", line 103, in create return super(view, self).create(cr, uid, values, context) File "D:\workspace_luna\openerp_server\openerp-7\openerp\osv\orm.py", line 4470, in create self._validate(cr, user, [id_new], context) File "D:\workspace_luna\openerp_server\openerp-7\openerp\osv\orm.py", line 1544, in _validate raise except_orm('ValidateError', '\n'.join(error_msgs)) except_orm: ('ValidateError', u'Une erreur est apparue lors de la validation du/des champ(s) arch: Invalid XML for View Architecture!') 2015-10-27 08:16:44,058 2216 ERROR openerp_bdd openerp.netsvc: ValidateError Une erreur est apparue lors de la validation du/des champ(s) arch: Invalid XML for View Architecture! Traceback (most recent call last): File "D:\workspace_luna\openerp_server\openerp-7\openerp\netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "D:\workspace_luna\openerp_server\openerp-7\openerp\service\web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "D:\workspace_luna\openerp_server\openerp-7\openerp\osv\osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "D:\workspace_luna\openerp_server\openerp-7\openerp\osv\osv.py", line 144, in wrapper raise except_osv(inst.name, inst.value) except_osv: ('ValidateError', u'Une erreur est apparue lors de la validation du/des champ(s) arch: Invalid XML for View Architecture!') > d:\workspace_luna\openerp_server\openerp-7\openerp\osv\osv.py(144)wrapper() -> raise except_osv(inst.name, inst.value) (Pdb) Cheers.

Tác giả

Sorry for the text formating :-)

Câu trả lời hay nhất

per your description of module structure, __init__.py can NOT be empty, it should contain following line:

import  ir_cron

(add this line to __init__.py, also make sure you restart odoo after this change)

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hi Temur,

You're right ! I've tried to put from . import ir_cron in my __init__.py but the result was the same.

Thank you for your reactivity (again) ! :-)


Ảnh đại diện
Huỷ bỏ

For the "from . import ir_cron" syntax to work, I believe you need to enable absolute imports first, by "from __future__ import absolute_import" and then do your absolute import of "from . import ir_cron".

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 22
2770
3
thg 8 20
27348
2
thg 2 17
2996
0
thg 3 15
4508
0
thg 3 15
2886