Hi guys, how i can initialize company_id with team_id on crm lead on creat method.
Can someone help me, thank you
Hi guys, how i can initialize company_id with team_id on crm lead on creat method.
Can someone help me, thank you
you need to inherit the model of 'crm.lead' first
after that, let's get into business
regarding the 'company_id',
override the default fields by rewriting them in your inherit model
then add a 'default' attribute to fill the corresponding field with a pre-determined value
as for example:
company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env.company)
there we try getting the currently active company as the default value for 'company_id'
same goes to the 'team_id',
but for this case, it depends on you which record you want to set as the default value, because there is nothing like 'self.env.team'
as for example:
team_id = fields.Many2one('crm.team', string='Sales Team', default=lambda self: self.env['crm.team'].search([], limit=1))
Hope it helps,
please correct me if I did any mistake!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.