[FIX] base: error in QWeb when a record is empty

When using a many2one widget, in the following scenario:

<h2><span t-field="o.partner_id.parent_id.country_id"/></h2>

If 'parent_id' is an empty recordset, the following error will be
raised:
[...]
    [read] = record.read([field_name])
ValueError: need more than 0 values to unpack

This is because record.read([field_name]) returns an empty list which
cannot be unpacked.

In version 10 this problem is avoided by using recordset but to keep the diff
minmal in v9, only returns empty string as the line below does
`if not read[field_name]: return ''`

Closes #14489
This commit is contained in:
Guewen Baconnier
2016-12-02 13:26:09 +01:00
committed by Martin Trigaux
parent 6e8ee5ee52
commit 9c3c022ffe
+2
View File
@@ -798,6 +798,8 @@ class ManyToOneConverter(osv.AbstractModel):
_inherit = 'ir.qweb.field'
def record_to_html(self, cr, uid, field_name, record, options=None, context=None):
if not record:
return ''
[read] = record.read([field_name])
if not read[field_name]: return ''
_, value = read[field_name]