I wanted to replace the kanban image from a company without an image. this is the XML I used. And I'm able to place that image on a form view but it won't work so far on the kanban view.
<field name="name">familae.res.partner.kanban</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="arch" type="xml">
<xpath expr="/kanban/div[@class='oe_kanban_vignette oe_semantic_html_override']" position="replace">
<div>
<a type="open">
<t t-if="record.has_image.raw_value === true">
<img t-att-src="kanban_image('res.partner', 'image_small', record.id.value)" class="oe_kanban_image"/>
</t>
<t t-if="record.has_image.raw_value === false">
<t t-if="record.is_company.raw_value === true">
<img src="mymodule/static/src/img/myimage.png" class="oe_kanban_image"/>
</t>
<t t-if="record.is_company.raw_value === false">
<img t-att-src="'_s' + '/base/static/src/img/avatar.png'" class="oe_kanban_image"/>
</t>
</t>
</a>
</div>
</xpath>
</field>
The logfile gives me this as errormessage:
2014-12-20 08:12:39,369 7031 ERROR openerpfamilae openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Traceback (most recent call last):
File "/home/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/home/openerp/server/openerp/service/web_services.py", line 626, in dispatch
res = fn(db, uid, *params)
File "/home/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/home/openerp/server/openerp/osv/osv.py", line 132, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/openerp/server/openerp/osv/osv.py", line 199, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/openerp/server/openerp/addons/base/module/module.py", line 426, in button_immediate_install
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
File "/home/openerp/server/openerp/addons/base/module/module.py", line 477, in _button_immediate_function
_, pool = pooler.restart_pool(cr.dbname, update_module=True)
File "/home/openerp/server/openerp/pooler.py", line 39, in restart_pool
registry = RegistryManager.new(db_name, force_demo, status, update_module)
File "/home/openerp/server/openerp/modules/registry.py", line 233, in new
openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/home/openerp/server/openerp/modules/loading.py", line 354, in load_modules
loaded_modules, update_module)
File "/home/openerp/server/openerp/modules/loading.py", line 256, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/home/openerp/server/openerp/modules/loading.py", line 187, in load_module_graph
load_update_xml(module_name, idref, mode)
File "/home/openerp/server/openerp/modules/loading.py", line 74, in <lambda>
load_update_xml = lambda *args: _load_data(cr, *args, kind='update_xml')
File "/home/openerp/server/openerp/modules/loading.py", line 124, in _load_data
tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
File "/home/openerp/server/openerp/tools/convert.py", line 959, in convert_xml_import
obj.parse(doc.getroot())
File "/home/openerp/server/openerp/tools/convert.py", line 852, in parse
self._tags[rec.tag](self.cr, rec, n)
File "/home/openerp/server/openerp/tools/convert.py", line 819, 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 "/home/openerp/server/openerp/addons/base/ir/ir_model.py", line 971, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/home/openerp/server/openerp/addons/base/ir/ir_ui_view.py", line 103, in create
return super(view, self).create(cr, uid, values, context)
File "/home/openerp/server/openerp/osv/orm.py", line 4551, in create
self._validate(cr, user, [id_new], context)
File "/home/openerp/server/openerp/osv/orm.py", line 1562, in _validate
raise except_orm('ValidateError', '\n'.join(error_msgs))
except_osv: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
Personally I can't get any information out of it but I hope it will help some of you with defining the problem.
the problem was with the xpath expression
Solution 1: Overriding the the kanban view
<!-- Partner Kanban View -->
<record model="ir.ui.view" id="base.res_partner_kanban_view">
<field name="name">res.partner.kanban</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<kanban>
<field name="color"/>
<field name="name"/>
<field name="title"/>
<field name="email"/>
<field name="parent_id"/>
<field name="is_company"/>
<field name="function"/>
<field name="phone"/>
<field name="street"/>
<field name="street2"/>
<field name="zip"/>
<field name="city"/>
<field name="country_id"/>
<field name="mobile"/>
<field name="state_id"/>
<field name="category_id"/>
<field name="has_image"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_vignette oe_semantic_html_override">
<a type="open">
<t t-if="record.has_image.raw_value === true">
<img t-att-src="kanban_image('res.partner', 'image_small', record.id.value)" class="oe_kanban_image"/>
</t>
<t t-if="record.has_image.raw_value === false">
<t t-if="record.is_company.raw_value === true">
<img t-att-src="mymodule/static/src/img/myimage.png" class="oe_kanban_image"/>
</t>
<t t-if="record.is_company.raw_value === false">
<img t-att-src='_s + "/base/static/src/img/avatar.png"' class="oe_kanban_image"/>
</t>
</t>
</a>
<div class="oe_kanban_details">
<h4 class="oe_partner_heading"><a type="open"><field name="name"/></a></h4>
<div class="oe_kanban_partner_categories"/>
<div class="oe_kanban_partner_links"/>
<ul>
<li t-if="record.parent_id.raw_value and !record.function.raw_value"><field name="parent_id"/></li>
<li t-if="!record.parent_id.raw_value and record.function.raw_value"><field name="function"/></li>
<li t-if="record.parent_id.raw_value and record.function.raw_value"><field name="function"/> at <field name="parent_id"/></li>
<li t-if="record.city.raw_value and !record.country.raw_value"><field name="city"/></li>
<li t-if="!record.city.raw_value and record.country.raw_value"><field name="country"/></li>
<li t-if="record.city.raw_value and record.country.raw_value"><field name="city"/>, <field name="country"/></li>
<li t-if="record.email.raw_value"><a t-attf-href="mailto:#{record.email.raw_value}"><field name="email"/></a></li>
</ul>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
Solution 2: Inherit the kanban view and replace the image using xpath:
<record model="ir.ui.view" id="familae_base_res_partner_kanban_view">
<field name="name">familae.res.partner.kanban</field>
<field name="inherit_id" ref="base.res_partner_kanban_view"/>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<xpath expr='//kanban/templates/t/div/a/t/t[@t-if="record.is_company.raw_value === true"]' position="replace">
<t t-if="record.is_company.raw_value === true">
<img src="pathtotheimage" class="oe_kanban_image"/>
</t>
</xpath>
</field>
</record>