
from odoo import api, models


class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.multi
    def schedule_meeting(self):
        old_action = super(ResPartner, self).schedule_meeting()
        new_action = self.env.ref(
            'crm_switzerland.action_calendar_event_partner').read()[0]
        new_action['domain'] = [('partner_ids', 'in', self.ids)]
        new_action['context'] = {
            'default_partner_ids': old_action['context'][
                'default_partner_ids']
        }
        return new_action

    @api.model
    def _notify_prepare_template_context(self, message):
        # modification of context for lang
        message = message.with_context(lang=self.lang)
        return super(ResPartner, self).\
            _notify_prepare_template_context(message)


from odoo import api, models


class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.multi
    def schedule_meeting(self):
        old_action = super(ResPartner, self).schedule_meeting()
        new_action = self.env.ref(
            'crm_switzerland.action_calendar_event_partner').read()[0]
        new_action['domain'] = [('partner_ids', 'in', self.ids)]
        new_action['context'] = {
            'default_partner_ids': old_action['context'][
                'default_partner_ids']
        }
        return new_action

    @api.model
    def _notify_prepare_template_context(self, message):
        # modification of context for lang
        message = message.with_context(lang=self[:1].lang or self.env.lang)
        return super(ResPartner, self).\
            _notify_prepare_template_context(message)

FIX bug when sending notification to multiple partners
FIX bug when sending notification to multiple partners

  
  from odoo import api, models
  
  
  class ResPartner(models.Model):
      _inherit = 'res.partner'
  
      @api.multi
      def schedule_meeting(self):
          old_action = super(ResPartner, self).schedule_meeting()
          new_action = self.env.ref(
              'crm_switzerland.action_calendar_event_partner').read()[0]
          new_action['domain'] = [('partner_ids', 'in', self.ids)]
          new_action['context'] = {
              'default_partner_ids': old_action['context'][
                  'default_partner_ids']
          }
          return new_action
  
      @api.model
      def _notify_prepare_template_context(self, message):
          # modification of context for lang
-         message = message.with_context(lang=self.lang)
+         message = message.with_context(lang=self[:1].lang or self.env.lang)
          return super(ResPartner, self).\
              _notify_prepare_template_context(message)
  
FIX bug when sending notification to multiple partners
## Code Before:

from odoo import api, models


class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.multi
    def schedule_meeting(self):
        old_action = super(ResPartner, self).schedule_meeting()
        new_action = self.env.ref(
            'crm_switzerland.action_calendar_event_partner').read()[0]
        new_action['domain'] = [('partner_ids', 'in', self.ids)]
        new_action['context'] = {
            'default_partner_ids': old_action['context'][
                'default_partner_ids']
        }
        return new_action

    @api.model
    def _notify_prepare_template_context(self, message):
        # modification of context for lang
        message = message.with_context(lang=self.lang)
        return super(ResPartner, self).\
            _notify_prepare_template_context(message)

## Instruction:
FIX bug when sending notification to multiple partners
## Code After:

from odoo import api, models


class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.multi
    def schedule_meeting(self):
        old_action = super(ResPartner, self).schedule_meeting()
        new_action = self.env.ref(
            'crm_switzerland.action_calendar_event_partner').read()[0]
        new_action['domain'] = [('partner_ids', 'in', self.ids)]
        new_action['context'] = {
            'default_partner_ids': old_action['context'][
                'default_partner_ids']
        }
        return new_action

    @api.model
    def _notify_prepare_template_context(self, message):
        # modification of context for lang
        message = message.with_context(lang=self[:1].lang or self.env.lang)
        return super(ResPartner, self).\
            _notify_prepare_template_context(message)
