Skip to Content
Menú
This question has been flagged
2 Respostes
10693 Vistes

Hello all,

I have a new report defined for the model res.partner to print shipping label.

All these qweb lines print the correct fields content :

<span t-field="o.street"/>
<span t-field="o.zip"/>
<span t-field="o.country_id"/>
<span t-field="o.id"/>


But impossible to use this line :

<span t-field="o.id" t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": false}' />


I get this error with this last line :

Traceback (most recent call last):
  File "/home/odoo/odoo-8.0-20161226/openerp/addons/base/ir/ir_qweb.py", line 600, in to_html
    content = self.record_to_html(cr, uid, field_name, record, options, context=context)
  File "/home/odoo/odoo-8.0-20161226/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/odoo/odoo-8.0-20161226/openerp/addons/base/ir/ir_qweb.py", line 951, in record_to_html
    value_rec = value_rec.sudo().with_context(show_address=True)
AttributeError: 'int' object has no attribute 'sudo'


Why??? How could I use the contact widget in this report?


EDIT #1

Why does this line work :

<address t-field="o.parent_id" t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true, "no_tag_br": true}' />

But not his one???

<address t-field="o.id"  t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true, "no_tag_br": true}' />

I don't want address from the parent... I want address from the current partner...


EDIT #2

I can use this to get what I want. But i feel like a cheater...

<h3 t-field="o.name" />
<span t-if="o.street" t-field="o.street" /><br />
<span t-field="o.street2" /><br />
<span t-field="o.city"/>, <span t-field="o.state_id"/>, <span t-field="o.country_id"/><br />
<span t-field="o.zip"/><br />




Avatar
Descartar
Best Answer

Had the same problem. I browsed for the partner and saved into 'partner'. Then I had to use partner.self. 

<span t-field="partner.self"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
style="border-bottom: 1px solid black; display:inline-block;"/>
Avatar
Descartar
Best Answer

o.id is getting the partner id, that's an integer. You need the record, that's "o". So I guess that  the answer is:

<address t-field="o" t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true, "no_tag_br": true}' />

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de juny 16
10100
1
de maig 22
2873
0
de març 21
3718
5
de set. 20
4914
0
d’oct. 20
7153