Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
21954 Vues

Hi again,

I need do a filter in a selection field, this is the code:

'wpartner_id': fields.related('incidencia_id', 'partner_id', type="many2one", relation="res.partner", string="Cliente", store=False),
'presupuesto': fields.many2one('sale.order', 'Presupuesto', ondelete='cascade', domain=[('partner_id', '=', wpartner_id)]),

This return this error:

'presupuesto': fields.many2one('sale.order', 'Presupuesto', ondelete='cascade', domain=[('partner_id', '=', wpartner_id)]),
NameError: name 'wpartner_id' is not defined

I need some help to solve it, please

Thanks

Avatar
Ignorer
Meilleure réponse

Hi Francisco Martínez,

Replace

domain=[('partner_id', '=', wpartner_id)]

with

domain="[('partner_id', '=', wpartner_id)]"

Try Following,

'presupuesto': fields.many2one('sale.order', 'Presupuesto', ondelete='cascade', domain="[('partner_id', '=', wpartner_id)]"),

or put this domain in 'presupuesto' field of xml file

<field name="presupuesto"  domain="[('partner_id', '=', wpartner_id)]"/>

Hope it work for you.

Avatar
Ignorer
Auteur

With quotes returns no errors, but neither returns any data. Quotation marks are used only on the view.

Auteur

now, i apply the domain at the view, and it works fine! so only in existents records when wpartner_id is filled. how can i get wpartner_id default value? for new records.

Auteur

<field name="wpartner_id" readonly="1" invisible="true"/> <field name="presupuesto" domain="[('partner_id','=',wpartner_id)]" on_change="onchange_presupuesto(presupuesto)"/>

Hi Francisco, If your problem is solved, then please mark this answer as solved. thanks

Solution for view worked for me but at class field level it didn't work....Thanks for solution

Meilleure réponse

You can not filter a domain with respect to a non-stored field.

Change the definition of wpartner_id to:

'wpartner_id': fields.related('incidencia_id', 'partner_id', type="many2one", relation="res.partner", string="Cliente", store=True),
Avatar
Ignorer
Auteur Meilleure réponse

thanks for your reply,

Doesn't works with this change.

returned the same error:

'presupuesto': fields.many2one('sale.order', 'Presupuesto', ondelete='cascade', domain=[('partner_id', '=', wpartner_id)]),
NameError: name 'wpartner_id' is not defined

Thx.

Avatar
Ignorer

I recommend making this a comment to my answer, not a new answer. Anyway, are you having this error when starting the server or when opening a view?

Auteur

Thx, I get this error when starting the server. (Web Client OpenERP 7)

Auteur

now, i apply the domain at the view, and it works fine! so only in existents records when wpartner_id is filled. how can i get wpartner_id default value? for new records.

Auteur

<field name="wpartner_id" readonly="1" invisible="true"/> <field name="presupuesto" domain="[('partner_id','=',wpartner_id)]" on_change="onchange_presupuesto(presupuesto)"/>

Publications associées Réponses Vues Activité
3
déc. 19
8647
3
juil. 25
4270
0
mai 25
864
2
mars 24
2134
0
janv. 23
1731