summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-09-15 18:55:01 +0200
committerChristophe Simonis <chs@odoo.com>2016-09-15 18:55:01 +0200
commitf8a601cad7becde53e7dc4635cb993a89a174ebc (patch)
tree5f9ecf1240c0b6bc4795e1ed2da2a9fb79b44f65
parentf83b5a8e560cd70493dd5c135d9538e0c6a83083 (diff)
parente634a52cace081edfce324f14228ddb419af0a31 (diff)
[MERGE] forward port branch saas-10 up to e634a52
-rw-r--r--addons/account/models/account.py19
-rw-r--r--addons/account/models/account_move.py2
-rw-r--r--addons/account/static/src/js/account_reconciliation_widgets.js20
-rw-r--r--addons/barcodes/static/src/js/form_view_barcode_handler.js5
-rw-r--r--addons/stock/models/stock_pack_operation.py16
-rw-r--r--addons/stock/models/stock_picking.py4
-rw-r--r--addons/stock/models/stock_warehouse.py2
-rw-r--r--addons/web/static/src/js/views/list_view.js4
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js5
-rw-r--r--addons/web_editor/static/src/xml/snippets.xml2
-rw-r--r--addons/website_quote/controllers/main.py2
-rw-r--r--openerp/addons/base/ir/ir_http.py2
-rw-r--r--openerp/addons/test_new_api/models.py9
-rw-r--r--openerp/addons/test_new_api/tests/test_onchange.py27
-rw-r--r--openerp/addons/test_new_api/views.xml1
-rw-r--r--openerp/fields.py4
-rw-r--r--openerp/modules/module.py2
-rw-r--r--openerp/tools/convert.py3
18 files changed, 111 insertions, 18 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 0cd99dbbde4..b2d5b5d2b6e 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -687,7 +687,18 @@ class AccountTax(models.Model):
# the 'Account' decimal precision + 5), and that way it's like
# rounding after the sum of the tax amounts of each line
prec = currency.decimal_places
- if company_id.tax_calculation_rounding_method == 'round_globally' or not bool(self.env.context.get("round", True)):
+
+ # In some cases, it is necessary to force/prevent the rounding of the tax and the total
+ # amounts. For example, in SO/PO line, we don't want to round the price unit at the
+ # precision of the currency.
+ # The context key 'round' allows to force the standard behavior.
+ round_tax = False if company_id.tax_calculation_rounding_method == 'round_globally' else True
+ round_total = True
+ if 'round' in self.env.context:
+ round_tax = bool(self.env.context['round'])
+ round_total = bool(self.env.context['round'])
+
+ if not round_tax:
prec += 5
total_excluded = total_included = base = round(price_unit * quantity, prec)
@@ -706,7 +717,7 @@ class AccountTax(models.Model):
continue
tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner)
- if company_id.tax_calculation_rounding_method == 'round_globally' or not bool(self.env.context.get("round", True)):
+ if not round_tax:
tax_amount = round(tax_amount, prec)
else:
tax_amount = currency.round(tax_amount)
@@ -732,8 +743,8 @@ class AccountTax(models.Model):
return {
'taxes': sorted(taxes, key=lambda k: k['sequence']),
- 'total_excluded': currency.round(total_excluded) if bool(self.env.context.get("round", True)) else total_excluded,
- 'total_included': currency.round(total_included) if bool(self.env.context.get("round", True)) else total_included,
+ 'total_excluded': currency.round(total_excluded) if round_total else total_excluded,
+ 'total_included': currency.round(total_included) if round_total else total_included,
'base': base,
}
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index 07a6879a24b..e002398b3ea 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -1088,7 +1088,7 @@ class AccountMoveLine(models.Model):
taxes = self.env['account.tax'].browse(tax_ids)
currency = self.env['res.currency'].browse(vals.get('currency_id'))
partner = self.env['res.partner'].browse(vals.get('partner_id'))
- res = taxes.compute_all(amount,
+ res = taxes.with_context(round=True).compute_all(amount,
currency, 1, vals.get('product_id'), partner)
# Adjust line amount if any tax is price_include
if abs(res['total_excluded']) < abs(amount):
diff --git a/addons/account/static/src/js/account_reconciliation_widgets.js b/addons/account/static/src/js/account_reconciliation_widgets.js
index 710eaba0810..b63c6136161 100644
--- a/addons/account/static/src/js/account_reconciliation_widgets.js
+++ b/addons/account/static/src/js/account_reconciliation_widgets.js
@@ -18,6 +18,7 @@ var pyeval = require('web.pyeval');
var web_client = require('web.web_client');
var parse_value = require('web.web_client');
var Widget = require('web.Widget');
+var session = require('web.session');
var FieldMany2One = core.form_widget_registry.get('many2one');
var FieldChar = core.form_widget_registry.get('char');
@@ -76,8 +77,6 @@ var abstractReconciliation = Widget.extend(ControlPanelMixin, {
this.action_manager = this.findAncestor(function(ancestor){ return ancestor instanceof ActionManager });
this.crash_manager = new CrashManager();
- // Method that tests if a monetary amount == 0, we use 4 digits because no currency uses more
- this.monetaryIsZero = _.partial(utils.float_is_zero, _, 4);
this.formatCurrencies; // Method that formats the currency ; loaded from the server
this.model_res_users = new Model("res.users");
this.model_tax = new Model("account.tax");
@@ -370,6 +369,11 @@ var abstractReconciliation = Widget.extend(ControlPanelMixin, {
if (line.ref && line.ref !== line.name)
line.q_label = line.q_label + " : " + line.ref;
},
+
+ // Method that tests if a monetary amount == 0, we use 4 digits because no currency uses more
+ monetaryIsZero: function(amount, digits) {
+ return utils.float_is_zero(amount, digits === undefined ? 4 : digits);
+ },
});
var abstractReconciliationLine = Widget.extend({
@@ -1873,7 +1877,11 @@ var bankStatementReconciliationLine = abstractReconciliationLine.extend({
// Find out if the counterpart is lower than, equal or greater than the transaction being reconciled
var balance_type = undefined;
- if (self.monetaryIsZero(self.get("balance"))) balance_type = "equal";
+ var digits = 4;
+ if (this.get("currency_id") && session.get_currency(this.get("currency_id"))) {
+ digits = session.get_currency(this.get("currency_id")).digits[1];
+ }
+ if (self.monetaryIsZero(self.get("balance"), digits)) balance_type = "equal";
else if (self.get("balance") * self.st_line.amount > 0) balance_type = "greater";
else if (self.get("balance") * self.st_line.amount < 0) balance_type = "lower";
@@ -2068,7 +2076,11 @@ var bankStatementReconciliationLine = abstractReconciliationLine.extend({
var payment_aml = _.filter(this.get("mv_lines_selected"), function(line) { return line.already_paid });
var payment_aml_ids = _.collect(payment_aml, function(line) { return line.id });
var new_aml_dicts = this.prepareCreatedMoveLinesForPersisting(this.getCreatedLines());
- if (! self.monetaryIsZero(this.get("balance"))) new_aml_dicts.push(this.prepareOpenBalanceForPersisting());
+ var digits = 4;
+ if (this.get("currency_id") && session.get_currency(this.get("currency_id"))) {
+ digits = session.get_currency(this.get("currency_id")).digits[1];
+ }
+ if (! self.monetaryIsZero(this.get("balance"), digits)) new_aml_dicts.push(this.prepareOpenBalanceForPersisting());
return {
'counterpart_aml_dicts': counterpart_aml_dicts,
'payment_aml_ids': payment_aml_ids,
diff --git a/addons/barcodes/static/src/js/form_view_barcode_handler.js b/addons/barcodes/static/src/js/form_view_barcode_handler.js
index a6fa4b55adf..b00bce51c5e 100644
--- a/addons/barcodes/static/src/js/form_view_barcode_handler.js
+++ b/addons/barcodes/static/src/js/form_view_barcode_handler.js
@@ -52,6 +52,11 @@ var FormViewBarcodeHandler = common.AbstractField.extend(BarcodeHandlerMixin, {
}
},
+ destroy: function () {
+ this.stop_listening();
+ this._super.apply(this, arguments);
+ },
+
_display_no_edit_mode_warning: function() {
this.do_warn(_t('Error : Document not editable'), _t('To modify this document, please first start edition.'));
},
diff --git a/addons/stock/models/stock_pack_operation.py b/addons/stock/models/stock_pack_operation.py
index 8a6ec8e639a..023d9ac57f5 100644
--- a/addons/stock/models/stock_pack_operation.py
+++ b/addons/stock/models/stock_pack_operation.py
@@ -164,8 +164,9 @@ class PackOperation(models.Model):
def split_quantities(self):
for operation in self:
if float_compare(operation.product_qty, operation.qty_done, precision_rounding=operation.product_uom_id.rounding) == 1:
- operation.copy(default={'qty_done': 0.0, 'product_qty': operation.product_qty - operation.qty_done})
+ cpy = operation.copy(default={'qty_done': 0.0, 'product_qty': operation.product_qty - operation.qty_done})
operation.write({'product_qty': operation.qty_done})
+ operation._copy_remaining_pack_lot_ids(cpy)
else:
raise UserError(_('The quantity to split should be smaller than the quantity To Do. '))
return True
@@ -238,6 +239,19 @@ class PackOperation(models.Model):
raise UserError(_('You should provide a different serial number for each piece'))
check_tracking = _check_serial_number
+ @api.multi
+ def _copy_remaining_pack_lot_ids(self, new_operation):
+ for op in self:
+ for lot in op.pack_lot_ids:
+ new_qty_todo = lot.qty_todo - lot.qty
+
+ if float_compare(new_qty_todo, 0, precision_rounding=op.product_uom_id.rounding) > 0:
+ lot.copy({
+ 'operation_id': new_operation.id,
+ 'qty_todo': new_qty_todo,
+ 'qty': 0,
+ })
+
class PackOperationLot(models.Model):
_name = "stock.pack.operation.lot"
diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py
index f2b05321384..c6e9ab46dcd 100644
--- a/addons/stock/models/stock_picking.py
+++ b/addons/stock/models/stock_picking.py
@@ -992,6 +992,10 @@ class Picking(models.Model):
packlots_transfer = [(4, x.id) for x in operation.pack_lot_ids]
new_operation.write({'pack_lot_ids': packlots_transfer})
+ # the stock.pack.operation.lot records now belong to the new, packaged stock.pack.operation
+ # we have to create new ones with new quantities for our original, unfinished stock.pack.operation
+ new_operation._copy_remaining_pack_lot_ids(operation)
+
op = new_operation
pack_operation_ids |= op
if operations:
diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py
index bfdfb0147b7..066a9a5afe0 100644
--- a/addons/stock/models/stock_warehouse.py
+++ b/addons/stock/models/stock_warehouse.py
@@ -808,7 +808,7 @@ class Orderpoint(models.Model):
def _get_date_planned(self, start_date):
days = self.lead_days or 0.0
- if self.lead_type == 'purchase':
+ if self.lead_type == 'supplier':
# These days will be substracted when creating the PO
days += self.product_id._select_seller(self.product_id).delay or 0.0
date_planned = start_date + relativedelta.relativedelta(days=days)
diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js
index b26b6fa12c9..c26eccae709 100644
--- a/addons/web/static/src/js/views/list_view.js
+++ b/addons/web/static/src/js/views/list_view.js
@@ -1092,8 +1092,8 @@ ListView.List = Class.extend({
_(names).pluck(1).join(', '));
record.set(column.id, ids);
});
- // temp empty value
- record.set(column.id, false);
+ // temporary empty display name
+ record.set(column.id + '__display', false);
}
}
return column.format(record.toForm().data, {
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index cd03cb70f6a..51cc5a31615 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -356,6 +356,9 @@ var BuildingBlock = Widget.extend({
});
self.make_snippet_draggable(self.$snippets);
+
+ this.show_blocks();
+ this.$el.on("snippet-dropped snippet-removed", this.show_blocks.bind(this));
},
cover_target: function ($el, $target) {
@@ -1074,6 +1077,8 @@ var Editor = Class.extend({
$(".note-control-selection").hide();
$('.o_table_handler').remove();
+ this.buildingBlock.$el.trigger("snippet-removed");
+
return false;
},
diff --git a/addons/web_editor/static/src/xml/snippets.xml b/addons/web_editor/static/src/xml/snippets.xml
index cbf1e6bef70..3fa6216c7f9 100644
--- a/addons/web_editor/static/src/xml/snippets.xml
+++ b/addons/web_editor/static/src/xml/snippets.xml
@@ -60,7 +60,7 @@
<!-- t-field options -->
<t t-name="web_editor.many2one.button">
- <div class="dropdown">
+ <div class="btn-group">
<a href="#" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" title="Search Contact"><i class="fa fa-search"></i></a>
<ul class="dropdown-menu contact_menu" role="menu">
<li><a><input href="#" type="email" placeholder="Search"/></a></li>
diff --git a/addons/website_quote/controllers/main.py b/addons/website_quote/controllers/main.py
index 7a3f74bb90e..79b5d8f2ce3 100644
--- a/addons/website_quote/controllers/main.py
+++ b/addons/website_quote/controllers/main.py
@@ -27,7 +27,7 @@ class sale_quote(http.Controller):
if order and request.session.get('view_quote', False) != now:
request.session['view_quote'] = now
body = _('Quotation viewed by customer')
- _message_post_helper(res_model='sale.order', res_id=order.id, message=body, token=token, token_field="access_token", message_type='notification')
+ _message_post_helper(res_model='sale.order', res_id=order.id, message=body, token=token, token_field="access_token", message_type='notification', subtype="mail.mt_note", partner_ids=order.user_id.partner_id.ids)
else:
order = request.env['sale.order'].search([('id', '=', order_id)])
diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py
index 4907ce131a7..56e0379fd52 100644
--- a/openerp/addons/base/ir/ir_http.py
+++ b/openerp/addons/base/ir/ir_http.py
@@ -303,7 +303,7 @@ class IrHttp(models.AbstractModel):
# cache
etag = hasattr(request, 'httprequest') and request.httprequest.headers.get('If-None-Match')
- retag = hashlib.md5(last_update).hexdigest()
+ retag = '"%s"' % hashlib.md5(last_update).hexdigest()
status = status or (304 if etag == retag else 200)
headers.append(('ETag', retag))
headers.append(('Cache-Control', 'max-age=%s' % (STATIC_CACHE if unique else 0)))
diff --git a/openerp/addons/test_new_api/models.py b/openerp/addons/test_new_api/models.py
index 1db15f6dfee..af664a5c9cb 100644
--- a/openerp/addons/test_new_api/models.py
+++ b/openerp/addons/test_new_api/models.py
@@ -82,6 +82,7 @@ class Category(models.Model):
name = fields.Char(required=True)
color = fields.Integer('Color Index')
parent = fields.Many2one('test_new_api.category')
+ root_categ = fields.Many2one(_name, compute='_compute_root_categ')
display_name = fields.Char(compute='_compute_display_name', inverse='_inverse_display_name')
dummy = fields.Char(store=False)
discussions = fields.Many2many('test_new_api.discussion', 'test_new_api_discussion_category',
@@ -95,6 +96,14 @@ class Category(models.Model):
else:
self.display_name = self.name
+ @api.depends('parent')
+ def _compute_root_categ(self):
+ for cat in self:
+ current = cat
+ while current.parent:
+ current = current.parent
+ cat.root_categ = current
+
@api.one
def _inverse_display_name(self):
names = self.display_name.split('/')
diff --git a/openerp/addons/test_new_api/tests/test_onchange.py b/openerp/addons/test_new_api/tests/test_onchange.py
index adecda3e4aa..8516f9394e2 100644
--- a/openerp/addons/test_new_api/tests/test_onchange.py
+++ b/openerp/addons/test_new_api/tests/test_onchange.py
@@ -75,6 +75,33 @@ class TestOnChange(common.TransactionCase):
result = self.Message.onchange(values, 'body', field_onchange)
self.assertNotIn('name', result['value'])
+ def test_onchange_many2one(self):
+ Category = self.env['test_new_api.category']
+
+ field_onchange = Category._onchange_spec()
+ self.assertEqual(field_onchange.get('parent'), '1')
+
+ root = Category.create(dict(name='root'))
+
+ values = {
+ 'name': 'test',
+ 'parent': root.id,
+ 'root_categ': False,
+ }
+
+ self.env.invalidate_all()
+ result = Category.onchange(values, 'parent', field_onchange).get('value', {})
+ self.assertIn('root_categ', result)
+ self.assertEqual(result['root_categ'], root.name_get()[0])
+
+ values.update(result)
+ values['parent'] = False
+
+ self.env.invalidate_all()
+ result = Category.onchange(values, 'parent', field_onchange).get('value', {})
+ self.assertIn('root_categ', result)
+ self.assertIs(result['root_categ'], False)
+
def test_onchange_one2many(self):
""" test the effect of onchange() on one2many fields """
BODY = "What a beautiful day!"
diff --git a/openerp/addons/test_new_api/views.xml b/openerp/addons/test_new_api/views.xml
index 9cc5c6ce2ce..b8e56e1119c 100644
--- a/openerp/addons/test_new_api/views.xml
+++ b/openerp/addons/test_new_api/views.xml
@@ -207,6 +207,7 @@
<group>
<field name="name"/>
<field name="parent"/>
+ <field name="root_categ"/>
<field name="dummy"/>
</group>
</sheet>
diff --git a/openerp/fields.py b/openerp/fields.py
index 64d90b047da..d4f29f611c6 100644
--- a/openerp/fields.py
+++ b/openerp/fields.py
@@ -1749,6 +1749,10 @@ class Many2one(_Relational):
def convert_to_display_name(self, value, record):
return ustr(value.display_name)
+ def convert_to_onchange(self, value, fnames=None):
+ if not value.id:
+ return False
+ return super(Many2one, self).convert_to_onchange(value, fnames)
class UnionUpdate(SpecialValue):
""" Placeholder for a value update; when this value is taken from the cache,
diff --git a/openerp/modules/module.py b/openerp/modules/module.py
index c7b01b99736..4f953091dd5 100644
--- a/openerp/modules/module.py
+++ b/openerp/modules/module.py
@@ -158,7 +158,7 @@ def get_module_path(module, downloaded=False, display_warning=True):
"""
initialize_sys_path()
for adp in ad_paths:
- if os.path.exists(opj(adp, module)) or os.path.exists(opj(adp, '%s.zip' % module)):
+ if os.path.exists(opj(adp, module, MANIFEST)) or os.path.exists(opj(adp, '%s.zip' % module)):
return opj(adp, module)
if downloaded:
diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py
index a9b1a088948..e1bc3db6160 100644
--- a/openerp/tools/convert.py
+++ b/openerp/tools/convert.py
@@ -756,7 +756,8 @@ form: module.record_id""" % (xml_id,)
record.append(Field(name, name='name'))
record.append(Field(full_tpl_id, name='key'))
record.append(Field("qweb", name='type'))
- record.append(Field(el.get('priority', "16"), name='priority'))
+ if 'priority' in el.attrib:
+ record.append(Field(el.get('priority'), name='priority'))
if 'inherit_id' in el.attrib:
record.append(Field(name='inherit_id', ref=el.get('inherit_id')))
if 'website_id' in el.attrib: