summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-22 16:38:01 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-22 16:38:01 +0100
commit950d9b2369046f2e3199d144df8edbd0e63f8a2f (patch)
treebef25949654cb8832d646e12e1eafd5450e6f744 /addons
parent8b5440c2b4515dc45af2b0ef38e4081c33036643 (diff)
parentdfe7f00e781503b01ec2b68df90a3f19c0060933 (diff)
[MERGE] forward port branch saas-16 up to dfe7f00e781
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_expense/views/hr_expense_views.xml6
-rw-r--r--addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py2
-rw-r--r--addons/payment_authorize/models/payment.py2
-rw-r--r--addons/payment_stripe/static/src/js/stripe.js2
-rw-r--r--addons/purchase/models/purchase.py8
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js3
-rw-r--r--addons/web_editor/static/src/js/editor/summernote.js66
7 files changed, 60 insertions, 29 deletions
diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml
index 05a7c50952c..c1e658fc042 100644
--- a/addons/hr_expense/views/hr_expense_views.xml
+++ b/addons/hr_expense/views/hr_expense_views.xml
@@ -27,13 +27,13 @@
<field eval="25" name="priority"/>
<field name="arch" type="xml">
<form string="Expenses" class="o_expense_form">
- <header>
+ <header invisible="context.get('expense_adding_line')">
<button name="submit_expenses" states="draft" string="Submit to Manager" type="object" class="oe_highlight o_expense_submit"/>
<field name="state" widget="statusbar" statusbar_visible="draft,reported,done"/>
<button name="view_sheet" type="object" string="View Report" class="oe_highlight" attrs="{'invisible': [('state', '=','draft')]}"/>
</header>
<sheet>
- <div class="oe_button_box">
+ <div class="oe_button_box" invisible="context.get('expense_adding_line')">
<button name="action_get_attachment_view"
class="oe_stat_button"
icon="fa-book"
@@ -421,7 +421,7 @@
</group>
<notebook>
<page string="Expense Lines">
- <field name="expense_line_ids" nolabel="1" widget="many2many" domain="[('state', '=', 'draft')]" options="{'not_delete': True, 'reload_on_button': True, 'no_create': True}">
+ <field name="expense_line_ids" nolabel="1" widget="many2many" domain="[('state', '=', 'draft')]" options="{'not_delete': True, 'reload_on_button': True, 'no_create': True}" context="{'expense_adding_line': True}">
<tree decoration-danger="is_refused">
<field name="date"/>
<field name="name"/>
diff --git a/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py b/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py
index 7e5fa858cf1..c80ccc983a5 100644
--- a/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py
+++ b/addons/l10n_be_hr_payroll/models/l10n_be_hr_payroll.py
@@ -76,7 +76,7 @@ class HrContract(models.Model):
default=lambda self: self.get_attribute('eco_checks', 'default_value'),
help="Yearly amount the employee receives in the form of eco vouchers.")
- @api.depends('holidays', 'wage')
+ @api.depends('holidays', 'wage', 'final_yearly_costs')
def _compute_wage_with_holidays(self):
for contract in self:
if contract.holidays > 20.0:
diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py
index ad792a08987..fa03c88b3a6 100644
--- a/addons/payment_authorize/models/payment.py
+++ b/addons/payment_authorize/models/payment.py
@@ -126,7 +126,7 @@ class PaymentAcquirerAuthorize(models.Model):
for field_name in mandatory_fields:
if not data.get(field_name):
error[field_name] = 'missing'
- if data['cc_expiry'] and datetime.now().strftime('%y%M') > datetime.strptime(data['cc_expiry'], '%M / %y').strftime('%y%M'):
+ if data['cc_expiry'] and datetime.now().strftime('%y%m') > datetime.strptime(data['cc_expiry'], '%m / %y').strftime('%y%m'):
return False
return False if error else True
diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js
index 7a6d1447f87..d616ddfe0be 100644
--- a/addons/payment_stripe/static/src/js/stripe.js
+++ b/addons/payment_stripe/static/src/js/stripe.js
@@ -92,7 +92,7 @@ odoo.define('payment_stripe.stripe', function(require) {
return false;
}
- var access_token = $("input[name='access_token']").val() || $("input[name='token']").val();
+ var access_token = $("input[name='access_token']").val() || $("input[name='token']").val() || '';
var so_id = $("input[name='return_url']").val().match(/quote\/([0-9]+)/) || undefined;
if (so_id) {
so_id = parseInt(so_id[1]);
diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py
index f6a906bc73e..4a79ad1c0bc 100644
--- a/addons/purchase/models/purchase.py
+++ b/addons/purchase/models/purchase.py
@@ -783,10 +783,10 @@ class PurchaseOrderLine(models.Model):
self.product_uom = self.product_id.uom_po_id or self.product_id.uom_id
result['domain'] = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}
- product_lang = self.product_id.with_context({
- 'lang': self.partner_id.lang,
- 'partner_id': self.partner_id.id,
- })
+ product_lang = self.product_id.with_context(
+ lang=self.partner_id.lang,
+ partner_id=self.partner_id.id,
+ )
self.name = product_lang.display_name
if product_lang.description_purchase:
self.name += '\n' + product_lang.description_purchase
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index 6da2ea72ea1..d2bcd29e5ce 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -374,10 +374,11 @@ var RTEWidget = Widget.extend({
* @param {boolean} internal_history
*/
historyRecordUndo: function ($target, event, internal_history) {
+ $target = $($target);
var rng = range.create();
var $editable = $(rng && rng.sc).closest('.o_editable');
if (!rng || !$editable.length) {
- $editable = $($target).closest('.o_editable');
+ $editable = $target.closest('.o_editable');
rng = range.create($target.closest('*')[0],0);
} else {
rng = $editable.data('range') || rng;
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js
index d6f9805599e..8ce2ed692da 100644
--- a/addons/web_editor/static/src/js/editor/summernote.js
+++ b/addons/web_editor/static/src/js/editor/summernote.js
@@ -846,37 +846,67 @@ range.WrappedRange.prototype.reRange = function (keep_end, isNotBreakable) {
return new range.WrappedRange(sc, so, ec, eo);
};
-// isOnImg: judge whether range is an image node or not
+/**
+ * Returns the image the range is in or matches (if any, false otherwise).
+ *
+ * @todo this implementation may not cover all corner cases but should do the
+ * trick for all reproductible ones
+ * @returns {DOMElement|boolean}
+ */
range.WrappedRange.prototype.isOnImg = function () {
+ // If not a selection but a cursor position, just check if a point's
+ // ancestor is an image or not
+ if (this.sc === this.ec && this.so === this.eo) {
+ return dom.ancestor(this.sc, dom.isImg);
+ }
+
+ var startPoint = {node: this.sc, offset: this.so};
+ var endPoint = {node: this.ec, offset: this.eo};
+
var nb = 0;
var image;
- var startPoint = {node: this.sc.childNodes.length && this.sc.childNodes[this.so] || this.sc};
- startPoint.offset = startPoint.node === this.sc ? this.so : 0;
- var endPoint = {node: this.ec.childNodes.length && this.ec.childNodes[this.eo] || this.ec};
- endPoint.offset = endPoint.node === this.ec ? this.eo : 0;
-
- if (dom.isImg(startPoint.node)) {
- nb ++;
- image = startPoint.node;
- }
+ var textNode;
dom.walkPoint(startPoint, endPoint, function (point) {
- if (!dom.isText(endPoint.node) && point.node === endPoint.node && point.offset === endPoint.offset) {
+ // If the element has children (not a text node and not empty node),
+ // the element cannot be considered as selected (these children will
+ // be processed to determine that)
+ if (dom.hasChildren(point.node)) {
return;
}
- var node = point.node.childNodes.length && point.node.childNodes[point.offset] || point.node;
- var offset = node === point.node ? point.offset : 0;
- var isImg = dom.ancestor(node, dom.isImg);
- if (!isImg && ((!dom.isBR(node) && !dom.isText(node)) || (offset && node.textContent.length !== offset && node.textContent.match(/\S|\u00A0/)))) {
+
+ // Check if an ancestor of the current point is an image
+ var pointImg = dom.ancestor(point.node, dom.isImg);
+ var isText = dom.isText(point.node);
+
+ // Check if a visible element is selected, i.e.
+ // - If an ancestor of the current is an image we did not see yet
+ // - If the point is not in a br or a text (so a node with no children)
+ // - If the point is in a non empty text node we already saw
+ if (pointImg ?
+ (image !== pointImg) :
+ ((!dom.isBR(point.node) && !isText) || (textNode === point.node && point.node.textContent.match(/\S|\u00A0/)))) {
nb++;
}
- if (isImg && image !== isImg) {
- image = isImg;
- nb ++;
+
+ // If an ancestor of the current point is an image, then save it as the
+ // image we are looking for
+ if (pointImg) {
+ image = pointImg;
+ }
+ // If the current point is a text node save it as the last text node
+ // seen (if we see it again, this might mean it is selected)
+ if (isText) {
+ textNode = point.node;
}
});
+
return nb === 1 && image;
};
range.WrappedRange.prototype.deleteContents = function (towrite) {
+ if (this.sc === this.ec && this.so === this.eo) {
+ return this;
+ }
+
var prevBP = dom.removeBetween(this.sc, this.so, this.ec, this.eo, towrite);
$(dom.node(prevBP.sc)).trigger("click"); // trigger click to disable and reanable editor and image handler