[IMP] event, website_event_track: make create of registration and track multi
Purpose is to allow the batch create on those models that may be created in batch, notably through import. LINKS Task ID 2212297 Community PR odoo/odoo#47229
This commit is contained in:
@@ -106,13 +106,13 @@ class EventRegistration(models.Model):
|
||||
# CRUD
|
||||
# ------------------------------------------------------------
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
registration = super(EventRegistration, self).create(vals)
|
||||
if registration._check_auto_confirmation():
|
||||
registration.sudo().action_confirm()
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
registrations = super(EventRegistration, self).create(vals_list)
|
||||
if registrations._check_auto_confirmation():
|
||||
registrations.sudo().action_confirm()
|
||||
|
||||
return registration
|
||||
return registrations
|
||||
|
||||
def write(self, vals):
|
||||
ret = super(EventRegistration, self).write(vals)
|
||||
|
||||
@@ -22,20 +22,22 @@ class EventRegistration(models.Model):
|
||||
action['res_id'] = self.sale_order_id.id
|
||||
return action
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('sale_order_line_id'):
|
||||
so_line_vals = self._synchronize_so_line_values(
|
||||
self.env['sale.order.line'].browse(vals['sale_order_line_id'])
|
||||
)
|
||||
vals.update(so_line_vals)
|
||||
res = super(EventRegistration, self).create(vals)
|
||||
if res.sale_order_id:
|
||||
res.message_post_with_view(
|
||||
'mail.message_origin_link',
|
||||
values={'self': res, 'origin': res.sale_order_id},
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
return res
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if vals.get('sale_order_line_id'):
|
||||
so_line_vals = self._synchronize_so_line_values(
|
||||
self.env['sale.order.line'].browse(vals['sale_order_line_id'])
|
||||
)
|
||||
vals.update(so_line_vals)
|
||||
registrations = super(EventRegistration, self).create(vals)
|
||||
for registration in registrations:
|
||||
if registration.sale_order_id:
|
||||
registration.message_post_with_view(
|
||||
'mail.message_origin_link',
|
||||
values={'self': registration, 'origin': registration.sale_order_id},
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
return registrations
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get('sale_order_line_id'):
|
||||
|
||||
@@ -105,18 +105,19 @@ class Track(models.Model):
|
||||
else:
|
||||
track.date_end = False
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
track = super(Track, self).create(vals)
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
tracks = super(Track, self).create(vals_list)
|
||||
|
||||
track.event_id.message_post_with_view(
|
||||
'website_event_track.event_track_template_new',
|
||||
values={'track': track},
|
||||
subject=track.name,
|
||||
subtype_id=self.env.ref('website_event_track.mt_event_track').id,
|
||||
)
|
||||
for track in tracks:
|
||||
track.event_id.message_post_with_view(
|
||||
'website_event_track.event_track_template_new',
|
||||
values={'track': track},
|
||||
subject=track.name,
|
||||
subtype_id=self.env.ref('website_event_track.mt_event_track').id,
|
||||
)
|
||||
|
||||
return track
|
||||
return tracks
|
||||
|
||||
def write(self, vals):
|
||||
if 'stage_id' in vals and 'kanban_state' not in vals:
|
||||
|
||||
Reference in New Issue
Block a user