Skip to Content
Menu
This question has been flagged
2 Replies
2004 Views

Dear All ,

please help out me how i can fill module B dropdown list from module A

please give example with sample code.

 

Avatar
Discard

Thanks Niyas Raphy,


please 1 more thing if i have multiple fields in ModuleA then how i can get all fields in ModuleB ?

please share code.


From: Niyas Raphy <niyasraphyk@gmail.com>
Sent: Wednesday, May 31, 2017 9:51:32 AM
To: Fawad Mazhar
Subject: Re: how populate dropdown list of Module B from Module A field in Odoo 10
 

A new answer on how populate dropdown list of Module B from Module A field in Odoo 10 has been posted. Click here to access the post :

See post

--
Niyas Raphy


Sent by Odoo S.A. using Odoo.

Author Best Answer

Thanks but if i have multiple fields in  ModuleA then how i can get all fields in ModuleB ?


Avatar
Discard

Use One2many instead of Many2one

this link might be helpful to you

https://www.odoo.com/documentation/10.0/howtos/backend.html

Author

My senario is given below please tell me how i get remaining fields flight_No and flight_destination in ModuleB

class ModuleA(models.Model):

_name = 'test.a'

_rec_name = 'flight_name'

flight_name = fields.Char(string="Flight")

flight_No = fields.Char(string="Flight No")

flight_destination = fields.Char(string="Flight destination")

Then in the Model B ,

class ModuleB(models.Model):

_name = 'test.b'

drop_down_field = fields.Many2one('test.a', string="Test")

in model b add :

flight_no = fields.Char(related='drop_down_field.flight_No', string='your string')

flight_destination = fields.Char(related='drop_down_field.flight_destination', string='your string')

Best Answer

Hi,  Try as in the below code

class ModuleA(models.Model):
_name = 'test.a'

_rec_name = 'flight_name'
flight_name = fields.Char(string="Flight")


Then in  the Model B ,

class ModuleB(models.Model):
_name = 'test.b'

drop_down_field = fields.Many2one('test.a', string="Test")

Avatar
Discard