Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MASTER] remove decorator api.returns #35595

Open
wants to merge 3 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -346,7 +346,6 @@ def name_get(self):
result.append((account.id, name))
return result

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {})
if default.get('code', False):
@@ -712,7 +711,6 @@ def unlink(self):
bank_accounts.unlink()
return ret

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {})
default.update(
@@ -1140,7 +1138,6 @@ def _check_children_scope(self):
if not all(child.type_tax_use in ('none', tax.type_tax_use) for child in tax.children_tax_ids):
raise ValidationError(_('The application scope of taxes in a group must be either the same as the group or left empty.'))

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {}, name=_("%s (Copy)") % self.name)
return super(AccountTax, self).copy(default=default)
@@ -1166,7 +1166,7 @@ def _compute_payments_widget_reconciled_info(self):
'outstanding': False,
'content': reconciled_vals,
}
move.invoice_payments_widget = json.dumps(info, default=date_utils.json_default)
move.invoice_payments_widget = json.dumps(info)
else:
move.invoice_payments_widget = json.dumps(False)

@@ -47,7 +47,6 @@ def create(self, vals):
rec._create_check_sequence()
return rec

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
rec = super(AccountJournal, self).copy(default)
rec._create_check_sequence()
@@ -215,7 +215,6 @@ def _import_facturx_invoice(self, tree):

return invoice_form.save()

@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
# OVERRIDE
# /!\ 'default_res_id' in self._context is used to don't process attachment when using a form view.
@@ -240,7 +240,6 @@ def create(self, values):
user.partner_id.with_context(create_user=True).signup_cancel()
return user

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
sup = super(ResUsers, self)
@@ -21,7 +21,7 @@
# Bus
#----------------------------------------------------------
def json_dump(v):
return json.dumps(v, separators=(',', ':'), default=date_utils.json_default)
return json.dumps(v, separators=(',', ':'))

def hashable(key):
if isinstance(key, list):
@@ -154,7 +154,6 @@ def create(self, vals_list):
values['common_name'] = values.get("common_name")
return super(Attendee, self).create(vals_list)

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
raise UserError(_('You cannot duplicate a calendar attendee.'))

@@ -1446,7 +1445,6 @@ def _get_message_needaction(self):
event.message_needaction_counter = rec.message_needaction_counter
event.message_needaction = rec.message_needaction

@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
thread_id = self.id
if isinstance(self.id, str):
@@ -1745,7 +1743,6 @@ def _search(self, args, offset=0, limit=None, order=None, count=False, access_ri
return events[offset: offset + limit].ids
return events.ids

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
default = default or {}
@@ -441,7 +441,6 @@ def _write_probability(self, vals):
super(Lead, lead).write(proba_vals)
return

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
# set default value in context, if not already set (Put stage to 'new' stage)
@@ -305,7 +305,6 @@ def write(self, vals):
self.message_subscribe([vals['organizer_id']])
return res

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
default = dict(default or {}, name=_("%s (copy)") % (self.name))
@@ -23,7 +23,6 @@ def write(self, values):
values['oe_update_date'] = fields.Datetime.now()
return super(Meeting, self).write(values)

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = default or {}
if default.get('write_type', False):
@@ -377,7 +377,6 @@ def _get_unavailable_intervals(self, start, end):
def _message_log(self, **kwargs):
return super(HrEmployeePrivate, self._post_author())._message_log(**kwargs)

@api.returns('mail.message', lambda value: value.id)
def message_post(self, *args, **kwargs):
return super(HrEmployeePrivate, self._post_author()).message_post(*args, **kwargs)

@@ -46,7 +46,6 @@ def create(self, values):
""" We don't want the current user to be follower of all created job """
return super(Job, self.with_context(mail_create_nosubscribe=True)).create(values)

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
default = dict(default or {})
@@ -96,6 +96,5 @@ def _check_validity(self):
'datetime': fields.Datetime.to_string(fields.Datetime.context_timestamp(self, fields.Datetime.from_string(last_attendance_before_check_out.check_in))),
})

@api.returns('self', lambda value: value.id)
def copy(self):
raise exceptions.UserError(_('You cannot duplicate an attendance.'))
@@ -70,7 +70,6 @@ def _track_subtype(self, init_values):
class MaintenanceRequest(models.Model):
_inherit = 'maintenance.request'

