Hi guys i am new to Odoo, for now i have 2 model as below:
class HumanResource(models.Model):
# _name = 'hr.employee'
_inherit = 'hr.employee'
food_ids = fields.One2many(
'hr.employee.food',
'food_id',
string='Food Cost'
)
class HrFood(models.Model):
_name = "hr.employee.food"
_description = "Food"
food_id = fields.Many2one('hr.employee', string='Food', default=lambda self: self.env['hr.employee'].id)
# food_id = fields.Many2one('hr.employee', 'Food')
# foodtype = ?to?
food_name = fields.Char(
string='Food Name',
help='Please Enter the Food Name'
)
food_category = fields.Selection(
[('breakfast', 'Breakfast'),
('lunch', 'Lunch'),
('teatime', 'Tea Time'),
('dinner', 'Dinner'),
('supper', 'Supper')],
string='Category',
)
food_cost = fields.Float(
string='Food Amount',
digits=(5, 2)
)
I'm inheriting the existing hr.employee model that i have installed in the "Apps".
Below is the inherit view. enter image description here
Then what i want is when i click on "Add an Item", it will automatically fills in the employee ID i have select into the food_id (Many2one fields) in HrFood class.
This is the current result, and the field i've circle up is the field i want to set the default as the employee i've selected. enter image description here
Please help me to solve my question, i am newbee in Odoo. And my Odoo version is Odoo 11, Thanks in advance.