跳至内容
菜单
此问题已终结
3 回复
21918 查看

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

形象
丢弃
最佳答案

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.

编写者

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.

编写者

<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

最佳答案

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),
形象
丢弃
编写者 最佳答案

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?

编写者

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

编写者

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.

编写者

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

相关帖文 回复 查看 活动
3
12月 19
8619
3
7月 25
4146
0
5月 25
838
2
3月 24
2066
0
1月 23
1691