[IMP] website_slides: support batch creation
See merge commit for more details. Task ID-2330149 COM PR odoo/odoo#61246 ENT PR odoo/enterprise#14561
This commit is contained in:
committed by
Thibault Delavallée
parent
0e992e0b72
commit
e2c3ab984d
@@ -33,12 +33,11 @@ class Channel(models.Model):
|
||||
for channel in self:
|
||||
channel.product_sale_revenues = rg_data.get(channel.product_id.id, 0)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
channel = super(Channel, self).create(vals)
|
||||
if channel.enroll == 'payment':
|
||||
channel._synchronize_product_publish()
|
||||
return channel
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
channels = super(Channel, self).create(vals_list)
|
||||
channels.filtered(lambda channel: channel.enroll == 'payment')._synchronize_product_publish()
|
||||
return channels
|
||||
|
||||
def write(self, vals):
|
||||
res = super(Channel, self).write(vals)
|
||||
@@ -47,6 +46,8 @@ class Channel(models.Model):
|
||||
return res
|
||||
|
||||
def _synchronize_product_publish(self):
|
||||
if not self:
|
||||
return
|
||||
self.filtered(lambda channel: channel.is_published and not channel.product_id.is_published).sudo().product_id.write({'is_published': True})
|
||||
self.filtered(lambda channel: not channel.is_published and channel.product_id.is_published).sudo().product_id.write({'is_published': False})
|
||||
|
||||
|
||||
@@ -7,12 +7,15 @@ from odoo import api, models
|
||||
class Users(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
""" Trigger automatic subscription based on user groups """
|
||||
user = super(Users, self).create(values)
|
||||
self.env['slide.channel'].sudo().search([('enroll_group_ids', 'in', user.groups_id.ids)])._action_add_members(user.partner_id)
|
||||
return user
|
||||
users = super(Users, self).create(vals_list)
|
||||
for user in users:
|
||||
self.env['slide.channel'].sudo().search([
|
||||
('enroll_group_ids', 'in', user.groups_id.ids)
|
||||
])._action_add_members(user.partner_id)
|
||||
return users
|
||||
|
||||
def write(self, vals):
|
||||
""" Trigger automatic subscription based on updated user groups """
|
||||
|
||||
@@ -35,8 +35,9 @@ class SlidePartnerRelation(models.Model):
|
||||
completed = fields.Boolean('Completed')
|
||||
quiz_attempts_count = fields.Integer('Quiz attempts count', default=0)
|
||||
|
||||
def create(self, values):
|
||||
res = super(SlidePartnerRelation, self).create(values)
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
res = super().create(vals_list)
|
||||
completed = res.filtered('completed')
|
||||
if completed:
|
||||
completed._set_completed_callback()
|
||||
|
||||
@@ -25,12 +25,11 @@ class Channel(models.Model):
|
||||
|
||||
return action
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
channel = super(Channel, self.with_context(mail_create_nosubscribe=True)).create(vals)
|
||||
if channel.forum_id:
|
||||
channel.forum_id.privacy = False
|
||||
return channel
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
channels = super(Channel, self.with_context(mail_create_nosubscribe=True)).create(vals_list)
|
||||
channels.forum_id.privacy = False
|
||||
return channels
|
||||
|
||||
def write(self, vals):
|
||||
old_forum = self.forum_id
|
||||
|
||||
Reference in New Issue
Block a user