Skip to Content
Menu
This question has been flagged
3 Replies
20653 Views

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
Discard
Best Answer

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
Discard
Author

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

Author

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.

Author

<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

Best Answer

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
Discard
Author Best Answer

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
Discard

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?

Author

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

Author

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.

Author

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

Related Posts Replies Views Activity
3
Dec 19
7585
2
Mar 24
574
0
Feb 24
1200
0
Jan 23
708
1
Nov 22
1765