[IMP] ir_qweb, ir_ui_view: can use id insead of xml_id; can render ir.ui.view many2one with widget='qweb' in template

bzr revid: chm@openerp.com-20140409104427-ut3r5acavyjsp6bj
This commit is contained in:
chm@openerp.com 2014-04-09 12:44:27 +02:00
parent d69bf32111
commit 4dc3b139f3
6 changed files with 19 additions and 6 deletions

View File

@ -383,6 +383,10 @@ class Contact(orm.AbstractModel):
_name = 'website.qweb.field.contact'
_inherit = ['ir.qweb.field.contact', 'website.qweb.field.many2one']
class QwebView(orm.AbstractModel):
_name = 'website.qweb.field.qweb'
_inherit = ['ir.qweb.field.qweb']
def html_to_text(element):
""" Converts HTML content with HTML-specified line breaks (br, p, div, ...)

View File

@ -128,8 +128,6 @@ class view(osv.osv):
if isinstance(id_or_xml_id, list):
id_or_xml_id = id_or_xml_id[0]
if isinstance(id_or_xml_id, (int, long)):
id_or_xml_id = self.get_view_xmlid(cr, uid, id_or_xml_id)
if not context:
context = {}

View File

@ -221,10 +221,13 @@ class website(osv.osv):
)
def get_template(self, cr, uid, ids, template, context=None):
if '.' not in template:
template = 'website.%s' % template
module, xmlid = template.split('.', 1)
model, view_id = request.registry["ir.model.data"].get_object_reference(cr, uid, module, xmlid)
if isinstance(template, (int, long)):
view_id = template
else:
if '.' not in template:
template = 'website.%s' % template
module, xmlid = template.split('.', 1)
model, view_id = request.registry["ir.model.data"].get_object_reference(cr, uid, module, xmlid)
return self.pool["ir.ui.view"].browse(cr, uid, view_id, context=context)
def _render(self, cr, uid, ids, template, values=None, context=None):

View File

@ -60,6 +60,9 @@ class product_template(osv.Model):
'website_style_ids': fields.many2many('product.style', 'product_website_style_rel', 'product_id', 'style_id', 'Styles'),
'website_sequence': fields.integer('Sequence', help="Determine the display order in the Website E-commerce"),
'website_url': fields.function(_website_url, string="Website url", type="char"),
'test_ir_ui_view': fields.many2one('ir.ui.view', 'test_ir_ui_view'),
}
def __defaults_website_sequence(self, cr, uid, *kwargs):

View File

@ -301,6 +301,10 @@
</div>
</section>
-------------------------------
<div t-field="product.test_ir_ui_view" t-field-options='{ "widget": "qweb" }'/>
-------------------------------
<section class="container oe_website_sale" id="product_detail">
<div class="row">
<div class="col-sm-7 col-md-7 col-lg-7">

View File

@ -74,6 +74,7 @@
domain="[('attribute_id', '=', attribute_id)]"/>
</tree>
</field>
<field name="test_ir_ui_view"/>
</group>
</xpath>