Browse Source

⬆️1️⃣3️⃣ Take away deprecated api.multi decorator

pull/237/head
Eugene Molotov 5 years ago
parent
commit
1502eabee3
  1. 2
      mail_base/models.py
  2. 20
      mail_move_message/mail_move_message_models.py
  3. 1
      mail_multi_website/models/ir_property.py
  4. 2
      mail_multi_website/models/mail_template.py
  5. 1
      mail_multi_website/models/res_users.py
  6. 2
      mail_private/models.py
  7. 1
      mail_sent/models.py
  8. 1
      res_partner_company_messages/models.py
  9. 2
      res_partner_mails_count/models.py

2
mail_base/models.py

@ -5,7 +5,6 @@ from openerp import api, models
class MailMessage(models.Model):
_inherit = 'mail.message'
@api.multi
def write(self, values):
if values.get('needaction_partner_ids'):
if not values.get('partner_ids'):
@ -21,7 +20,6 @@ class MailComposer(models.TransientModel):
_inherit = 'mail.compose.message'
@api.multi
def send_mail(self, auto_commit=False):
res = super(MailComposer, self).send_mail(auto_commit=auto_commit)
notification = {}

20
mail_move_message/mail_move_message_models.py

@ -96,7 +96,6 @@ class Wizard(models.TransientModel):
"You must use this option, if new record has restricted access.\n"
"You can change default value for this option at Settings/System Parameters")
@api.multi
@api.depends('model_record')
def _compute_model_res_id(self):
for rec in self:
@ -104,17 +103,14 @@ class Wizard(models.TransientModel):
rec.res_id = rec.model_record and rec.model_record.id or False
@api.depends('message_id')
@api.multi
def _compute_get_can_move(self):
for r in self:
r.get_can_move_one()
@api.multi
def _compute_is_read(self):
messages = self.env['mail.message'].sudo().browse(self.message_id.all_child_ids.ids + [self.message_id.id])
self.message_to_read = True in [m.needaction for m in messages]
@api.multi
def get_can_move_one(self):
self.ensure_one()
# message was not moved before OR message is a top message of previous move
@ -164,12 +160,10 @@ class Wizard(models.TransientModel):
self.res_id = None
return {'domain': domain}
@api.multi
def check_access(self):
for r in self:
r.check_access_one()
@api.multi
def check_access_one(self):
self.ensure_one()
operation = 'write'
@ -183,7 +177,6 @@ class Wizard(models.TransientModel):
else:
self.env['mail.thread'].check_mail_message_access(mids.ids, operation, model_name=self.model)
@api.multi
def open_moved_by_message_id(self):
message_id = None
for r in self:
@ -198,7 +191,6 @@ class Wizard(models.TransientModel):
'context': {'default_message_id': message_id},
}
@api.multi
def move(self):
for r in self:
if not r.model:
@ -229,12 +221,10 @@ class Wizard(models.TransientModel):
'type': 'ir.actions.act_window',
}
@api.multi
def delete(self):
for r in self:
r.delete_one()
@api.multi
def delete_one(self):
self.ensure_one()
msg_id = self.message_id.id
@ -246,12 +236,10 @@ class Wizard(models.TransientModel):
self.message_id.unlink()
return {}
@api.multi
def read_close(self):
for r in self:
r.read_close_one()
@api.multi
def read_close_one(self):
self.ensure_one()
self.message_id.set_message_done()
@ -271,12 +259,10 @@ class MailMessage(models.Model):
all_child_ids = fields.One2many('mail.message', string='All childs', compute='_compute_get_all_childs', help='all childs, including subchilds')
moved_as_unread = fields.Boolean('Was Unread', default=False)
@api.multi
def _compute_get_all_childs(self, include_myself=True):
for r in self:
r._get_all_childs_one(include_myself=include_myself)
@api.multi
def _get_all_childs_one(self, include_myself=True):
self.ensure_one()
ids = []
@ -291,7 +277,6 @@ class MailMessage(models.Model):
moved_childs = self.search([('moved_by_message_id', '=', self.id)]).ids
self.all_child_ids = ids + moved_childs
@api.multi
def move_followers(self, model, ids):
fol_obj = self.env['mail.followers']
for message in self:
@ -300,12 +285,10 @@ class MailMessage(models.Model):
for f in followers:
self.env[model].browse(ids).message_subscribe([f.partner_id.id], [s.id for s in f.subtype_ids])
@api.multi
def move(self, parent_id, res_id, model, move_back, move_followers=False, message_to_read=False, author=False):
for r in self:
r.move_one(parent_id, res_id, model, move_back, move_followers=move_followers, message_to_read=message_to_read, author=author)
@api.multi
def move_one(self, parent_id, res_id, model, move_back, move_followers=False, message_to_read=False, author=False):
self.ensure_one()
if parent_id == self.id:
@ -384,7 +367,6 @@ class MailMessage(models.Model):
}
self.env['bus.bus'].sendone((self._cr.dbname, 'mail_move_message'), notification)
@api.multi
def name_get(self):
context = self.env.context
if not (context or {}).get('extended_name'):
@ -397,7 +379,6 @@ class MailMessage(models.Model):
res.append((record['id'], name + extended_name))
return res
@api.multi
def message_format(self):
message_values = super(MailMessage, self).message_format()
message_index = {message['id']: message for message in message_values}
@ -427,7 +408,6 @@ class MailMoveMessageConfiguration(models.TransientModel):
)
return res
@api.multi
def set_values(self):
super(MailMoveMessageConfiguration, self).set_values()
config_parameters = self.env["ir.config_parameter"].sudo()

