[IMP] base, mail: action server: remove deprecated code

This commit is contained in:
Jeremy Kersten
2016-11-21 12:56:59 +01:00
parent 1f34c507c7
commit 651976521b
3 changed files with 15 additions and 27 deletions
+3 -3
View File
@@ -48,8 +48,8 @@ class ServerActions(models.Model):
to the currently executed action will be set in the queue instead of
sent directly. This will avoid possible break in transactions. """
eval_context = super(ServerActions, self)._get_eval_context(action=action)
# re-dictify, because eval_context['context'] is a frozendict
ctx = dict(eval_context.get('context', {}))
ctx = dict(eval_context['env'].context)
ctx['mail_notify_force_send'] = False
eval_context['context'] = ctx
eval_context['env'].context = ctx
return eval_context
+3 -14
View File
@@ -9,7 +9,7 @@ import time
from pytz import timezone
import odoo
from odoo import api, fields, models, tools, workflow, _
from odoo import api, fields, models, tools, _
from odoo.exceptions import MissingError, UserError, ValidationError
from odoo.report.report_sxw import report_sxw, report_rml
from odoo.tools.safe_eval import safe_eval, test_python_expr
@@ -920,17 +920,6 @@ class IrActionsServer(models.Model):
# record
'record': record,
'records': records,
# TODO: REMOVE ME IN saas-14
'workflow': workflow,
# deprecated use record, records
'object': record,
'obj': record,
# Deprecated use env or model instead
'pool': self.pool,
'cr': self._cr,
'context': self._context,
'user': self.env.user,
# helpers
'log': log,
})
@@ -967,7 +956,7 @@ class IrActionsServer(models.Model):
if not expr:
continue
# call the multi method
run_self = self.with_context(eval_context['context'])
run_self = self.with_context(eval_context['env'].context)
func = getattr(run_self, 'run_action_%s_multi' % action.state)
res = func(action, eval_context=eval_context)
@@ -977,7 +966,7 @@ class IrActionsServer(models.Model):
for active_id in active_ids:
# run context dedicated to a particular active_id
run_self = self.with_context(active_ids=[active_id], active_id=active_id)
eval_context["context"] = run_self._context
eval_context["env"].context = run_self._context
expr = safe_eval(str(condition), eval_context)
if not expr:
continue
+9 -10
View File
@@ -46,7 +46,7 @@ class TestServerActionsBase(common.TransactionCase):
'condition': 'True',
'model_id': self.res_partner_model.id,
'state': 'code',
'code': 'obj.write({"comment": "MyComment"})',
'code': 'record.write({"comment": "MyComment"})',
})
@@ -82,9 +82,8 @@ class TestServerActions(TestServerActionsBase):
def test_10_code(self):
self.action.write({
'state': 'code',
'code': ("partner_name = obj.name + '_code'\n"
"obj.env['res.partner'].create({'name': partner_name})\n"
"workflow"),
'code': ("partner_name = record.name + '_code'\n"
"record.env['res.partner'].create({'name': partner_name})"),
})
run_res = self.action.with_context(self.context).run()
self.assertFalse(run_res, 'ir_actions_server: code server action correctly finished should return False')
@@ -104,7 +103,7 @@ class TestServerActions(TestServerActionsBase):
'condition': 'True',
'model_id': self.res_partner_model.id,
'state': 'code',
'code': 'obj.write({"comment": "MyComment"})',
'code': 'record.write({"comment": "MyComment"})',
})
action3 = self.action.create({
'name': 'TestAction3',
@@ -112,7 +111,7 @@ class TestServerActions(TestServerActionsBase):
'condition': 'True',
'model_id': self.res_country_model.id,
'state': 'code',
'code': 'obj.write({"code": "ZZ"})',
'code': 'record.write({"code": "ZZ"})',
})
# Data: create workflows
@@ -253,8 +252,8 @@ class TestServerActions(TestServerActionsBase):
'crud_model_id': self.res_country_model.id,
'link_new_record': False,
'fields_lines': [(5,),
(0, 0, {'col1': self.res_country_name_field.id, 'value': 'obj.name', 'type': 'equation'}),
(0, 0, {'col1': self.res_country_code_field.id, 'value': 'obj.name[0:2]', 'type': 'equation'})],
(0, 0, {'col1': self.res_country_name_field.id, 'value': 'record.name', 'type': 'equation'}),
(0, 0, {'col1': self.res_country_code_field.id, 'value': 'record.name[0:2]', 'type': 'equation'})],
})
run_res = self.action.with_context(self.context).run()
self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False')
@@ -303,7 +302,7 @@ class TestServerActions(TestServerActionsBase):
'use_write': 'other',
'crud_model_id': self.res_country_model.id,
'ref_object': 'res.country,%s' % self.test_country.id,
'fields_lines': [(5,), (0, 0, {'col1': self.res_country_name_field.id, 'value': 'obj.name', 'type': 'equation'})],
'fields_lines': [(5,), (0, 0, {'col1': self.res_country_name_field.id, 'value': 'record.name', 'type': 'equation'})],
})
run_res = self.action.with_context(self.context).run()
self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False')
@@ -315,7 +314,7 @@ class TestServerActions(TestServerActionsBase):
self.action.write({
'use_write': 'expression',
'crud_model_id': self.res_country_model.id,
'write_expression': 'object.country_id',
'write_expression': 'record.country_id',
'fields_lines': [(5,), (0, 0, {'col1': self.res_country_name_field.id, 'value': 'NewCountry', 'type': 'value'})],
})
run_res = self.action.with_context(self.context).run()