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

two fields many2one both are different form form-1 1.plan_category plan-1 plan-2 form-2 2.sub_pan sub plan-1 sub plan-2

in third form select plan category in onchange event on display subplan

아바타
취소
베스트 답변

Hi,

Other than returning domain in onchange method, you can use the web domain field module from oca for the same:  Web Domain Field


See this: Return Dynamic Domain For Field In Odoo


How to use:

.. code-block:: xml

<field name="product_id_domain" invisible="1"/>
<field name="product_id" domain="product_id_domain"/>


.. code-block:: python

product_id_domain = fields.Char(
compute="_compute_product_id_domain",
readonly=True,
store=False,
)

@api.multi
@api.depends('name')
def _compute_product_id_domain(self):
for rec in self:
rec.product_id_domain = json.dumps(
[('type', '=', 'product'), ('name', 'like', rec.name)]
)

Returning domain from the onchange function: How To Give Domain For A Field Based On Another Field

Thanks

아바타
취소
베스트 답변

Hi,

I just understood the title :D,

So, the onchange function can return a domain like:

res = {'domain': {'field_name': [domain like ('id', 'in', list_of_ids)]}}
return res

So every time this function is called you can do your calculation and pass the result to the domain...

I hope this could helps you ...

Regards..

아바타
취소
작성자

thanks sir

베스트 답변

Hi, 

You can watch following video for this:

https://youtu.be/ezH3ql5Dmx4

Thanks

아바타
취소
베스트 답변
Added same code, getting a traceback.

Traceback: TypeError: CreateListFromArrayLike called on non-object at http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:367:20 at _.each._.forEach (http://localhost:8014/web/content/3947-253c74a/web.assets_common.js:108:558) at _. [as each] (http://localhost:8014/web/content/3947-253c74a/web.assets_common.js:165:526) at eval_domains (http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:364:265) at Object.pyeval [as eval] (http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:389:24) at OdooClass.stringToArray (http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:331:147) at Class._getDomain (http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:1523:167) at Class._search (http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:1110:607) at http://localhost:8014/web/content/3571-1e2f158/web.assets_backend.js:1102:260 at _.each._.forEach (http://localhost:8014/web/content/3947-253c74a/web.assets_common.js:108:558)


아바타
취소
관련 게시물 답글 화면 활동
1
10월 23
1852
2
10월 23
2075
2
8월 23
4059
3
10월 22
10831
3
3월 22
37210