[MERGE] forward port branch saas-14 up to 556b59bce1
This commit is contained in:
@@ -148,6 +148,7 @@ class MailMail(models.Model):
|
|||||||
if notif_emails:
|
if notif_emails:
|
||||||
notifications = self.env['mail.notification'].search([
|
notifications = self.env['mail.notification'].search([
|
||||||
('mail_message_id', 'in', notif_emails.mapped('mail_message_id').ids),
|
('mail_message_id', 'in', notif_emails.mapped('mail_message_id').ids),
|
||||||
|
('res_partner_id', 'in', notif_emails.mapped('recipient_ids').ids),
|
||||||
('is_email', '=', True)])
|
('is_email', '=', True)])
|
||||||
if mail_sent:
|
if mail_sent:
|
||||||
notifications.write({
|
notifications.write({
|
||||||
@@ -322,6 +323,7 @@ class MailMail(models.Model):
|
|||||||
notifs = self.env['mail.notification'].search([
|
notifs = self.env['mail.notification'].search([
|
||||||
('is_email', '=', True),
|
('is_email', '=', True),
|
||||||
('mail_message_id', 'in', mail.mapped('mail_message_id').ids),
|
('mail_message_id', 'in', mail.mapped('mail_message_id').ids),
|
||||||
|
('res_partner_id', 'in', mail.mapped('recipient_ids').ids),
|
||||||
('email_status', 'not in', ('sent', 'canceled'))
|
('email_status', 'not in', ('sent', 'canceled'))
|
||||||
])
|
])
|
||||||
if notifs:
|
if notifs:
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
'name': 'test_convert',
|
'name': 'test_convert',
|
||||||
'description': "Data for xml conversion tests",
|
'description': "Data for xml conversion tests",
|
||||||
'version': '0.0.1',
|
'version': '0.0.1',
|
||||||
|
'data': ['ir.model.access.csv'],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_test_convert_test_model,access_test_convert_test_model,model_test_convert_test_model,,1,1,1,1
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
class TestModel(models.Model):
|
||||||
|
_name = 'test_convert.test_model'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def action_test_date(self, today_date):
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def action_test_time(self, cur_time):
|
||||||
|
return True
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def action_test_timezone(self, timezone):
|
||||||
|
return True
|
||||||
@@ -4,8 +4,10 @@
|
|||||||
import collections
|
import collections
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from lxml import etree as ET
|
||||||
from lxml.builder import E
|
from lxml.builder import E
|
||||||
|
|
||||||
|
import odoo
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
from odoo.tools.convert import _eval_xml
|
from odoo.tools.convert import _eval_xml
|
||||||
|
|
||||||
@@ -16,6 +18,25 @@ class TestEvalXML(common.TransactionCase):
|
|||||||
def eval_xml(self, node, obj=None):
|
def eval_xml(self, node, obj=None):
|
||||||
return _eval_xml(obj, node, self.env)
|
return _eval_xml(obj, node, self.env)
|
||||||
|
|
||||||
|
def test_function_eval(self):
|
||||||
|
def id_get(): pass
|
||||||
|
Obj = collections.namedtuple('Obj', ['module', 'idref', 'id_get'])
|
||||||
|
obj = Obj('test_convert', {}, id_get)
|
||||||
|
|
||||||
|
try:
|
||||||
|
test_datetime = ET.XML("<function name='action_test_date' model='test_convert.test_model' eval='[datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")]'/>")
|
||||||
|
self.eval_xml(node=test_datetime, obj=obj)
|
||||||
|
test_time = ET.XML("<function name='action_test_time' model='test_convert.test_model' eval='[time.strftime(\"%Y-%m-%d %H:%M:%S\")]'/>")
|
||||||
|
self.eval_xml(node=test_time, obj=obj)
|
||||||
|
test_timedelta = ET.XML("<function name='action_test_date' model='test_convert.test_model' eval='[(datetime.today()-timedelta(days=365)).strftime(\"%Y-%m-%d %H:%M:%S\")]'/>")
|
||||||
|
self.eval_xml(node=test_timedelta, obj=obj)
|
||||||
|
test_relativedelta = ET.XML("<function name='action_test_date' model='test_convert.test_model' eval='[(datetime.today()+relativedelta(months=3)).strftime(\"%Y-%m-%d %H:%M:%S\")]'/>")
|
||||||
|
self.eval_xml(node=test_relativedelta, obj=obj)
|
||||||
|
test_timezone = ET.XML("<function name='action_test_timezone' model='test_convert.test_model' eval='[pytz.timezone(\"Asia/Calcutta\")]'/>")
|
||||||
|
self.eval_xml(node=test_timezone, obj=obj)
|
||||||
|
except ValueError as e:
|
||||||
|
self.fail(e.message)
|
||||||
|
|
||||||
def test_char(self):
|
def test_char(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.eval_xml(Field("foo")),
|
self.eval_xml(Field("foo")),
|
||||||
|
|||||||
@@ -177,15 +177,16 @@ def _eval_xml(self, node, env):
|
|||||||
elif node.tag == "function":
|
elif node.tag == "function":
|
||||||
args = []
|
args = []
|
||||||
a_eval = node.get('eval','')
|
a_eval = node.get('eval','')
|
||||||
|
model_str = node.get('model', '')
|
||||||
# FIXME: should probably be exclusive
|
# FIXME: should probably be exclusive
|
||||||
if a_eval:
|
if a_eval:
|
||||||
self.idref['ref'] = self.id_get
|
idref2 = _get_idref(self, env, model_str, self.idref)
|
||||||
args = safe_eval(a_eval, self.idref)
|
args = safe_eval(a_eval, idref2)
|
||||||
for n in node:
|
for n in node:
|
||||||
return_val = _eval_xml(self, n, env)
|
return_val = _eval_xml(self, n, env)
|
||||||
if return_val is not None:
|
if return_val is not None:
|
||||||
args.append(return_val)
|
args.append(return_val)
|
||||||
model = env[node.get('model', '')]
|
model = env[model_str]
|
||||||
method = node.get('name')
|
method = node.get('name')
|
||||||
# this one still depends on the old API
|
# this one still depends on the old API
|
||||||
return odoo.api.call_kw(model, method, args, {})
|
return odoo.api.call_kw(model, method, args, {})
|
||||||
|
|||||||
Reference in New Issue
Block a user