Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
20295 มุมมอง

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)


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 23
1794
"Wrong value for %s: %r" % (self, value) แก้ไขแล้ว
2
ต.ค. 23
2039
2
ส.ค. 23
4016
3
ต.ค. 22
10771
3
มี.ค. 22
37151