summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-02-08 11:40:01 +0100
committerChristophe Simonis <chs@odoo.com>2019-02-08 11:40:01 +0100
commit18228f9c4e1642a3c0afb24223bccfb3354c928a (patch)
tree63b65fda120d542c39c936bae09f87aca7550a56
parent53ba83579beeb330312d9e4066ae05145dd40caa (diff)
parentbe689c53c13330832510c8cef332ac862d4ed5e8 (diff)
[MERGE] forward port branch 10.0 up to be689c53c13
-rw-r--r--addons/account/models/account_analytic_line.py2
-rw-r--r--addons/fleet/models/fleet.py2
-rw-r--r--addons/purchase/models/purchase.py10
-rw-r--r--addons/stock/models/stock_move.py14
-rw-r--r--addons/stock/models/stock_picking.py5
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js36
-rw-r--r--addons/web_editor/static/src/less/web_editor.ui.less4
7 files changed, 56 insertions, 17 deletions
diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py
index 20b44c04dbb..5f001ad34dd 100644
--- a/addons/account/models/account_analytic_line.py
+++ b/addons/account/models/account_analytic_line.py
@@ -44,7 +44,7 @@ class AccountAnalyticLine(models.Model):
# Compute based on pricetype
amount_unit = self.product_id.price_compute('standard_price', uom=unit)[self.product_id.id]
amount = amount_unit * self.unit_amount or 0.0
- result = round(amount, self.currency_id.decimal_places) * -1
+ result = round(amount, self.currency_id.decimal_places if self.currency_id else 2) * -1
self.amount = result
self.general_account_id = account
self.product_uom_id = unit
diff --git a/addons/fleet/models/fleet.py b/addons/fleet/models/fleet.py
index 364b44fff16..538142ad2bb 100644
--- a/addons/fleet/models/fleet.py
+++ b/addons/fleet/models/fleet.py
@@ -143,7 +143,7 @@ class FleetVehicle(models.Model):
def _get_default_state(self):
state = self.env.ref('fleet.vehicle_state_active', raise_if_not_found=False)
- return state and state.id or False
+ return state if state and state.id else False
name = fields.Char(compute="_compute_vehicle_name", store=True)
active = fields.Boolean(default=True)
diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py
index e4d8f368e59..43905c39652 100644
--- a/addons/purchase/models/purchase.py
+++ b/addons/purchase/models/purchase.py
@@ -443,6 +443,16 @@ class PurchaseOrder(models.Model):
'currency_id': currency.id,
'delay': 0,
}
+ # In case the order partner is a contact address, a new supplierinfo is created on
+ # the parent company. In this case, we keep the product name and code.
+ seller = line.product_id._select_seller(
+ partner_id=line.partner_id,
+ quantity=line.product_qty,
+ date=line.order_id.date_order and line.order_id.date_order[:10],
+ uom_id=line.product_uom)
+ if seller:
+ supplierinfo['product_name'] = seller.product_name
+ supplierinfo['product_code'] = seller.product_code
vals = {
'seller_ids': [(0, 0, supplierinfo)],
}
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index c170d2cc5fa..43a51a03831 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -868,13 +868,15 @@ class StockMove(models.Model):
false_quants += [reserved_quant]
elif float_compare(lot_quantities.get(reserved_quant.lot_id.id, 0), 0, precision_rounding=rounding) > 0:
if float_compare(lot_quantities[reserved_quant.lot_id.id], reserved_quant.qty, precision_rounding=rounding) >= 0:
- lot_quantities[reserved_quant.lot_id.id] -= reserved_quant.qty
- quants_taken += [(reserved_quant, reserved_quant.qty)]
- qty_on_link -= reserved_quant.qty
+ qty_taken = min(reserved_quant.qty, qty_on_link)
+ lot_quantities[reserved_quant.lot_id.id] -= qty_taken
+ quants_taken += [(reserved_quant, qty_taken)]
+ qty_on_link -= qty_taken
else:
- quants_taken += [(reserved_quant, lot_quantities[reserved_quant.lot_id.id])]
- lot_quantities[reserved_quant.lot_id.id] = 0
- qty_on_link -= lot_quantities[reserved_quant.lot_id.id]
+ qty_taken = min(qty_on_link, lot_quantities[reserved_quant.lot_id.id])
+ quants_taken += [(reserved_quant, qty_taken)]
+ lot_quantities[reserved_quant.lot_id.id] -= qty_taken
+ qty_on_link -= qty_taken
lot_move_qty[move.id] = qty_on_link
remaining_move_qty[move.id] -= prout_move_qty[move]
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index 9c7994b5e16..594cf210e0b 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -241,7 +241,8 @@ class Picking(models.Model):
picking_type_id = fields.Many2one(
'stock.picking.type', 'Picking Type',
required=True,
- states={'done': [('readonly', True)], 'cancel': [('readonly', True)]})
+ readonly=True,
+ states={'draft': [('readonly', False)]})
picking_type_code = fields.Selection([
('incoming', 'Vendors'),
('outgoing', 'Customers'),
@@ -731,7 +732,7 @@ class Picking(models.Model):
flag = quant.package_id == ops.package_id
else:
flag = not quant.package_id.id
- flag = flag and (ops.owner_id.id == quant.owner_id.id)
+ flag = flag and (ops.owner_id.id == quant.owner_id.id) and (ops.location_id.id == quant.location_id.id)
if flag:
if not lot_qty:
max_qty_on_link = min(quant.qty, qty_to_assign)
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index f68bf8756bb..3ad5d8beb18 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -615,6 +615,10 @@ data.Class = Widget.extend({
var self = this;
var zone_template = $("<div class='oe_drop_zone oe_insert'/>");
+ function isFullWidth($elem) {
+ return $elem.parent().width() === $elem.outerWidth(true);
+ }
+
if ($selector_children) {
$selector_children.each(function () {
var $zone = $(this);
@@ -632,7 +636,10 @@ data.Class = Widget.extend({
'display': 'inline-block'
});
} else if (float === "left" || float === "right") {
- $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.children().last().outerHeight()), 30));
+ $drop.css('float', float);
+ if (!isFullWidth($zone)) {
+ $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.children().last().outerHeight()), 30));
+ }
}
$drop = $drop.clone();
@@ -647,7 +654,10 @@ data.Class = Widget.extend({
'display': 'inline-block'
});
} else if (float === "left" || float === "right") {
- $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.children().first().outerHeight()), 30));
+ $drop.css('float', float);
+ if (!isFullWidth($zone)) {
+ $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.children().first().outerHeight()), 30));
+ }
}
if (test) {
$drop.css({'float': 'none', 'display': 'inline-block'});
@@ -668,14 +678,20 @@ data.Class = Widget.extend({
if($zone.prev('.oe_drop_zone:visible').length === 0) {
$drop = zone_template.clone();
if (float === "left" || float === "right") {
- $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.prev().outerHeight() || Infinity), 30));
+ $drop.css('float', float);
+ if (!isFullWidth($zone)) {
+ $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.prev().outerHeight() || Infinity), 30));
+ }
}
$zone.before($drop);
}
if($zone.next('.oe_drop_zone:visible').length === 0) {
$drop = zone_template.clone();
if (float === "left" || float === "right") {
- $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.next().outerHeight() || Infinity), 30));
+ $drop.css('float', float);
+ if (!isFullWidth($zone)) {
+ $drop.addClass("oe_vertical").css('height', Math.max(Math.min($zone.outerHeight(), $zone.next().outerHeight() || Infinity), 30));
+ }
}
$zone.after($drop);
}
@@ -862,6 +878,7 @@ data.Editor = Class.extend({
},
_drag_and_drop_start: function () {
var self = this;
+ this.dropped = false;
self.buildingBlock.editor_busy = true;
self.size = {
width: self.$target.width(),
@@ -890,9 +907,18 @@ data.Editor = Class.extend({
self._drag_and_drop_after_insert_dropzone();
self._drag_and_drop_active_drop_zone($('.oe_drop_zone'));
},
- _drag_and_drop_stop: function () {
+ _drag_and_drop_stop: function (ev, ui) {
var self = this;
+ // TODO lot of this is duplicated code of the d&d feature of snippets
+ if (!this.dropped) {
+ var $el = $.nearest({x: ui.position.left, y: ui.position.top}, '.oe_drop_zone').first();
+ if ($el.length) {
+ $el.after(this.$target);
+ this.dropped = true;
+ }
+ }
+
$(".oe_drop_zone").droppable('destroy').remove();
var prev = this.$target.first()[0].previousSibling;
diff --git a/addons/web_editor/static/src/less/web_editor.ui.less b/addons/web_editor/static/src/less/web_editor.ui.less
index 02094adf754..965a0ca820e 100644
--- a/addons/web_editor/static/src/less/web_editor.ui.less
+++ b/addons/web_editor/static/src/less/web_editor.ui.less
@@ -264,12 +264,12 @@ html[lang] > body.editor_enable [data-oe-translation-state] {
}
&.oe_vertical {
- border: 2px dashed @odoo-brand-primary;
+ border: @odoo-dropzone-border;
border-left: none;
border-right: none;
width: @odoo-dropzone-size;
- float: left;
+ height: 100%;
margin: 0 -@odoo-dropzone-size/2;
&:after {