Odoo Help

0

0
3 Answers
0
Manu Prabhakar
26/06/19 03:17

Hi

Try this...



def _menu(self):

res = {}
res['domain'] = {'field_name': [('id', '=', value)]}
return res

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)

0
Avatar

Usman Farzand

--Usman Farzand--

5067
| 6 3 7
Faisalabad, Paquistão
--Usman Farzand--

I Love Programming ....


E-Mail At

usman_farzand@outlook.com

Usman Farzand
25/06/19 09:31

if you want to change your domain base on product_id(many2one) field then please use on change method for it base on Product_id(many2one)

then you can easily return domain like 

res = {}
res['domain'] = {'field_name': [('id', '=', value)]}
return res
0
Avatar

Rishan Malaka

--Rishan Malaka--
--Rishan Malaka--

Software Engineer(Odoo) - Capital TRUST Information Technologies (Pvt) Ltd.

Rishan Malaka
25/06/19 09:16
1 Comment
mitra safari
26/06/19 03:30

hi @Rishan Malaka

thanks for your reply .i write on_change function as you said but it did not work can you help me?

@api.onchange('date')

def _onchange_menu(self):

res={}

self.write({'test1':'ok'})

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 d in range (0,len(day)):

if day[d] == day_name:

menu = self.env['lunch.menu'].search([('day' ,'=' ,day_name)]).mapped('product.id')

res['doamin']={'product_c':[('id','in',menu.ids)]}

return res

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now