Skip to Content
Menu
This question has been flagged
6510 Views

Why context is modified on below code of crm.lead model ? Sales team and stage_id are already comes in vals.

so,what the point to update context here?

@api.model

    def create(self, vals):

        # set up context used to find the lead's sales team which is needed

        # to correctly set the default stage_id

        context = dict(self._context or {})

        if vals.get('type') and not self._context.get('default_type'):

            context['default_type'] = vals.get('type')

        if vals.get('team_id') and not self._context.get('default_team_id'):

            context['default_team_id'] = vals.get('team_id')


        if vals.get('user_id') and 'date_open' not in vals:

            vals['date_open'] = fields.Datetime.now()

        # context: no_log, because subtype already handle this

        return super(Lead, self.with_context(context, mail_create_nolog=True)).create(vals)

Avatar
Discard