1
mail_multi_website/models/ir_property.py

@ -7,7 +7,6 @@ from odoo import models, api
class IrProperty(models.Model):
_inherit = 'ir.property'
@api.multi
def write(self, vals):
res = super(IrProperty, self).write(vals)
field_object_list = [

2
mail_multi_website/models/mail_template.py

@ -24,7 +24,6 @@ class MailTemplate(models.Model):
mail_server_id = fields.Many2one(string='Outgoing Mail Server (Multi-Website)', company_dependent=True, website_dependent=True)
report_template = fields.Many2one(string='Optional report to print and attach (Multi-Website)', company_dependent=True, website_dependent=True)
@api.multi
def generate_email(self, res_ids, fields=None):
"""Remove mail_server_id when not set to recompute in _default_mail_server_id in mail.message"""
multi_mode = True
@ -128,7 +127,6 @@ class MailTemplate(models.Model):
res._force_default(f, vals.get(f))
return res
@api.multi
def write(self, vals):
res = super(MailTemplate, self).write(vals)

1
mail_multi_website/models/res_users.py

@ -30,7 +30,6 @@ class User(models.Model):
res._force_default(f, vals.get(f))
return res
@api.multi
def write(self, vals):
res = super(User, self).write(vals)
# TODO: will it work with OCA's partner_firstname module?

2
mail_private/models.py

@ -46,7 +46,6 @@ class MailMessage(models.Model):
# })
return result
@api.multi
def _notify(self, record, msg_vals, force_send=False, send_after_commit=True, model_description=False, mail_auto_delete=True):
self_sudo = self.sudo()
msg_vals = msg_vals if msg_vals else {}
@ -56,7 +55,6 @@ class MailMessage(models.Model):
rdata = self._notify_compute_internal_recipients(record, msg_vals)
return self._notify_recipients(rdata, record, msg_vals, force_send, send_after_commit, model_description, mail_auto_delete)
@api.multi
def _notify_compute_internal_recipients(self, record, msg_vals):
recipient_data = super(MailMessage, self)._notify_compute_recipients(record, msg_vals)
pids = [x[1] for x in msg_vals.get('partner_ids')] if 'partner_ids' in msg_vals else self.sudo().partner_ids.ids

1
mail_sent/models.py

@ -29,7 +29,6 @@ class MailMessage(models.Model):
)
r.sent = sent
@api.multi
def message_format(self):
message_values = super(MailMessage, self).message_format()
message_index = {message['id']: message for message in message_values}

1
res_partner_company_messages/models.py

@ -5,7 +5,6 @@ from openerp import models
class Partner(models.Model):
_inherit = 'res.partner'
@api.multi
def read(self, fields=None, load='_classic_read'):
res = super(Partner, self).read(fields=fields, load=load)
if fields and 'message_ids' in fields:

2
res_partner_mails_count/models.py

@ -7,12 +7,10 @@ class ResPartner(models.Model):
mails_to = fields.Integer(compute="_compute_mails_to")
mails_from = fields.Integer(compute="_compute_mails_from")
@api.multi
def _compute_mails_to(self):
for r in self:
r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)])
@api.multi
def _compute_mails_from(self):
for r in self:
r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)])
Loading…
Cancel
Save