We are trying to scrap products but it doesn't list the On Hand location only the default location, I've added a new Many2Many field and trying to limit it there but it's not working. Any ideas on how to get the Stock location field to only show on hand locations on the scrap page?
Here’s what I’ve done:
I created a ManytoMany field in the Scrap model
I put in the related model - stock.location.
I put the product_id, location_id in the dependencies and
I pasted this into the Compute field:
available_location_ids = fields.Many2many(
'stock.location',
compute='_compute_available_locations',
string='Available Locations'
)
<field name="location_id" domain="[('product_id', 'in', available_location_ids)]"/>
it gives a very long error but I think this is the valid part of it:
File "<string>", line 7
<field name="location_id" domain="[('product_id', 'in', available_location_ids)]"/>
^
SyntaxError: invalid syntax
What’s wrong with the last line of code?
I did post this previously (thankyou Akhilesh) but I think I've closed it for commenting by accident.
Odoo v18
Komal, that didn't work, I updated it to this:
available_location_ids = fields.Many2many(
'stock.location',
compute='_compute_available_locations',
string='Available Locations'
)
<field name="available_location_ids" invisible="1"/>
<field name="location_id" domain="[('id', 'in', available_location_ids)]"/>
and got
File "<string>", line 7
<field name="available_location_ids" invisible="1"/>
^
SyntaxError: invalid syntax