[MERGE] Forward port of saas-11.3 to 12.0 up to db5261b19e

closes odoo/odoo#34723

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Martin Trigaux
2019-07-10 08:27:12 +00:00
5 changed files with 48 additions and 40 deletions
-1
View File
@@ -260,7 +260,6 @@ class ResPartner(models.Model):
def _invoice_total(self):
account_invoice_report = self.env['account.invoice.report']
if not self.ids:
self.total_invoiced = 0.0
return True
user_currency_id = self.env.user.company_id.currency_id.id
@@ -123,14 +123,32 @@ class AccountVoucher(models.Model):
@api.multi
@api.depends('tax_correction', 'line_ids.price_subtotal')
def _compute_total(self):
tax_calculation_rounding_method = self.env.user.company_id.tax_calculation_rounding_method
for voucher in self:
total = 0
tax_amount = 0
tax_lines_vals_merged = {}
for line in voucher.line_ids:
tax_info = line.tax_ids.compute_all(line.price_unit, voucher.currency_id, line.quantity, line.product_id, voucher.partner_id)
total += tax_info.get('total_included', 0.0)
tax_amount += sum([t.get('amount',0.0) for t in tax_info.get('taxes', False)])
voucher.amount = total + voucher.tax_correction
if tax_calculation_rounding_method == 'round_globally':
total += tax_info.get('total_excluded', 0.0)
for t in tax_info.get('taxes', False):
key = (
t['id'],
t['account_id'],
)
if key not in tax_lines_vals_merged:
tax_lines_vals_merged[key] = t.get('amount', 0.0)
else:
tax_lines_vals_merged[key] += t.get('amount', 0.0)
else:
total += tax_info.get('total_included', 0.0)
tax_amount += sum([t.get('amount', 0.0) for t in tax_info.get('taxes', False)])
if tax_calculation_rounding_method == 'round_globally':
tax_amount = sum([voucher.currency_id.round(t) for t in tax_lines_vals_merged.values()])
voucher.amount = total + tax_amount + voucher.tax_correction
else:
voucher.amount = total + voucher.tax_correction
voucher.tax_amount = tax_amount
@api.onchange('date')
+1 -2
View File
@@ -649,9 +649,8 @@ class PurchaseOrderLine(models.Model):
'''
if not self.product_id:
return
seller_min_qty = self.product_id.seller_ids\
.filtered(lambda r: r.name == self.order_id.partner_id)\
.filtered(lambda r: r.name == self.order_id.partner_id and (not r.product_id or r.product_id == self.product_id))\
.sorted(key=lambda r: r.min_qty)
if seller_min_qty:
self.product_qty = seller_min_qty[0].min_qty or 1.0
@@ -760,7 +760,7 @@ function jSignatureClass(parent, options, instanceExtensions) {
// these, when enabled, will hover above the sig area. Hence we append them to DOM before canvas.
this.$controlbarUpper = (function(){
var controlbarstyle = 'padding:0 !important; margin:0 !important;'+
'width: 100% !important; height: 0 !important; -ms-touch-action: none;'+
'width: 100% !important; height: 0 !important; -ms-touch-action: none; touch-action: none;'+
'margin-top:-1em !important; margin-bottom:1em !important;';
return $('<div style="'+controlbarstyle+'"></div>').appendTo($parent);
})();
@@ -771,7 +771,7 @@ function jSignatureClass(parent, options, instanceExtensions) {
this.$controlbarLower = (function(){
var controlbarstyle = 'padding:0 !important; margin:0 !important;'+
'width: 100% !important; height: 0 !important; -ms-touch-action: none;'+
'width: 100% !important; height: 0 !important; -ms-touch-action: none; touch-action: none;'+
'margin-top:-1.5em !important; margin-bottom:1.5em !important; position: relative;';
return $('<div style="'+controlbarstyle+'"></div>').appendTo($parent);
})();
@@ -876,7 +876,7 @@ function jSignatureClass(parent, options, instanceExtensions) {
$canvas.bind('mouseup.'+apinamespace, drawEndHandler);
$canvas.bind('mousedown.'+apinamespace, drawStartHandler);
} else {
canvas.ontouchstart = function(e) {
canvas.addEventListener('touchstart', function(e) {
canvas.onmousedown = canvas.onmouseup = canvas.onmousemove = undef;
this.fatFingerCompensation = (
@@ -886,19 +886,19 @@ function jSignatureClass(parent, options, instanceExtensions) {
drawStartHandler(e);
canvas.ontouchend = drawEndHandler;
canvas.ontouchstart = drawStartHandler;
canvas.ontouchmove = drawMoveHandler;
};
canvas.onmousedown = function(e) {
canvas.addEventListener('touchend', drawEndHandler);
canvas.addEventListener('touchstart', drawStartHandler);
canvas.addEventListener('touchmove', drawMoveHandler);
});
canvas.addEventListener('mousedown', function(e) {
canvas.ontouchstart = canvas.ontouchend = canvas.ontouchmove = undef;
drawStartHandler(e);
canvas.onmousedown = drawStartHandler;
canvas.onmouseup = drawEndHandler;
canvas.onmousemove = drawMoveHandler;
}
canvas.addEventListener('mousedown', drawStartHandler);
canvas.addEventListener('mouseup', drawEndHandler);
canvas.addEventListener('mousemove', drawMoveHandler);
});
if (window.navigator.msPointerEnabled) {
canvas.onmspointerdown = drawStartHandler;
canvas.onmspointerup = drawEndHandler;
@@ -1084,28 +1084,16 @@ jSignatureClass.prototype.initializeCanvas = function(settings) {
settings.width = '100%';
}
$canvas.css(
'margin'
, 0
).css(
'padding'
, 0
).css(
'border'
, 'none'
).css(
'height'
, settings.height === 'ratio' || !settings.height ? 1 : settings.height.toString(10)
).css(
'width'
, settings.width === 'ratio' || !settings.width ? 1 : settings.width.toString(10)
).css(
'-ms-touch-action'
, 'none'
).css(
'background-color',
settings['background-color']
);
$canvas.css({
'margin': 0,
'padding': 0,
'border': 'none',
'height': settings.height === 'ratio' || !settings.height ? 1 : settings.height.toString(10),
'width': settings.width === 'ratio' || !settings.width ? 1 : settings.width.toString(10),
'-ms-touch-action': 'none',
'touch-action': 'none',
'background-color': settings['background-color'],
});
$canvas.appendTo(this.$parent);
+4
View File
@@ -41,6 +41,10 @@
});
// close modal on submit
$('.modal').on('submit', 'form', function (ev) {
var form = $(this).closest('form')[0];
if (form && form.checkValidity && !form.checkValidity()) {
return;
}
var modal = $(this).parentsUntil('body', '.modal');
if (modal.hasClass('o_database_backup')) {
$(modal).modal('hide');