From ffdafd3f8a6a18f2af9d5aa7f2446c299cb71967 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 12 Aug 2016 09:36:25 +0200 Subject: [PATCH] [REM] most uses of `_model` (useless in most cases) --- addons/account/models/chart_template.py | 2 +- addons/mail/models/mail_thread.py | 2 +- addons/mail/views/mail_templates.xml | 2 +- addons/marketing_campaign/models/marketing_campaign.py | 2 +- addons/resource/tests/test_resource.py | 2 +- addons/web_editor/models/ir_qweb.py | 2 +- addons/website_mail/controllers/main.py | 2 +- addons/website_mail/views/website_mail_templates.xml | 2 +- openerp/addons/base/ir/ir_http.py | 2 +- openerp/addons/base/tests/test_ir_attachment.py | 1 - 10 files changed, 9 insertions(+), 10 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index c74fdd7f702..effca2ce1a4 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -343,7 +343,7 @@ class AccountChartTemplate(models.Model): # also create an entry in ir_model_data to have an xmlid for the newly created record # xmlid is the concatenation of company_id and template_xml_id ir_model_data = self.env['ir.model.data'] - template_xmlid = ir_model_data.search([('model', '=', str(template._model)), ('res_id', '=', template.id)]) + template_xmlid = ir_model_data.search([('model', '=', template._name), ('res_id', '=', template.id)]) new_xml_id = str(company.id)+'_'+template_xmlid.name return ir_model_data._update(model, template_xmlid.module, vals, xml_id=new_xml_id, store=True, noupdate=True, mode='init', res_id=False) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 3e07a89594b..e88024b17fc 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -763,7 +763,7 @@ class MailThread(models.AbstractModel): self.ensure_one() database_uuid = self.env['ir.config_parameter'].get_param('database.uuid') return {'headers': repr({ - 'X-Odoo-Objects': "%s-%s" % (self._model, self.id), + 'X-Odoo-Objects': "%s-%s" % (self._name, self.id), 'X-Odoo-db-uuid': database_uuid })} diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml index a3aace7b85e..192486b6eaa 100644 --- a/addons/mail/views/mail_templates.xml +++ b/addons/mail/views/mail_templates.xml @@ -33,7 +33,7 @@ diff --git a/addons/marketing_campaign/models/marketing_campaign.py b/addons/marketing_campaign/models/marketing_campaign.py index df30bf73a94..a7b68e72bf3 100644 --- a/addons/marketing_campaign/models/marketing_campaign.py +++ b/addons/marketing_campaign/models/marketing_campaign.py @@ -338,7 +338,7 @@ class MarketingCampaignActivity(models.Model): method = '_process_wi_%s' % (self.action_type,) action = getattr(self, method, None) if not action: - raise NotImplementedError('Method %r is not implemented on %r object.' % (method, self._model)) + raise NotImplementedError('Method %r is not implemented on %r object.' % (method, self._name)) return action(workitem) diff --git a/addons/resource/tests/test_resource.py b/addons/resource/tests/test_resource.py index 2a4f9ee109f..eff3fdd6a49 100644 --- a/addons/resource/tests/test_resource.py +++ b/addons/resource/tests/test_resource.py @@ -70,7 +70,7 @@ class TestResource(TestResourceCommon): # Test: schedule hours on intervals, backwards cleaned_intervals.reverse() - result = self.ResourceCalendar._model.interval_schedule_hours(cleaned_intervals, 5.5, remove_at_end=False) + result = self.ResourceCalendar.interval_schedule_hours(cleaned_intervals, 5.5, remove_at_end=False) self.assertEqual(len(result), 2, 'resource_calendar: wrong hours scheduling in interval') # First interval: 03, 8-10 untouches self.assertEqual(result[0][0], Datetime.from_string('2013-02-04 17:00:00'), 'resource_calendar: wrong leave removal from interval') diff --git a/addons/web_editor/models/ir_qweb.py b/addons/web_editor/models/ir_qweb.py index ca16f9e86a9..a9bb7f7fd21 100644 --- a/addons/web_editor/models/ir_qweb.py +++ b/addons/web_editor/models/ir_qweb.py @@ -82,7 +82,7 @@ class Field(models.AbstractModel): attrs['placeholder'] = placeholder if options['translate'] and field.type in ('char', 'text'): - name = "%s,%s" % (record._model._name, field_name) + name = "%s,%s" % (record._name, field_name) domain = [('name', '=', name), ('res_id', '=', record.id), ('type', '=', 'model'), ('lang', '=', options.get('lang'))] translation = record.env['ir.translation'].search(domain, limit=1) attrs['data-oe-translation-state'] = translation and translation.state or 'to_translate' diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py index ca7678a458e..c966b2bede7 100644 --- a/addons/website_mail/controllers/main.py +++ b/addons/website_mail/controllers/main.py @@ -16,7 +16,7 @@ def object_shasign(record=False, res_model='', res_id=None, **kw): shasign = False timestamp = int(time()) if record: - shasign = sha1('%s%s%s%s' % (record._model, record.id, secret, timestamp)).hexdigest() + shasign = sha1('%s%s%s%s' % (record._name, record.id, secret, timestamp)).hexdigest() elif res_model and res_id: shasign = sha1('%s%s%s%s' % (res_model, res_id, secret, timestamp)).hexdigest() return (shasign, timestamp) diff --git a/addons/website_mail/views/website_mail_templates.xml b/addons/website_mail/views/website_mail_templates.xml index b65a19b3271..cf250cc18b2 100644 --- a/addons/website_mail/views/website_mail_templates.xml +++ b/addons/website_mail/views/website_mail_templates.xml @@ -48,7 +48,7 @@
- + diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py index 81500d3f7b8..2de1441ab93 100644 --- a/openerp/addons/base/ir/ir_http.py +++ b/openerp/addons/base/ir/ir_http.py @@ -297,7 +297,7 @@ class IrHttp(models.AbstractModel): elif module_resource_path: filename = os.path.basename(module_resource_path) else: - filename = "%s-%s-%s" % (obj._model._name, obj.id, field) + filename = "%s-%s-%s" % (obj._name, obj.id, field) # mimetype mimetype = 'mimetype' in obj and obj.mimetype or False diff --git a/openerp/addons/base/tests/test_ir_attachment.py b/openerp/addons/base/tests/test_ir_attachment.py index d515cfc354d..e621ee91079 100644 --- a/openerp/addons/base/tests/test_ir_attachment.py +++ b/openerp/addons/base/tests/test_ir_attachment.py @@ -13,7 +13,6 @@ class TestIrAttachment(TransactionCase): def setUp(self): super(TestIrAttachment, self).setUp() self.Attachment = self.env['ir.attachment'] - self.ira = self.Attachment._model self.filestore = self.Attachment._filestore() # Blob1