I am trying to limit the BOMs that appear in a list based on products in a certain location, i have one function that executes sql to pull values from the Bom and Bom_line tables to create a dictionary of related values. Then I compare this list with products in a location called WIP. and from that get a list of BOMs that should be available since their parts are available in the production environment.
I have all of the code written my last step is to limit the BOM's that appear using a domain search for approved BOMS. my char value appears correctly.
Code is below where enabled_boms appears as the char field correctly displaying [('id', '=', 9)] in my app , which is correct, but appears as none.none when i print it in python. and then gives me Traceback:
Error: Expected attribute name, got (constant)
enabled_boms = fields.Char(compute='_compute_BOM_components')
print(enabled_boms)
BOM_production = fields.Many2one("mrp.bom", domain=enabled_boms)
I'm not sure how to get the returned value for enabled_boms to populate the domains section.
my code runs if I hard code the
BOM_production = fields.Many2one('mrp.bom', domain = [('id', '=', 9)])
happy to share all of the code with whoever wants to take a look, just dont see value in posting it all here.
seems you need to return based on some field values selected ? see: https://www.youtube.com/watch?v=dq5Vtj_pwuI&t=819s
Thanks @niyas, i followed the video and got it working with a hard coded domain however my dynamic domain causes this error.
Error:
Traceback:
TypeError: CreateListFromArrayLike called on non-object
at http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:360:20
at Function._.each._.forEach (http://localhost:8069/web/content/555-da63a9d/web.assets_common.js:108:558)
at _.<computed> [as each] (http://localhost:8069/web/content/555-da63a9d/web.assets_common.js:165:526)
at eval_domains (http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:357:265)
at Object.pyeval [as eval] (http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:382:24)
at OdooClass.stringToArray (http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:324:845)
at Class._getDomain (http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:1504:167)
at Class._search (http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:1097:607)
at http://localhost:8069/web/content/556-d02db81/web.assets_backend.js:1089:260
at Function._.each._.forEach (http://localhost:8069/web/content/555-da63a9d/web.assets_common.js:108:558)
I assume this is a formatting related issue or the value is not being passed to it as it says non-object.. Not sure what to do i have spent hours on this problem.
Did you find an answer for that ,because i have the same issue