I have many2one field and trying to filter units of measure by name:
product_uom = fields.Many2one('product.uom', 'Unit of Measure', required=True, domain="[('name', 'in', ['m', 'Hour(s)', 'mile(s)', 'Day(s)', 'unit(s)'])]")
xml field:
<field name="product_uom"/>
The problem is that in product_uom dropdown I can't find Unit(s) and Hour(s). What can be wrong with these field names?
P.S. for example if I make simple sql like that in my PgAdmin select * from product_uom where name in ('Unit(s)', 'Hour(s)') everything is fine.
Solved:
Changed my code into:
@api.multi
def get_domain(self):
lang = self.env.context.get('lang')
domain_list = ['m', 'Hour(s)', 'mile(s)', 'Day(s)', 'Unit(s)']
if lang and lang != 'en_US':
result = self.env['ir.translation'].search_read([
('lang', '=', lang),
('src', 'in', domain_list)])
domain_list = [rec['value'] for rec in result]
return [('name', 'in', domain_list)]