[REF] Moved qweb contact from website to base and removed the from_html method (it never worked)
bzr revid: sle@openerp.com-20140324135723-2f8owtcotk3n9jt8
This commit is contained in:
parent
a3be66bb49
commit
48f785d786
|
@ -58,6 +58,7 @@ The kernel of OpenERP, needed for all installation.
|
|||
'ir/osv_memory_autovacuum.xml',
|
||||
'ir/ir_model_report.xml',
|
||||
'ir/ir_logging_view.xml',
|
||||
'ir/ir_qweb.xml',
|
||||
'workflow/workflow_view.xml',
|
||||
'module/module_view.xml',
|
||||
'module/module_data.xml',
|
||||
|
|
|
@ -808,6 +808,38 @@ class RelativeDatetimeConverter(osv.AbstractModel):
|
|||
return babel.dates.format_timedelta(
|
||||
value - reference, add_direction=True, locale=locale)
|
||||
|
||||
|
||||
class Contact(orm.AbstractModel):
|
||||
_name = 'ir.qweb.field.contact'
|
||||
_inherit = 'ir.qweb.field.many2one'
|
||||
|
||||
def record_to_html(self, cr, uid, field_name, record, column, options=None, context=None):
|
||||
opf = options.get('fields') or ["name", "address", "phone", "mobile", "fax", "email"]
|
||||
|
||||
if not getattr(record, field_name):
|
||||
return None
|
||||
|
||||
id = getattr(record, field_name).id
|
||||
field_browse = self.pool[column._obj].browse(cr, openerp.SUPERUSER_ID, id, context={"show_address": True})
|
||||
value = werkzeug.utils.escape( field_browse.name_get()[0][1] )
|
||||
|
||||
val = {
|
||||
'name': value.split("\n")[0],
|
||||
'address': werkzeug.utils.escape("\n".join(value.split("\n")[1:])),
|
||||
'phone': field_browse.phone,
|
||||
'mobile': field_browse.mobile,
|
||||
'fax': field_browse.fax,
|
||||
'city': field_browse.city,
|
||||
'country_id': field_browse.country_id and field_browse.country_id.name_get()[0][1],
|
||||
'email': field_browse.email,
|
||||
'fields': opf,
|
||||
'options': options
|
||||
}
|
||||
|
||||
html = self.pool["ir.ui.view"].render(cr, uid, "base.contact", val, engine='ir.qweb', context=context).decode('utf8')
|
||||
|
||||
return HTMLSafe(html)
|
||||
|
||||
class HTMLSafe(object):
|
||||
""" HTMLSafe string wrapper, Werkzeug's escape() has special handling for
|
||||
objects with a ``__html__`` methods but AFAIK does not provide any such
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<openerp>
|
||||
<data>
|
||||
<template id="contact">
|
||||
<address t-ignore="true" class="mb0" itemscope="itemscope" itemtype="http://schema.org/Organization">
|
||||
<div t-att-class="'name' not in fields and 'css_non_editable_mode_hidden'"><span itemprop="name" t-esc="name"/></div>
|
||||
<div itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress">
|
||||
<div t-if="address and 'address' in fields" class='css_editable_mode_hidden'>
|
||||
<i t-if="not options.get('no_marker')" class='fa fa-map-marker'/> <span itemprop="streetAddress" t-raw="address.replace('\n', options.get('no_tag_br') and ', ' or ('<br/>%s' % ('' if options.get('no_marker') else '&nbsp; &nbsp; ')))"/>
|
||||
</div>
|
||||
<div t-if="city and 'city' in fields" class='css_editable_mode_hidden'>
|
||||
<i t-if="not options.get('no_marker')" class='fa fa-map-marker'/> <span itemprop="addressLocality" t-raw="city"/>, <span itemprop="addressCountry" t-raw="country_id"/>
|
||||
</div>
|
||||
<div t-if="phone and 'phone' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-phone'/> <span itemprop="telephone" t-esc="phone"/></div>
|
||||
<div t-if="mobile and 'mobile' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-mobile-phone'/> <span itemprop="telephone" t-esc="mobile"/></div>
|
||||
<div t-if="fax and 'fax' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-file-text-o'/> <span itemprop="faxNumber" t-esc="fax"/></div>
|
||||
<div t-if="email and 'email' in fields" class='css_editable_mode_hidden'><i t-if="not options.get('no_marker')" class='fa fa-envelope'/> <span itemprop="email" t-esc="email"/></div>
|
||||
</div>
|
||||
</address>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue