[MIG] base: remove all old-API method definitions
This commit is contained in:
@@ -310,12 +310,7 @@ class IrActionsActWindow(models.Model):
|
||||
search_view = fields.Text(compute='_compute_search_view')
|
||||
multi = fields.Boolean(string='Restrict to lists', help="If checked and the action is bound to a model, it will only appear in the More menu on list views")
|
||||
|
||||
@api.v7
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
result = IrActionsActWindow.read(self.browse(cr, uid, ids, context), fields, load=load)
|
||||
return result if isinstance(ids, list) else (bool(result) and result[0])
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def read(self, fields=None, load='_classic_read'):
|
||||
""" call the method get_empty_list_help of the model and set the window action help message
|
||||
"""
|
||||
|
||||
@@ -341,12 +341,7 @@ class IrAttachment(models.Model):
|
||||
result = [id for id in orig_ids if id in ids]
|
||||
return len(result) if count else list(result)
|
||||
|
||||
@api.v7
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
result = IrAttachment.read(self.browse(cr, uid, ids, context), fields, load=load)
|
||||
return result if isinstance(ids, list) else (bool(result) and result[0])
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def read(self, fields=None, load='_classic_read'):
|
||||
self.check('read')
|
||||
return super(IrAttachment, self).read(fields, load=load)
|
||||
|
||||
@@ -92,11 +92,7 @@ class Property(models.Model):
|
||||
def create(self, values):
|
||||
return super(Property, self).create(self._update_values(values))
|
||||
|
||||
@api.v7
|
||||
def get_by_record(self, cr, uid, record, context=None):
|
||||
return Property.get_by_record(self.browse(cr, uid, record.id, context=context))
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def get_by_record(self):
|
||||
self.ensure_one()
|
||||
if self.type in ('char', 'text', 'selection'):
|
||||
|
||||
@@ -609,12 +609,7 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin)
|
||||
model_name, field_name = full_field_name.rsplit('.', 1)
|
||||
return self.env[model_name].fields_get([field_name])[field_name]['string']
|
||||
|
||||
@api.v7
|
||||
def get_config_warning(self, cr, msg, context=None):
|
||||
recs = self.browse(cr, SUPERUSER_ID, [], context)
|
||||
return ResConfigSettings.get_config_warning(recs, msg)
|
||||
|
||||
@api.v8
|
||||
@api.model_cr_context
|
||||
def get_config_warning(self, msg):
|
||||
"""
|
||||
Helper: return a Warning exception with the given message where the %(field:xxx)s
|
||||
|
||||
@@ -98,9 +98,9 @@ class CountryState(models.Model):
|
||||
|
||||
name_search = location_name_search
|
||||
|
||||
def merge_states(self, cr, uid, ids=None, context=None):
|
||||
Imd = self.pool['ir.model.data']
|
||||
State = self.pool['res.country.state']
|
||||
@api.model
|
||||
def merge_states(self):
|
||||
IMD = self.env['ir.model.data']
|
||||
|
||||
query = """
|
||||
SELECT st.id, st.oldid, imd.id, imd.name, imd2.id, ids
|
||||
@@ -114,8 +114,8 @@ class CountryState(models.Model):
|
||||
LEFT JOIN ir_model_data imd2 on (imd2.model = 'res.country.state' and imd2.res_id = st.oldid)
|
||||
WHERE imd.module = 'base';
|
||||
"""
|
||||
cr.execute(query)
|
||||
data = cr.fetchall()
|
||||
self._cr.execute(query)
|
||||
data = self._cr.fetchall()
|
||||
|
||||
for st_id, st_oldid, imd_id, imd_name, imd2_id, ids in data:
|
||||
values = dict(module=self._module)
|
||||
@@ -123,22 +123,22 @@ class CountryState(models.Model):
|
||||
# If duplicated record had already a xml_id we update the old xml_id and
|
||||
# force to delete the new xml_id created to avoid constraint error
|
||||
keepid = imd2_id
|
||||
Imd.unlink(cr, uid, imd_id, context=context)
|
||||
IMD.browse(imd_id).unlink()
|
||||
values.update(name=imd_name)
|
||||
else:
|
||||
# Else we point the new xml_id to the oldest duplicated state
|
||||
keepid = imd_id
|
||||
values.update(res_id=st_oldid)
|
||||
|
||||
Imd.write(cr, uid, keepid, values, context=context)
|
||||
State.unlink(cr, uid, st_id, context=context)
|
||||
IMD.browse(keepid).write(values)
|
||||
self.browse(st_id).unlink()
|
||||
|
||||
duplicated_ids = set(map(int, ids.split(','))) - set([st_id, st_oldid])
|
||||
if duplicated_ids:
|
||||
_logger.warning(_('State with id [%s] (%s) seems to have duplicated code: %s' % (st_oldid, imd_name, ','.join(duplicated_ids))))
|
||||
|
||||
if data:
|
||||
self._add_sql_constraints(cr)
|
||||
self._add_sql_constraints()
|
||||
|
||||
_sql_constraints = [
|
||||
('name_code_uniq', 'unique(country_id, code)', 'The code of the state must be unique by country !')
|
||||
|
||||
@@ -78,11 +78,7 @@ class Currency(models.Model):
|
||||
def name_get(self):
|
||||
return [(currency.id, tools.ustr(currency.name)) for currency in self]
|
||||
|
||||
@api.v7
|
||||
def round(self, cr, uid, currency, amount):
|
||||
return Currency.round(currency, amount)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def round(self, amount):
|
||||
"""Return ``amount`` rounded according to ``self``'s rounding rules.
|
||||
|
||||
@@ -96,11 +92,7 @@ class Currency(models.Model):
|
||||
#self.ensure_one()
|
||||
return tools.float_round(amount, precision_rounding=self.rounding)
|
||||
|
||||
@api.v7
|
||||
def compare_amounts(self, cr, uid, currency, amount1, amount2):
|
||||
return Currency.compare_amounts(currency, amount1, amount2)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def compare_amounts(self, amount1, amount2):
|
||||
"""Compare ``amount1`` and ``amount2`` after rounding them according to the
|
||||
given currency's precision..
|
||||
@@ -123,11 +115,7 @@ class Currency(models.Model):
|
||||
"""
|
||||
return tools.float_compare(amount1, amount2, precision_rounding=self.rounding)
|
||||
|
||||
@api.v7
|
||||
def is_zero(self, cr, uid, currency, amount):
|
||||
return Currency.is_zero(currency, amount)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def is_zero(self, amount):
|
||||
"""Returns true if ``amount`` is small enough to be treated as
|
||||
zero according to current currency's rounding rules.
|
||||
@@ -157,20 +145,7 @@ class Currency(models.Model):
|
||||
amount = to_currency.round(from_amount * rate) if round else from_amount * rate
|
||||
return amount
|
||||
|
||||
@api.v7
|
||||
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount,
|
||||
round=True, context=None):
|
||||
context = context or {}
|
||||
if not from_currency_id:
|
||||
from_currency_id = to_currency_id
|
||||
if not to_currency_id:
|
||||
to_currency_id = from_currency_id
|
||||
xc = self.browse(cr, uid, [from_currency_id,to_currency_id], context=context)
|
||||
from_currency = (xc[0].id == from_currency_id and xc[0]) or xc[1]
|
||||
to_currency = (xc[0].id == to_currency_id and xc[0]) or xc[1]
|
||||
return self._compute(cr, uid, from_currency, to_currency, from_amount, round, context)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def compute(self, from_amount, to_currency, round=True):
|
||||
""" Convert `from_amount` from currency `self` to `to_currency`. """
|
||||
self, to_currency = self or to_currency, to_currency or self
|
||||
|
||||
@@ -183,12 +183,6 @@ class Lang(models.Model):
|
||||
def _lang_get(self, code):
|
||||
return self.browse(self._lang_get_id(code))
|
||||
|
||||
@api.v7
|
||||
def _lang_data_get(self, cr, uid, lang, monetary=False):
|
||||
if isinstance(lang, basestring):
|
||||
lang = self._lang_get(cr, uid, lang)
|
||||
return self.browse(cr, uid, lang)._data_get(monetary)
|
||||
|
||||
@tools.ormcache('self.code', 'monetary')
|
||||
def _data_get(self, monetary=False):
|
||||
conv = locale.localeconv()
|
||||
@@ -240,19 +234,7 @@ class Lang(models.Model):
|
||||
self.clear_caches()
|
||||
return super(Lang, self).unlink()
|
||||
|
||||
#
|
||||
# IDS: can be a list of IDS or a list of XML_IDS
|
||||
#
|
||||
@api.v7
|
||||
def format(self, cr, uid, ids, percent, value, grouping=False, monetary=False, context=None):
|
||||
# Refering the old code, `ids` is expected to have only one value(ID or XML_ID) inside list, hence used ids[0].
|
||||
lang_id = ids[0]
|
||||
if isinstance(lang_id, (str, unicode)):
|
||||
lang_id = self._lang_get(cr, uid, lang_id)
|
||||
lang = self.browse(cr, uid, lang_id, context=context)
|
||||
return Lang.format(lang, percent, value, grouping=grouping, monetary=monetary)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def format(self, percent, value, grouping=False, monetary=False):
|
||||
""" Format() will return the language-specific output for float values"""
|
||||
self.ensure_one()
|
||||
|
||||
@@ -349,11 +349,7 @@ class Partner(models.Model, FormatAddress):
|
||||
def onchange_company_type(self):
|
||||
self.is_company = (self.company_type == 'company')
|
||||
|
||||
@api.v7
|
||||
def _update_fields_values(self, cr, uid, partner, fields, context=None):
|
||||
return Partner._update_fields_values(partner, fields)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def _update_fields_values(self, fields):
|
||||
""" Returns dict of write() values for synchronizing ``fields`` """
|
||||
values = {}
|
||||
@@ -389,11 +385,7 @@ class Partner(models.Model, FormatAddress):
|
||||
extended by inheriting classes. """
|
||||
return ['vat', 'credit_limit']
|
||||
|
||||
@api.v7
|
||||
def _commercial_sync_from_company(self, cr, uid, partner, context=None):
|
||||
return Partner._commercial_sync_from_company(partner)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def _commercial_sync_from_company(self):
|
||||
""" Handle sync of commercial fields when a new parent commercial entity is set,
|
||||
as if they were related fields """
|
||||
@@ -402,11 +394,7 @@ class Partner(models.Model, FormatAddress):
|
||||
sync_vals = commercial_partner._update_fields_values(self._commercial_fields())
|
||||
self.write(sync_vals)
|
||||
|
||||
@api.v7
|
||||
def _commercial_sync_to_children(self, cr, uid, partner, context=None):
|
||||
return Partner._commercial_sync_to_children(partner)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def _commercial_sync_to_children(self):
|
||||
""" Handle sync of commercial fields to descendants """
|
||||
commercial_partner = self.commercial_partner_id
|
||||
@@ -416,11 +404,7 @@ class Partner(models.Model, FormatAddress):
|
||||
child._commercial_sync_to_children()
|
||||
return sync_children.write(sync_vals)
|
||||
|
||||
@api.v7
|
||||
def _fields_sync(self, cr, uid, partner, values, context=None):
|
||||
return Partner._fields_sync(partner, values)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def _fields_sync(self, values):
|
||||
""" Sync commercial fields and address fields from company and to children after create/update,
|
||||
just as if those were all modeled as fields.related to the parent """
|
||||
@@ -447,11 +431,7 @@ class Partner(models.Model, FormatAddress):
|
||||
contacts = self.child_ids.filtered(lambda c: c.type == 'contact')
|
||||
contacts.update_address(values)
|
||||
|
||||
@api.v7
|
||||
def _handle_first_contact_creation(self, cr, uid, partner, context=None):
|
||||
return Partner._handle_first_contact_creation(partner)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def _handle_first_contact_creation(self):
|
||||
""" On creation of first contact for a company (or root) that has no address, assume contact address
|
||||
was meant to be company address """
|
||||
@@ -747,11 +727,7 @@ class Partner(models.Model, FormatAddress):
|
||||
''' Return the main partner '''
|
||||
return self.env.ref('base.main_partner')
|
||||
|
||||
@api.v7
|
||||
def _display_address(self, cr, uid, address, without_company=False, context=None):
|
||||
return self.browse(cr, uid, address.id, context=context)._display_address(without_company=without_company)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def _display_address(self, without_company=False):
|
||||
|
||||
'''
|
||||
|
||||
@@ -206,13 +206,8 @@ class Users(models.Model):
|
||||
share = fields.Boolean(compute='_compute_share', compute_sudo=True, string='Share User', store=True,
|
||||
help="External user with limited access, created only for the purpose of sharing data.")
|
||||
companies_count = fields.Integer(compute='_compute_companies_count', string="Number of Companies", default=_companies_count)
|
||||
|
||||
@api.v7
|
||||
def _get_company(self, cr, uid, context=None, uid2=False):
|
||||
user = self.browse(cr, uid, uid2 or uid, context=context)
|
||||
return Users._get_company(user).id
|
||||
|
||||
@api.v8
|
||||
@api.model
|
||||
def _get_company(self):
|
||||
return self.env.user.company_id
|
||||
|
||||
@@ -281,12 +276,7 @@ class Users(models.Model):
|
||||
if any(user.company_ids and user.company_id not in user.company_ids for user in self):
|
||||
raise ValidationError(_('The chosen company is not in the allowed companies for this user'))
|
||||
|
||||
@api.v7
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
result = Users.read(self.browse(cr, uid, ids, context), fields, load=load)
|
||||
return result if isinstance(ids, list) else (bool(result) and result[0])
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def read(self, fields=None, load='_classic_read'):
|
||||
if fields and self == self.env.user:
|
||||
for key in fields:
|
||||
@@ -535,11 +525,7 @@ class Users(models.Model):
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
@api.v7
|
||||
def has_group(self, cr, uid, group_ext_id):
|
||||
return self._has_group(cr, uid, group_ext_id)
|
||||
|
||||
@api.v8
|
||||
@api.model
|
||||
def has_group(self, group_ext_id):
|
||||
# use singleton's id if called on a non-empty recordset, otherwise
|
||||
# context uid
|
||||
@@ -840,12 +826,7 @@ class UsersView(models.Model):
|
||||
self._add_reified_groups(group_fields, values)
|
||||
return values
|
||||
|
||||
@api.v7
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
result = UsersView.read(self.browse(cr, uid, ids, context), fields, load=load)
|
||||
return result if isinstance(ids, list) else (bool(result) and result[0])
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def read(self, fields=None, load='_classic_read'):
|
||||
# determine whether reified groups fields are required, and which ones
|
||||
fields1 = fields or self.fields_get().keys()
|
||||
|
||||
@@ -86,12 +86,6 @@ class TestORM(TransactionCase):
|
||||
result = partner.read()
|
||||
self.assertIsInstance(result, list)
|
||||
|
||||
# special cases for the old API only
|
||||
result = self.registry('res.partner').read(self.cr, self.uid, [partner.id])
|
||||
self.assertIsInstance(result, list)
|
||||
result = self.registry('res.partner').read(self.cr, self.uid, partner.id)
|
||||
self.assertIsInstance(result, dict)
|
||||
|
||||
@mute_logger('openerp.models')
|
||||
def test_search_read(self):
|
||||
partner = self.env['res.partner']
|
||||
|
||||
+2
-16
@@ -3252,15 +3252,7 @@ class BaseModel(object):
|
||||
|
||||
return fields
|
||||
|
||||
# add explicit old-style implementation to read()
|
||||
@api.v7
|
||||
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
|
||||
records = self.browse(cr, user, ids, context)
|
||||
result = BaseModel.read(records, fields, load=load)
|
||||
return result if isinstance(ids, list) else (bool(result) and result[0])
|
||||
|
||||
# new-style implementation of read()
|
||||
@api.v8
|
||||
@api.multi
|
||||
def read(self, fields=None, load='_classic_read'):
|
||||
""" read([fields])
|
||||
|
||||
@@ -4871,13 +4863,7 @@ class BaseModel(object):
|
||||
|
||||
return [default]
|
||||
|
||||
@api.v7
|
||||
def copy_translations(self, cr, uid, old_id, new_id, context=None):
|
||||
old = self.browse(cr, uid, old_id, context)
|
||||
new = self.browse(cr, uid, new_id, context)
|
||||
BaseModel.copy_translations(old, new)
|
||||
|
||||
@api.v8
|
||||
@api.multi
|
||||
def copy_translations(old, new):
|
||||
# avoid recursion through already copied records in case of circular relationship
|
||||
if '__copy_translations_seen' not in old._context:
|
||||
|
||||
@@ -36,14 +36,14 @@ class ormcache(object):
|
||||
signature of the decorated method, and are used to compute a cache key::
|
||||
|
||||
@ormcache('model_name', 'mode')
|
||||
def _compute_domain(self, cr, uid, model_name, mode="read"):
|
||||
def _compute_domain(self, model_name, mode="read"):
|
||||
...
|
||||
|
||||
For the sake of backward compatibility, the decorator supports the named
|
||||
parameter `skiparg`::
|
||||
|
||||
@ormcache(skiparg=3)
|
||||
def _compute_domain(self, cr, uid, model_name, mode="read"):
|
||||
@ormcache(skiparg=1)
|
||||
def _compute_domain(self, model_name, mode="read"):
|
||||
...
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user