Hello Odoo community!
i want filter domain of product_id (many2one field) by some condition ,to do that i write compute field and in xml code , iuse compute field as domain , but it did not work . can anyone help me???
in .py
def _menu(self):
day = self.env['lunch.menu'].search([]).mapped('day')
order_day = self.env['lunch.order'].search([]).mapped('date')
day_name = datetime.datetime.now().strftime('%A')
for rec in self:
for d in range (0,len(day)):
if day[d] == day_name:
menu = self.env['lunch.menu'].search([('day' ,'=' ,day_name)]).mapped('product.id')
rec.product_c = menu
product_c = fields.Char('CProduct', compute = '_menu')
product_id = fields.Many2one('lunch.product', 'Product', required=True)
in XML:
<field name='product_c' >
<field name='product_id' domain='product_c'>