[REM] most uses of self.pool

This commit is contained in:
Raphael Collet
2016-08-16 09:55:46 +02:00
parent ffdafd3f8a
commit 38e7a1318a
13 changed files with 22 additions and 23 deletions
+1 -1
View File
@@ -656,7 +656,7 @@ class Message(models.Model):
SUPERUSER_ID, to be sure to have the record name correctly stored. """
model = values.get('model', self.env.context.get('default_model'))
res_id = values.get('res_id', self.env.context.get('default_res_id'))
if not model or not res_id or model not in self.pool:
if not model or not res_id or model not in self.env:
return False
return self.env[model].sudo().browse(res_id).name_get()[0][1]
+1 -1
View File
@@ -497,7 +497,7 @@ class MailTemplate(models.Model):
report_service = report.report_name
if report.report_type in ['qweb-html', 'qweb-pdf']:
result, format = self.pool['report'].get_pdf(self._cr, self._uid, [res_id], report_service, context=Template._context), 'pdf'
result, format = Template.env['report'].get_pdf([res_id], report_service), 'pdf'
else:
result, format = odoo_report.render_report(self._cr, self._uid, [res_id], report_service, {'model': template.model}, Template._context)
+4 -5
View File
@@ -786,8 +786,7 @@ class MailThread(models.AbstractModel):
def message_capable_models(self):
""" Used by the plugin addon, based for plugin_outlook and others. """
ret_dict = {}
for model_name in self.pool.obj_list():
model = self.pool[model_name]
for model_name, model in self.env.iteritems():
if hasattr(model, "message_process") and hasattr(model, "message_post"):
ret_dict[model_name] = model._description
return ret_dict
@@ -846,9 +845,9 @@ class MailThread(models.AbstractModel):
message_id, route, message)
# Wrong model
if model and model not in self.pool:
if model and model not in self.env:
if assert_model:
assert model in self.pool, 'Routing: unknown target model %s' % model
assert model in self.env, 'Routing: unknown target model %s' % model
_warn('unknown target model %s' % model)
return ()
@@ -1025,7 +1024,7 @@ class MailThread(models.AbstractModel):
# do not match forwarded emails from another OpenERP system (thread_id collision!)
if local_hostname == reply_hostname:
thread_id, model = reply_thread_id, reply_model
if thread_id and model in self.pool:
if thread_id and model in self.env:
record = self.env[model].browse(thread_id)
compat_mail_msg_ids = MailMessage.search([
('message_id', '=', False),
+1 -1
View File
@@ -96,7 +96,7 @@ class Partner(models.Model):
# custom values
custom_values = dict()
if message.model and message.res_id and self.pool.get(message.model) and hasattr(self.pool[message.model], 'message_get_email_values'):
if message.res_id and message.model in self.env and hasattr(self.env[message.model], 'message_get_email_values'):
custom_values = self.env[message.model].browse(message.res_id).message_get_email_values(message)
mail_values = {
+1 -1
View File
@@ -115,7 +115,7 @@ class Users(models.Model):
@api.multi
def message_partner_info_from_emails(self, emails, link_mail=False):
return self.pool.get('mail.thread').message_partner_info_from_emails(emails, link_mail=link_mail)
return self.env['mail.thread'].message_partner_info_from_emails(emails, link_mail=link_mail)
@api.multi
def message_get_suggested_recipients(self):
+1 -1
View File
@@ -18,7 +18,7 @@ class Invite(models.TransientModel):
if self._context.get('mail_invite_follower_channel_only'):
result['send_mail'] = False
if 'message' in fields and model and res_id:
model_name = self.env['ir.model'].search([('model', '=', self.pool[model]._name)]).name_get()[0][1]
model_name = self.env['ir.model'].search([('model', '=', model)]).name_get()[0][1]
document_name = self.env[model].browse(res_id).name_get()[0][1]
message = _('<div><p>Hello,</p><p>%s invited you to follow %s document: %s.</p></div>') % (user_name, model_name, document_name)
result['message'] = message
+1 -1
View File
@@ -65,7 +65,7 @@ class MailComposer(models.TransientModel):
result['model'] = result.get('model', self._context.get('active_model'))
result['res_id'] = result.get('res_id', self._context.get('active_id'))
result['parent_id'] = result.get('parent_id', self._context.get('message_id'))
if 'no_auto_thread' not in result and (not result['model'] or not result['model'] in self.pool or not hasattr(self.env[result['model']], 'message_post')):
if 'no_auto_thread' not in result and (result['model'] not in self.env or not hasattr(self.env[result['model']], 'message_post')):
result['no_auto_thread'] = True
# default values according to composition mode - NOTE: reply is deprecated, fall back on comment
+1 -1
View File
@@ -282,7 +282,7 @@ class StockMove(models.Model):
if self.location_id.usage == 'customer' and self.origin_returned_move_id:
debit_value = self.origin_returned_move_id.price_unit * qty
credit_value = debit_value
partner_id = (self.picking_id.partner_id and self.pool.get('res.partner')._find_accounting_partner(self.picking_id.partner_id).id) or False
partner_id = (self.picking_id.partner_id and self.env['res.partner']._find_accounting_partner(self.picking_id.partner_id).id) or False
debit_line_vals = {
'name': self.name,
'product_id': self.product_id.id,
+2 -2
View File
@@ -97,10 +97,10 @@ class ResourceCalendar(models.Model):
for leave in leave_intervals:
if len(leave) > 2:
current_group = False
att_obj = self.pool.get("resource.calendar.attendance")
Att = self.env["resource.calendar.attendance"]
if leave[2]:
if len(current_interval) > 2:
current_group = current_interval[2] and att_obj.browse(current_interval[2]).group_id.id or False
current_group = current_interval[2] and Att.browse(current_interval[2]).group_id.id or False
if leave[2] != current_group:
continue
if leave[1] <= current_interval[0]:
+1 -1
View File
@@ -309,7 +309,7 @@ class Http(models.AbstractModel):
obj = None
if xmlid:
obj = env.ref(xmlid, False)
elif id and model in self.pool:
elif id and model in env:
obj = env[model].browse(int(id))
if obj and 'website_published' in obj._fields:
if env[obj._name].sudo().search([('id', '=', obj.id), ('website_published', '=', True)]):
+1 -1
View File
@@ -431,7 +431,7 @@
<p>Example of python code</p>
<code>
partner_name = obj.name + '_code'
self.pool["res.partner"].create(cr, uid, {"name": partner_name}, context=context)
env["res.partner"].create({"name": partner_name})
</code>
</div>
</div>
+1 -1
View File
@@ -391,7 +391,7 @@ class IrValues(models.Model):
if not value:
continue # skip if undefined
action_model, action_id = value.split(',')
if action_model not in self.pool:
if action_model not in self.env:
continue # unknown model? skip it!
action = self.env[action_model].browse(int(action_id))
actions.append((id, name, action))
+6 -6
View File
@@ -772,15 +772,15 @@ class BaseModel(object):
elif field['ttype'] in ('selection', 'reference'):
attrs['selection'] = safe_eval(field['selection'])
elif field['ttype'] == 'many2one':
if partial and field['relation'] not in self.pool:
if partial and field['relation'] not in self.env:
continue
attrs['comodel_name'] = field['relation']
attrs['ondelete'] = field['on_delete']
attrs['domain'] = safe_eval(field['domain']) if field['domain'] else None
elif field['ttype'] == 'one2many':
if partial and not (
field['relation'] in self.pool and (
field['relation_field'] in self.pool[field['relation']]._fields or
field['relation'] in self.env and (
field['relation_field'] in self.env[field['relation']]._fields or
field['relation_field'] in self.pool.get_manual_fields(self._cr, field['relation'])
)):
continue
@@ -788,7 +788,7 @@ class BaseModel(object):
attrs['inverse_name'] = field['relation_field']
attrs['domain'] = safe_eval(field['domain']) if field['domain'] else None
elif field['ttype'] == 'many2many':
if partial and field['relation'] not in self.pool:
if partial and field['relation'] not in self.env:
continue
attrs['comodel_name'] = field['relation']
rel, col1, col2 = self.env['ir.model.fields']._custom_many2many_names(field['model'], field['relation'])
@@ -2211,7 +2211,7 @@ class BaseModel(object):
:param query: query object on which the JOIN should be added
"""
inherits_field = current_model._inherits[parent_model_name]
parent_model = self.pool[parent_model_name]
parent_model = self.env[parent_model_name]
parent_alias, parent_alias_statement = query.add_join((current_model._table, parent_model._table, inherits_field, 'id', inherits_field), implicit=True)
return parent_alias
@@ -2684,7 +2684,7 @@ class BaseModel(object):
_schema.debug(msg, self._table, name, column._type)
if isinstance(column, fields.many2one) or (isinstance(column, fields.function) and column._type == 'many2one' and column.store):
dest_model = self.pool[column._obj]
dest_model = self.env[column._obj]
if dest_model._auto and dest_model._table != 'ir_actions':
self._m2o_fix_foreign_key(self._table, name, dest_model, column.ondelete)