[PATCH] Upstream patch - 05102021

This commit is contained in:
Parthiv Patel committed 2021-10-05 09:36:19 +00:00
1 parent ebd3f22b29
commit 3cb2d898c7
17 files changed
+219 -73

No files matched your search

@@ -207,7 +207,7 @@ class AccountBankStatement(models.Model):
# will find the record itself, so we have to add a condition in the search to ignore self.id
if not isinstance(st.id, models.NewId):
domain.extend(['|', '&', ('id', '<', st.id), ('date', '=', st.date), '&', ('id', '!=', st.id), ('date', '!=', st.date)])
previous_statement = self.search(domain, limit=1)
previous_statement = self.search(domain, limit=1, order='date desc, id desc')
st.previous_statement_id = previous_statement.id
name = fields.Char(string='Reference', states={'open': [('readonly', False)]}, copy=False, readonly=True)
+1 -1
View File
@@ -4296,7 +4296,7 @@ class AccountMoveLine(models.Model):
}
def _get_tracking_field_string(self, fields):
ARROW_RIGHT = '<span aria-label="Changed" class="fa fa-long-arrow-alt-right" role="img" title="Changed"></span>'
ARROW_RIGHT = '<div class="o_Message_trackingValueSeparator o_Message_trackingValueItem fa fa-long-arrow-right" title="Changed" role="img"/>'
msg = '<ul>'
for field in fields:
redirect_link = '<a href=# data-oe-model=account.move.line data-oe-id=%d>#%d</a>' % (field['line_id'], field['line_id']) # Account move line link
@@ -135,6 +135,9 @@ class AccountAnalyticLine(models.Model):
return etree.tostring(doc, encoding='unicode')
def _timesheet_get_portal_domain(self):
if self.env.user.has_group('hr_timesheet.group_hr_timesheet_user'):
# Then, he is internal user, and we take the domain for this current user
return self.env['ir.rule']._compute_domain(self._name)
return ['&',
'|', '|', '|',
('task_id.project_id.message_partner_ids', 'child_of', [self.env.user.partner_id.commercial_partner_id.id]),
+1 -1
View File
@@ -188,7 +188,7 @@ class AccountMove(models.Model):
# OVERRIDE
posted = super()._post(soft=soft)
for move in posted.filtered(lambda m: m.l10n_it_send_state == 'to_send' and m.move_type == 'out_invoice' and m.company_id.country_id.code == 'IT'):
for move in posted.filtered(lambda m: m.l10n_it_send_state == 'to_send' and m.move_type in ['out_invoice', 'out_refund'] and m.company_id.country_id.code == 'IT'):
move.send_pec_mail()
return posted
+6 -8
View File
@@ -15,17 +15,14 @@ from flectra.addons.base.models.res_partner import _tz_get
WEEKDAY_TO_NAME = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
def float_to_time(hours, moment='am', tz=None):
def float_to_time(hours, moment='am'):
""" Convert a number of hours into a time object. """
if hours == 12.0 and moment == 'pm':
return time.max
fractional, integral = math.modf(hours)
if moment == 'pm':
integral += 12
res = time(int(integral), int(float_round(60 * fractional, precision_digits=0)), 0)
if tz:
res = res.replace(tzinfo=pytz.timezone(tz))
return res
return time(int(integral), int(float_round(60 * fractional, precision_digits=0)), 0)
def time_to_float(t):
return float_round(t.hour + t.minute/60 + t.second/3600, precision_digits=2)
@@ -122,9 +119,10 @@ class LunchSupplier(models.Model):
records = self.search([('send_by', '=', 'mail')])
for supplier in records:
send_at = datetime.combine(fields.Date.today(),
float_to_time(supplier.automatic_email_time, supplier.moment, supplier.tz)).astimezone(pytz.UTC).replace(tzinfo=None)
if supplier.available_today and fields.Datetime.now() > send_at:
hours = float_to_time(supplier.automatic_email_time, supplier.moment)
date_tz = pytz.timezone(supplier.tz).localize(datetime.combine(fields.Date.today(), hours))
date_utc = date_tz.astimezone(pytz.UTC).replace(tzinfo=None)
if supplier.available_today and fields.Datetime.now() > date_utc:
lines = self.env['lunch.order'].search([('supplier_id', '=', supplier.id),
('state', '=', 'ordered'), ('date', '=', fields.Date.today())])
+2 -1
View File
@@ -958,9 +958,10 @@ class MailActivityMixin(models.AbstractModel):
'date_deadline': date_deadline,
'res_model_id': model_id,
'res_id': record.id,
'user_id': act_values.get('user_id') or activity_type.default_user_id.id or self.env.uid
}
create_vals.update(act_values)
if not create_vals.get('user_id'):
create_vals['user_id'] = activity_type.default_user_id.id or self.env.uid
activities |= self.env['mail.activity'].create(create_vals)
return activities
+1
View File
@@ -923,6 +923,7 @@ class MailCommon(common.SavepointCase, MailCase):
cls.env, login='employee_c2',
groups='base.group_user',
company_id=cls.company_2.id,
company_ids=[(4, cls.company_2.id)],
name='Enguerrand Employee C2',
notification_type='inbox',
signature='--\nEnguerrand'
+2 -1
View File
@@ -30,7 +30,8 @@ class SaleOrder(models.Model):
def recompute_coupon_lines(self):
for order in self:
order._remove_invalid_reward_lines()
order._create_new_no_code_promo_reward_lines()
if order.state != 'cancel':
order._create_new_no_code_promo_reward_lines()
order._update_existing_reward_lines()
@api.returns('self', lambda value: value.id)
@@ -113,15 +113,14 @@
</t>
<!-- Scoring info -->
<t t-if="question_scoring">
<t t-if="question.question_type in ['simple_choice', 'multiple_choice']">
<t t-if="question.question_type in ['simple_choice', 'multiple_choice'] or question.is_scored_question">
<span class="badge badge-success ml-3"><span t-esc="question_data['right_inputs_count']"></span> Correct</span>
</t>
<t t-if="question.question_type in ['simple_choice', 'multiple_choice']">
<span class="badge badge-warning ml-1" t-if="question.question_type == 'multiple_choice'">
<span t-esc="question_data['partial_inputs_count']"></span> Partial
</span>
</t>
<t t-if="question.is_scored_question">
<span class="badge badge-success ml-3"><span t-esc="question_data['right_inputs_count']"></span> Correct</span>
</t>
</t>
<!-- Inputs info -->
<span class="badge badge-info ml-3"><span t-esc="len(question_data['answer_input_done_ids'])"></span> Answered</span>
+1
View File
@@ -10,6 +10,7 @@ from . import test_mail_mail
from . import test_mail_channel
from . import test_mail_channel_partner
from . import test_mail_gateway
from . import test_mail_multicompany
from . import test_mail_thread_internals
from . import test_mail_template
from . import test_mail_tools
@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
import socket
from flectra.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from flectra.tests import tagged
from flectra.tests.common import users
from flectra.tools import formataddr
@tagged('multi_company')
class TestMultiCompanySetup(TestMailCommon, TestRecipients):
@classmethod
def setUpClass(cls):
super(TestMultiCompanySetup, cls).setUpClass()
cls._activate_multi_company()
cls.test_model = cls.env['ir.model']._get('mail.test.gateway')
cls.email_from = '"Sylvie Lelitre" <test.sylvie.lelitre@agrolait.com>'
cls.test_record = cls.env['mail.test.gateway'].with_context(cls._test_context).create({
'name': 'Test',
'email_from': 'ignasse@example.com',
}).with_context({})
cls.partner_1 = cls.env['res.partner'].with_context(cls._test_context).create({
'name': 'Valid Lelitre',
'email': 'valid.lelitre@agrolait.com',
})
# groups@.. will cause the creation of new mail.test.gateway
cls.alias = cls.env['mail.alias'].create({
'alias_name': 'groups',
'alias_user_id': False,
'alias_model_id': cls.test_model.id,
'alias_contact': 'everyone'})
# Set a first message on public group to test update and hierarchy
cls.fake_email = cls.env['mail.message'].create({
'model': 'mail.test.gateway',
'res_id': cls.test_record.id,
'subject': 'Public Discussion',
'message_type': 'email',
'subtype_id': cls.env.ref('mail.mt_comment').id,
'author_id': cls.partner_1.id,
'message_id': '<123456-openerp-%s-mail.test.gateway@%s>' % (cls.test_record.id, socket.gethostname()),
})
cls._init_mail_gateway()
@users('employee')
def test_notify_reply_to_computation(self):
test_record = self.env['mail.test.gateway'].browse(self.test_record.ids)
res = test_record._notify_get_reply_to()
self.assertEqual(
res[test_record.id],
formataddr((
"%s %s" % (self.user_employee.company_id.name, test_record.name),
"%s@%s" % (self.alias_catchall, self.alias_domain)))
)
@users('employee_c2')
def test_notify_reply_to_computation_mc(self):
""" Test reply-to computation in multi company mode. Add notably tests
depending on user company_id / company_ids. """
# Test1: no company_id field
test_record = self.env['mail.test.gateway'].browse(self.test_record.ids)
res = test_record._notify_get_reply_to()
self.assertEqual(
res[test_record.id],
formataddr((
"%s %s" % (self.user_employee_c2.company_id.name, test_record.name),
"%s@%s" % (self.alias_catchall, self.alias_domain)))
)
# Test2: company_id field, MC environment
self.user_employee_c2.write({'company_ids': [(4, self.user_employee.company_id.id)]})
test_records = self.env['mail.test.multi.company'].create([
{'name': 'Test',
'company_id': self.user_employee.company_id.id},
{'name': 'Test',
'company_id': self.user_employee_c2.company_id.id},
])
res = test_records._notify_get_reply_to()
for test_record in test_records:
self.assertEqual(
res[test_record.id],
formataddr((
"%s %s" % (self.user_employee_c2.company_id.name, test_record.name),
"%s@%s" % (self.alias_catchall, self.alias_domain)))
)
+58 -16
View File
@@ -31,12 +31,23 @@ class BaseMailPerformance(TransactionCaseWithUserDemo):
# patch registry to simulate a ready environment
self.patch(self.env.registry, 'ready', True)
def _init_mail_gateway(self):
# setup mail gateway
self.alias_domain = 'example.com'
self.alias_catchall = 'catchall.test'
self.alias_bounce = 'bounce.test'
self.default_from = 'notifications'
self.env['ir.config_parameter'].set_param('mail.bounce.alias', self.alias_bounce)
self.env['ir.config_parameter'].set_param('mail.catchall.domain', self.alias_domain)
self.env['ir.config_parameter'].set_param('mail.catchall.alias', self.alias_catchall)
self.env['ir.config_parameter'].set_param('mail.default.from', self.default_from)
@tagged('mail_performance')
class TestMailPerformance(BaseMailPerformance):
class TestBaseMailPerformance(BaseMailPerformance):
def setUp(self):
super(TestMailPerformance, self).setUp()
super(TestBaseMailPerformance, self).setUp()
self.res_partner_3 = self.env['res.partner'].create({
'name': 'Gemini Furniture',
@@ -78,6 +89,8 @@ class TestMailPerformance(BaseMailPerformance):
}
])
self._init_mail_gateway()
@users('__system__', 'demo')
@warmup
def test_read_mail(self):
@@ -147,13 +160,13 @@ class TestMailPerformance(BaseMailPerformance):
@warmup
def test_create_mail_with_tracking(self):
""" Create records inheriting from 'mail.thread' (with field tracking). """
with self.assertQueryCount(__system__=7, demo=7):
with self.assertQueryCount(__system__=8, demo=8):
self.env['mail.performance.thread'].create({'name': 'X'})
@users('__system__', 'emp')
@warmup
def test_create_mail_simple(self):
with self.assertQueryCount(__system__=6, emp=6):
with self.assertQueryCount(__system__=7, emp=7):
self.env['mail.test.simple'].create({'name': 'Test'})
@users('__system__', 'emp')
@@ -184,6 +197,8 @@ class TestMailAPIPerformance(BaseMailPerformance):
'groups_id': [(6, 0, [self.env.ref('base.group_user').id])],
})
self._init_mail_gateway()
# automatically follow activities, for backward compatibility concerning query count
self.env.ref('mail.mt_activities').write({'default': True})
@@ -209,7 +224,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_adv_activity(self):
model = self.env['mail.test.activity']
with self.assertQueryCount(__system__=6, emp=6):
with self.assertQueryCount(__system__=7, emp=7):
model.create({'name': 'Test'})
@users('__system__', 'emp')
@@ -231,7 +246,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
#voip module read activity_type during create leading to one less query in enterprise on action_feedback
category = activity.activity_type_id.category
with self.assertQueryCount(__system__=16, emp=20):
with self.assertQueryCount(__system__=17, emp=21):
activity.action_feedback(feedback='Zizisse Done !')
@users('__system__', 'emp')
@@ -248,7 +263,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
record.write({'name': 'Dupe write'})
with self.assertQueryCount(__system__=17, emp=20):
with self.assertQueryCount(__system__=18, emp=21):
record.action_close('Dupe feedback')
self.assertEqual(record.activity_ids, self.env['mail.activity'])
@@ -352,7 +367,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_log_with_post(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(__system__=3, emp=6):
with self.assertQueryCount(__system__=4, emp=7):
record.message_post(
body='<p>Test message_post as log</p>',
subtype_xmlid='mail.mt_note',
@@ -363,7 +378,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_post_no_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(__system__=3, emp=6):
with self.assertQueryCount(__system__=4, emp=7):
record.message_post(
body='<p>Test Post Performances basic</p>',
partner_ids=[],
@@ -388,7 +403,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_post_one_inbox_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(__system__=12, emp=17):
with self.assertQueryCount(__system__=13, emp=18):
record.message_post(
body='<p>Test Post Performances with an inbox ping</p>',
partner_ids=self.user_test.partner_id.ids,
@@ -439,6 +454,32 @@ class TestMailAPIPerformance(BaseMailPerformance):
record.write({'field_%s' % (i): 'Field With Cache %s' % (i) for i in range(3)})
record.flush()
@users('__system__', 'emp')
@warmup
def test_notification_reply_to_batch(self):
test_records_sudo = self.env['mail.test.container'].sudo().create([
{'alias_name': 'alias.test.%s.%d' % (self.env.user.name, index),
'customer_id': self.customer.id,
'name': 'Test_%d' % index,
} for index in range(10)
])
with self.assertQueryCount(__system__=1, emp=1):
test_records = self.env['mail.test.container'].browse(test_records_sudo.ids)
reply_to = test_records._notify_get_reply_to(
default=self.env.user.email_formatted
)
for record in test_records:
self.assertEqual(
reply_to[record.id],
formataddr(
("%s %s" % (self.env.user.company_id.name, record.name),
"%s@%s" % (record.alias_name, self.alias_domain)
)
)
)
@tagged('mail_performance')
class TestMailComplexPerformance(BaseMailPerformance):
@@ -453,11 +494,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
'notification_type': 'email',
'groups_id': [(6, 0, [self.env.ref('base.group_portal').id])],
})
# setup mail gateway
self.env['ir.config_parameter'].sudo().set_param('mail.catchall.domain', 'example.com')
self.env['ir.config_parameter'].sudo().set_param('mail.catchall.alias', 'test-catchall')
self.env['ir.config_parameter'].sudo().set_param('mail.bounce.alias', 'test-bounce')
self.admin = self.env.user
self.channel = self.env['mail.channel'].with_context(self._quick_create_ctx).create({
'name': 'Listener',
@@ -481,6 +518,9 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.env.ref('mail.mt_comment').id,
self.env.ref('test_mail.st_mail_test_container_child_full').id]
)
self._init_mail_gateway()
# `test_complex_mail_mail_send`
self.container.flush()
@@ -981,6 +1021,8 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
'res_id': 0,
} for i in range(3)]
self._init_mail_gateway()
self.patch(self.env.registry, 'ready', True)
@mute_logger('flectra.tests', 'flectra.addons.mail.models.mail_mail', 'flectra.models.unlink')
@@ -998,7 +1040,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
]
self.attachements = self.env['ir.attachment'].with_user(self.env.user).create(self.vals)
attachement_ids = self.attachements.ids
with self.assertQueryCount(emp=80):
with self.assertQueryCount(emp=79):
self.cr.sql_log = self.warm and self.cr.sql_log_count
record.with_context({}).message_post(
body='<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>',
@@ -42,6 +42,8 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase):
'country_id': self.env.ref('base.be').id,
})
self._init_mail_gateway()
# patch registry to simulate a ready environment
self.patch(self.env.registry, 'ready', True)
@@ -51,7 +53,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase):
def test_message_sms_record_1_partner(self):
record = self.test_record.with_user(self.env.user)
pids = self.customer.ids
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=23): # test_mail_enterprise: 18
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=25): # test_mail_enterprise: 25
messages = record._message_sms(
body='Performance Test',
partner_ids=pids,
@@ -66,7 +68,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase):
def test_message_sms_record_10_partners(self):
record = self.test_record.with_user(self.env.user)
pids = self.partners.ids
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=41):
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=43):
messages = record._message_sms(
body='Performance Test',
partner_ids=pids,
@@ -80,7 +82,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.SMSCase):
@warmup
def test_message_sms_record_default(self):
record = self.test_record.with_user(self.env.user)
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=26):
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=27):
messages = record._message_sms(
body='Performance Test',
)
@@ -143,7 +145,7 @@ class TestSMSMassPerformance(BaseMailPerformance, sms_common.MockSMS):
})
with self.mockSMSGateway(sms_allow_unlink=True), self.assertQueryCount(employee=106):
composer.action_send_sms()
composer.action_send_sms()
@mute_logger('flectra.addons.sms.models.sms_sms')
@users('employee')
@@ -22,6 +22,16 @@ class TestMassMailPerformanceBase(TransactionCase):
groups='base.group_user,mass_mailing.group_mass_mailing_user',
name='Martial Marketing', signature='--\nMartial')
# setup mail gateway
self.alias_domain = 'example.com'
self.alias_catchall = 'catchall.test'
self.alias_bounce = 'bounce.test'
self.default_from = 'notifications'
self.env['ir.config_parameter'].set_param('mail.bounce.alias', self.alias_bounce)
self.env['ir.config_parameter'].set_param('mail.catchall.domain', self.alias_domain)
self.env['ir.config_parameter'].set_param('mail.catchall.alias', self.alias_catchall)
self.env['ir.config_parameter'].set_param('mail.default.from', self.default_from)
# patch registry to simulate a ready environment
self.patch(self.env.registry, 'ready', True)
@@ -51,7 +61,7 @@ class TestMassMailPerformance(TestMassMailPerformanceBase):
})
# runbot needs +51 compared to local
with self.assertQueryCount(__system__=1715, marketing=1716): # test_mass_mailing_only: 1664 - 1665
with self.assertQueryCount(__system__=1717, marketing=1718): # test_mass_mailing_only: 1665 - 1666
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)
@@ -91,7 +101,7 @@ class TestMassMailBlPerformance(TestMassMailPerformanceBase):
})
# runbot needs +63 compared to local
with self.assertQueryCount(__system__=1992, marketing=1993): # test_mass_mailing only: 1929 - 1930
with self.assertQueryCount(__system__=1994, marketing=1995): # test_mass_mailing only: 1931 - 1932
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)
+13 -15
View File
@@ -384,7 +384,7 @@
if (groupType === "LEFT_BRACE" &&
isLeftSeparator(prevToken) &&
isRightSeparator(nextToken)) {
tokens.splice(i + 1, 0, { type: "COLON", value: ":" }, { ...token });
tokens.splice(i + 1, 0, { type: "COLON", value: ":" }, Object.assign({}, token));
nextToken = tokens[i + 1];
}
if (prevToken.type === "OPERATOR" && prevToken.value === ".") {
@@ -1614,6 +1614,9 @@
* template, with the name given by the t-name attribute.
*/
addTemplates(xmlstr) {
if (!xmlstr) {
return;
}
const doc = typeof xmlstr === "string" ? parseXML(xmlstr) : xmlstr;
const templates = doc.getElementsByTagName("templates")[0];
if (!templates) {
@@ -1823,7 +1826,7 @@
return;
}
if (node.tagName !== "t" && node.hasAttribute("t-call")) {
const tCallNode = document.createElement("t");
const tCallNode = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "t", null).documentElement;
tCallNode.setAttribute("t-call", node.getAttribute("t-call"));
node.removeAttribute("t-call");
node.prepend(tCallNode);
@@ -1850,7 +1853,7 @@
throw new Error(`Unknown QWeb directive: '${attrName}'`);
}
if (node.tagName !== "t" && (attrName === "t-esc" || attrName === "t-raw")) {
const tNode = document.createElement("t");
const tNode = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "t", null).documentElement;
tNode.setAttribute(attrName, node.getAttribute(attrName));
for (let child of Array.from(node.childNodes)) {
tNode.appendChild(child);
@@ -2905,7 +2908,9 @@
},
});
const config = {};
const config = {
translatableAttributes: TRANSLATABLE_ATTRS,
};
Object.defineProperty(config, "mode", {
get() {
return QWeb.dev ? "dev" : "prod";
@@ -2918,9 +2923,6 @@
This is not suitable for production use.
See https://github.com/flectra/owl/blob/master/doc/reference/config.md#mode for more information.`);
}
else {
console.log(`Owl is now running in 'prod' mode.`);
}
},
});
Object.defineProperty(config, "enableTransitions", {
@@ -3656,6 +3658,7 @@ See https://github.com/flectra/owl/blob/master/doc/reference/config.md#mode for
// build patchQueue
const patchQueue = [];
const doWork = function (f) {
f.component.__owl__.currentFiber = null;
patchQueue.push(f);
return f.child;
};
@@ -3712,10 +3715,6 @@ See https://github.com/flectra/owl/blob/master/doc/reference/config.md#mode for
component.__owl__.pvnode.elm = component.__owl__.vnode.elm;
}
}
const compOwl = component.__owl__;
if (fiber === compOwl.currentFiber) {
compOwl.currentFiber = null;
}
}
// insert into the DOM (mount case)
let inDOM = false;
@@ -4369,7 +4368,6 @@ See https://github.com/flectra/owl/blob/master/doc/reference/config.md#mode for
__callMounted() {
const __owl__ = this.__owl__;
__owl__.status = 3 /* MOUNTED */;
__owl__.currentFiber = null;
this.mounted();
if (__owl__.mountedCB) {
__owl__.mountedCB();
@@ -5544,9 +5542,9 @@ See https://github.com/flectra/owl/blob/master/doc/reference/config.md#mode for
exports.utils = utils;
__info__.version = '1.4.4';
__info__.date = '2021-09-03T08:19:48.452Z';
__info__.hash = 'b3181f1';
__info__.version = '1.4.6';
__info__.date = '2021-10-04T13:18:44.608Z';
__info__.hash = 'c0f4956';
__info__.url = 'https://github.com/flectra/owl';
@@ -2088,22 +2088,13 @@ var FieldBinaryFile = AbstractFieldBinary.extend({
this.filename_value = this.recordData[this.attrs.filename];
},
_renderReadonly: function () {
this.do_toggle(!!this.value);
if (this.value) {
this.$el.empty().append($("<span/>").addClass('fa fa-download'));
if (this.recordData.id) {
this.$el.css('cursor', 'pointer');
} else {
this.$el.css('cursor', 'not-allowed');
}
if (this.filename_value) {
this.$el.append(" " + this.filename_value);
}
}
if (!this.res_id) {
this.$el.css('cursor', 'not-allowed');
} else {
this.$el.css('cursor', 'pointer');
var visible = !!(this.value && this.res_id);
this.$el.empty().css('cursor', 'not-allowed');
this.do_toggle(visible);
if (visible) {
this.$el.css('cursor', 'pointer')
.text(this.filename_value || '')
.prepend($('<span class="fa fa-download"/>'), ' ');
}
},
_renderEdit: function () {
@@ -2441,7 +2441,7 @@ QUnit.module('basic_fields', {
});
QUnit.test('binary fields that are readonly in create mode do not download', async function (assert) {
assert.expect(2);
assert.expect(4);
// save the session function
var oldGetFile = session.get_file;
@@ -2473,10 +2473,17 @@ QUnit.module('basic_fields', {
await testUtils.fields.many2one.clickOpenDropdown('product_id');
await testUtils.fields.many2one.clickHighlightedItem('product_id');
assert.containsOnce(form, 'a.o_field_widget[name="document"] > .fa-download',
assert.containsOnce(form, 'a.o_field_widget[name="document"]',
'The link to download the binary should be present');
assert.containsNone(form, 'a.o_field_widget[name="document"] > .fa-download',
'The download icon should not be present');
testUtils.dom.click(form.$('a.o_field_widget[name="document"]'));
var link = form.$('a.o_field_widget[name="document"]');
assert.ok(link.is(':hidden'), "the link element should not be visible");
// force visibility to test that the clicking has also been disabled
link.removeClass('o_hidden');
testUtils.dom.click(link);
assert.verifySteps([]); // We shouldn't have passed through steps