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): class MailMessage(models.Model):
_inherit = 'mail.message' _inherit = 'mail.message'
@api.multi
def write(self, values): def write(self, values):
if values.get('needaction_partner_ids'): if values.get('needaction_partner_ids'):
if not values.get('partner_ids'): if not values.get('partner_ids'):
@ -21,7 +20,6 @@ class MailComposer(models.TransientModel):
_inherit = 'mail.compose.message' _inherit = 'mail.compose.message'
@api.multi
def send_mail(self, auto_commit=False): def send_mail(self, auto_commit=False):
res = super(MailComposer, self).send_mail(auto_commit=auto_commit) res = super(MailComposer, self).send_mail(auto_commit=auto_commit)
notification = {} 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 must use this option, if new record has restricted access.\n"
"You can change default value for this option at Settings/System Parameters") "You can change default value for this option at Settings/System Parameters")
@api.multi
@api.depends('model_record') @api.depends('model_record')
def _compute_model_res_id(self): def _compute_model_res_id(self):
for rec in 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 rec.res_id = rec.model_record and rec.model_record.id or False
@api.depends('message_id') @api.depends('message_id')
@api.multi
def _compute_get_can_move(self): def _compute_get_can_move(self):
for r in self: for r in self:
r.get_can_move_one() r.get_can_move_one()
@api.multi
def _compute_is_read(self): def _compute_is_read(self):
messages = self.env['mail.message'].sudo().browse(self.message_id.all_child_ids.ids + [self.message_id.id]) 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] self.message_to_read = True in [m.needaction for m in messages]
@api.multi
def get_can_move_one(self): def get_can_move_one(self):
self.ensure_one() self.ensure_one()
# message was not moved before OR message is a top message of previous move # 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 self.res_id = None
return {'domain': domain} return {'domain': domain}
@api.multi
def check_access(self): def check_access(self):
for r in self: for r in self:
r.check_access_one() r.check_access_one()
@api.multi
def check_access_one(self): def check_access_one(self):
self.ensure_one() self.ensure_one()
operation = 'write' operation = 'write'
@ -183,7 +177,6 @@ class Wizard(models.TransientModel):
else: else:
self.env['mail.thread'].check_mail_message_access(mids.ids, operation, model_name=self.model) self.env['mail.thread'].check_mail_message_access(mids.ids, operation, model_name=self.model)
@api.multi
def open_moved_by_message_id(self): def open_moved_by_message_id(self):
message_id = None message_id = None
for r in self: for r in self:
@ -198,7 +191,6 @@ class Wizard(models.TransientModel):
'context': {'default_message_id': message_id}, 'context': {'default_message_id': message_id},
} }
@api.multi
def move(self): def move(self):
for r in self: for r in self:
if not r.model: if not r.model:
@ -229,12 +221,10 @@ class Wizard(models.TransientModel):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
} }
@api.multi
def delete(self): def delete(self):
for r in self: for r in self:
r.delete_one() r.delete_one()
@api.multi
def delete_one(self): def delete_one(self):
self.ensure_one() self.ensure_one()
msg_id = self.message_id.id msg_id = self.message_id.id
@ -246,12 +236,10 @@ class Wizard(models.TransientModel):
self.message_id.unlink() self.message_id.unlink()
return {} return {}
@api.multi
def read_close(self): def read_close(self):
for r in self: for r in self:
r.read_close_one() r.read_close_one()
@api.multi
def read_close_one(self): def read_close_one(self):
self.ensure_one() self.ensure_one()
self.message_id.set_message_done() 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') 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) moved_as_unread = fields.Boolean('Was Unread', default=False)
@api.multi
def _compute_get_all_childs(self, include_myself=True): def _compute_get_all_childs(self, include_myself=True):
for r in self: for r in self:
r._get_all_childs_one(include_myself=include_myself) r._get_all_childs_one(include_myself=include_myself)
@api.multi
def _get_all_childs_one(self, include_myself=True): def _get_all_childs_one(self, include_myself=True):
self.ensure_one() self.ensure_one()
ids = [] ids = []
@ -291,7 +277,6 @@ class MailMessage(models.Model):
moved_childs = self.search([('moved_by_message_id', '=', self.id)]).ids moved_childs = self.search([('moved_by_message_id', '=', self.id)]).ids
self.all_child_ids = ids + moved_childs self.all_child_ids = ids + moved_childs
@api.multi
def move_followers(self, model, ids): def move_followers(self, model, ids):
fol_obj = self.env['mail.followers'] fol_obj = self.env['mail.followers']
for message in self: for message in self:
@ -300,12 +285,10 @@ class MailMessage(models.Model):
for f in followers: for f in followers:
self.env[model].browse(ids).message_subscribe([f.partner_id.id], [s.id for s in f.subtype_ids]) 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): def move(self, parent_id, res_id, model, move_back, move_followers=False, message_to_read=False, author=False):
for r in self: 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) 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): def move_one(self, parent_id, res_id, model, move_back, move_followers=False, message_to_read=False, author=False):
self.ensure_one() self.ensure_one()
if parent_id == self.id: 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) self.env['bus.bus'].sendone((self._cr.dbname, 'mail_move_message'), notification)
@api.multi
def name_get(self): def name_get(self):
context = self.env.context context = self.env.context
if not (context or {}).get('extended_name'): if not (context or {}).get('extended_name'):
@ -397,7 +379,6 @@ class MailMessage(models.Model):
res.append((record['id'], name + extended_name)) res.append((record['id'], name + extended_name))
return res return res
@api.multi
def message_format(self): def message_format(self):
message_values = super(MailMessage, self).message_format() message_values = super(MailMessage, self).message_format()
message_index = {message['id']: message for message in message_values} message_index = {message['id']: message for message in message_values}
@ -427,7 +408,6 @@ class MailMoveMessageConfiguration(models.TransientModel):
) )
return res return res
@api.multi
def set_values(self): def set_values(self):
super(MailMoveMessageConfiguration, self).set_values() super(MailMoveMessageConfiguration, self).set_values()
config_parameters = self.env["ir.config_parameter"].sudo() 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): class IrProperty(models.Model):
_inherit = 'ir.property' _inherit = 'ir.property'
@api.multi
def write(self, vals): def write(self, vals):
res = super(IrProperty, self).write(vals) res = super(IrProperty, self).write(vals)
field_object_list = [ 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) 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) 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): 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""" """Remove mail_server_id when not set to recompute in _default_mail_server_id in mail.message"""
multi_mode = True multi_mode = True
@ -128,7 +127,6 @@ class MailTemplate(models.Model):
res._force_default(f, vals.get(f)) res._force_default(f, vals.get(f))
return res return res
@api.multi
def write(self, vals): def write(self, vals):
res = super(MailTemplate, self).write(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)) res._force_default(f, vals.get(f))
return res return res
@api.multi
def write(self, vals): def write(self, vals):
res = super(User, self).write(vals) res = super(User, self).write(vals)
# TODO: will it work with OCA's partner_firstname module? # 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 return result
@api.multi
def _notify(self, record, msg_vals, force_send=False, send_after_commit=True, model_description=False, mail_auto_delete=True): def _notify(self, record, msg_vals, force_send=False, send_after_commit=True, model_description=False, mail_auto_delete=True):
self_sudo = self.sudo() self_sudo = self.sudo()
msg_vals = msg_vals if msg_vals else {} 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) 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) 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): def _notify_compute_internal_recipients(self, record, msg_vals):
recipient_data = super(MailMessage, self)._notify_compute_recipients(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 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 r.sent = sent
@api.multi
def message_format(self): def message_format(self):
message_values = super(MailMessage, self).message_format() message_values = super(MailMessage, self).message_format()
message_index = {message['id']: message for message in message_values} 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): class Partner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
@api.multi
def read(self, fields=None, load='_classic_read'): def read(self, fields=None, load='_classic_read'):
res = super(Partner, self).read(fields=fields, load=load) res = super(Partner, self).read(fields=fields, load=load)
if fields and 'message_ids' in fields: 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_to = fields.Integer(compute="_compute_mails_to")
mails_from = fields.Integer(compute="_compute_mails_from") mails_from = fields.Integer(compute="_compute_mails_from")
@api.multi
def _compute_mails_to(self): def _compute_mails_to(self):
for r in self: for r in self:
r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)]) r.mails_to = self.env['mail.message'].sudo().search_count([('partner_ids', 'in', r.id)])
@api.multi
def _compute_mails_from(self): def _compute_mails_from(self):
for r in self: for r in self:
r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)]) r.mails_from = self.env['mail.message'].sudo().search_count([('author_id', '=', r.id)])
Loading…
Cancel
Save