Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

problem with a domain (many2one)

By
Francisco Martínez
on 6/24/13, 3:48 PM 7,571 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

2

Ghanshyam Prajapati

--Ghanshyam Prajapati--
1377
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 6/25/13, 3:46 AM

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.

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

Francisco Martínez
on 6/25/13, 5:20 AM

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.

Francisco Martínez
on 6/25/13, 5:35 AM

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

Francisco Martínez
on 6/25/13, 5:38 AM

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

Ghanshyam Prajapati
on 6/25/13, 7:07 AM

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

dirtyHandsPHP
on 9/16/14, 2:07 AM
1
Lucio
On 6/24/13, 4:06 PM

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),
0
Francisco Martínez
On 6/24/13, 4:15 PM

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.

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?

Lucio
on 6/24/13, 4:26 PM

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

Francisco Martínez
on 6/25/13, 5:20 AM

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.

Francisco Martínez
on 6/25/13, 5:37 AM

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

Francisco Martínez
on 6/25/13, 5:38 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/24/13, 3:48 PM
Seen: 7571 times
Last updated: 3/16/15, 8:10 AM