@api.returns('self')
def _default_employee_get(self):
return self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)

@@ -184,7 +184,6 @@ def action_invoice_sent(self):

return rslt

@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
if self.env.context.get('l10n_ch_mark_isr_as_sent'):
self.filtered(lambda inv: not inv.l10n_ch_isr_sent).write({'l10n_ch_isr_sent': True})
@@ -351,7 +351,6 @@ def _extract_moderation_values(self, message_type, **kwargs):
moderation_status = 'pending_moderation'
return moderation_status, email

@api.returns('mail.message', lambda value: value.id)
def message_post(self, message_type='notification', **kwargs):
This conversation was marked as resolved by rco-odoo

This comment has been minimized.

Copy link
@rco-odoo

rco-odoo Aug 12, 2019

Member

The calls to message_post from the JS must be adapted, including the mocks of message_post in JS tests.

moderation_status, email = self._extract_moderation_values(message_type, **kwargs)
if moderation_status == 'rejected':
@@ -198,7 +198,6 @@ def unlink(self):
self.unlink_action()
return super(MailTemplate, self).unlink()

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {},
name=_("%s (copy)") % self.name)
@@ -1652,7 +1652,6 @@ def _message_post_process_attachments(self, attachments, attachment_ids, message
return_values['attachment_ids'] = m2m_attachment_ids
return return_values

@api.returns('mail.message', lambda value: value.id)
def message_post(self,
body='', subject=None, message_type='notification',
email_from=False, author_id=None, parent_id=False,
@@ -320,11 +320,11 @@ var DocumentThread = Thread.extend({
args: [resID],
kwargs: messageData,
})
.then(function (messageID) {
.then(function (messageIDs) {
return self._rpc({
model: 'mail.message',
method: 'message_format',
args: [[messageID]],
args: [messageIDs],
})
.then(function (messages) {
messages[0].model = resModel;
@@ -939,7 +939,7 @@ QUnit.test('chatter: post, receive and star messages', async function (assert) {
model: 'partner',
res_id: 2,
});
return Promise.resolve(messageID);
return Promise.resolve([messageID]);
}
if (args.method === 'toggle_message_starred') {
assert.ok(_.contains(args.args[0], 2),
@@ -1063,7 +1063,7 @@ QUnit.test('chatter: post a message disable the send button', async function(ass
if (args.method === 'message_post') {
assert.ok(form.$('.o_composer_button_send').prop("disabled"),
"Send button should be disabled when a message is being sent");
return Promise.resolve(57923);
return Promise.resolve([57923]);
}
if (args.method === 'message_format') {
return Promise.resolve([{
@@ -1268,7 +1268,7 @@ QUnit.test('chatter: post a message and switch in edit mode', async function (as
model: 'partner',
res_id: 2,
});
return Promise.resolve(42);
return Promise.resolve([42]);
}

return this._super(route, args);
@@ -1390,7 +1390,7 @@ QUnit.test('chatter: discard changes on message post without post_refresh', asyn
model: 'partner',
res_id: 2,
});
return Promise.resolve(42);
return Promise.resolve([42]);
}
return this._super(route, args);
},
@@ -1472,7 +1472,7 @@ QUnit.test('chatter: discard changes on message post with post_refresh "recipien
model: 'partner',
res_id: 2,
});
return Promise.resolve(42);
return Promise.resolve([42]);
}
return this._super(route, args);
},
@@ -1749,7 +1749,7 @@ QUnit.test('chatter: keep context when sending a message', async function(assert
mail_post_autofollow: true,
},
"the context is incorrect");
return Promise.resolve(57923);
return Promise.resolve([57923]);
}
if (args.method === 'message_format') {
return Promise.resolve([{
@@ -2893,7 +2893,7 @@ QUnit.test('chatter: suggested partner auto-follow on message post', async funct
model: 'partner',
res_id: 2,
});
return Promise.resolve(messageID);
return Promise.resolve([messageID]);
}
if (route === '/mail/read_followers') {
return Promise.resolve({
@@ -575,7 +575,7 @@ QUnit.test('author: send message in moderated channel', function (assert) {
await testUtils.nextTick();

messagePostDef.resolve();
return Promise.resolve(message.id);
return Promise.resolve([message.id]);
}
return this._super.apply(this, arguments);
},
@@ -317,7 +317,7 @@ QUnit.test('@ mention in channel', async function (assert) {
var notification = [[false, 'mail.channel', 1], data];
objectDiscuss.call('bus_service', 'trigger', 'notification', [notification]);
receiveMessageDef.resolve();
return Promise.resolve(42);
return Promise.resolve([42]);
}
return this._super.apply(this, arguments);
},
@@ -479,7 +479,7 @@ QUnit.test('@ mention with special chars', async function (assert) {
var notification = [[false, 'mail.channel', 1], data];
objectDiscuss.call('bus_service', 'trigger', 'notification', [notification]);
receiveMessageDef.resolve();
return Promise.resolve(42);
return Promise.resolve([42]);
}
return this._super.apply(this, arguments);
},
@@ -572,7 +572,7 @@ QUnit.test('@ mention with removed space', async function (assert) {
var notification = [[false, 'mail.channel', 1], data];
objectDiscuss.call('bus_service', 'trigger', 'notification', [notification]);
receiveMessageDef.resolve();
return Promise.resolve(42);
return Promise.resolve([42]);
}
return this._super.apply(this, arguments);
},
@@ -943,7 +943,7 @@ QUnit.test('convert emoji sources to unicodes on message_post', async function (
var notification = [[false, 'mail.channel', 1], data];
objectDiscuss.call('bus_service', 'trigger', 'notification', [notification]);
receiveMessageDef.resolve();
return Promise.resolve(42);
return Promise.resolve([42]);
}
return this._super.apply(this, arguments);
},
@@ -1159,7 +1159,7 @@ QUnit.test('reply to message from inbox', async function (assert) {
model: 'some.document',
record_name: 'SomeDocument',
});
return Promise.resolve(2);
return Promise.resolve([2]);
}
return this._super.apply(this, arguments);
},
@@ -1234,7 +1234,7 @@ QUnit.test('discard replying to message from inbox', async function (assert) {
model: 'some.document',
record_name: 'SomeDocument',
});
return Promise.resolve(2);
return Promise.resolve([2]);
}
return this._super.apply(this, arguments);
},
@@ -193,7 +193,7 @@ QUnit.test('post messages in a document thread window', async function (assert)
// add the message to the fake DB
this.data['mail.message'].records.push(newMessage);
this.data['some.res.model'].records[0].message_ids.push(6783);
return Promise.resolve(6783);
return Promise.resolve([6783]);
}
return this._super.apply(this, arguments);
},
@@ -254,7 +254,6 @@ class MaintenanceRequest(models.Model):
_description = 'Maintenance Request'
_order = "id desc"

@api.returns('self')
def _default_stage(self):
return self.env['maintenance.stage'].search([], limit=1)

@@ -241,7 +241,6 @@ def write(self, values):
values['body_html'] = self._convert_inline_images_to_urls(values['body_html'])
return super(MassMailing, self).write(values)

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
default = dict(default or {},
@@ -427,7 +427,6 @@ def _unlink_or_archive(self, check_access=True):
# This is the case from existing stock reordering rules.
self.write({'active': False})

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
# TDE FIXME: clean context / variant brol
if default is None:
@@ -401,7 +401,6 @@ def write(self, vals):
])
return res

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
# TDE FIXME: should probably be copy_data
self.ensure_one()
@@ -271,7 +271,6 @@ def map_tasks(self, new_project_id):

return self.browse(new_project_id).write({'tasks': [(6, 0, tasks.ids)]})

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
if default is None:
default = {}
@@ -621,7 +620,6 @@ def _check_subtask_level(self):
if task.parent_id and task.child_ids:
raise ValidationError(_('Task %s cannot have several subtask levels.' % (task.name,)))

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
if default is None:
default = {}
@@ -295,7 +295,6 @@ def action_rfq_send(self):
'context': ctx,
}

@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
if self.env.context.get('mark_rfq_as_sent'):
self.filtered(lambda o: o.state == 'draft').write({'state': 'sent'})
@@ -7,7 +7,6 @@
class MailThread(models.AbstractModel):
_inherit = 'mail.thread'

@api.returns('mail.message', lambda value: value.id)
def message_post(self, **kwargs):
rating_value = kwargs.pop('rating_value', False)
message = super(MailThread, self).message_post(**kwargs)
@@ -614,7 +614,6 @@ def create(self, values):
values['tz'] = tz
return super(ResourceResource, self).create(values)

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
if default is None:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.