Followup of 73dc42d6d5: catchall or bounce alias reset to the same value
should not raise an UserError. This happens for example when reinitializing
mail module.
Also enable batch write again.
closes odoo/odoo#50248
X-original-commit: 00709025a9436b35744908481c5e5faa1e3ef655
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
22 lines
846 B
Python
22 lines
846 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models
|
|
|
|
|
|
class IrConfigParameter(models.Model):
|
|
_inherit = 'ir.config_parameter'
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
for vals in vals_list:
|
|
if vals.get('key') in ['mail.bounce.alias', 'mail.catchall.alias']:
|
|
vals['value'] = self.env['mail.alias']._clean_and_check_unique(vals.get('value'))
|
|
return super().create(vals_list)
|
|
|
|
def write(self, vals):
|
|
for parameter in self:
|
|
if 'value' in vals and parameter.key in ['mail.bounce.alias', 'mail.catchall.alias'] and vals['value'] != parameter.value:
|
|
vals['value'] = self.env['mail.alias']._clean_and_check_unique(vals.get('value'))
|
|
return super().write(vals)
|