跳至內容
選單
此問題已被標幟
4 回覆
20072 瀏覽次數

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
1633
2
10月 23
1873
2
8月 23
3771
3
10月 22
10572
3
3月 22
36965