콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
21988 화면

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
8723
naked domain set up 해결 완료
3
7월 25
4399
0
5월 25
920
2
3월 24
2167
0
1월 23
1758