diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 39b90ce9f31..d3d6162a247 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -726,7 +726,7 @@ class WizardMultiChartsAccounts(models.TransientModel): if company_id: company = self.env['res.company'].browse(company_id) currency_id = company.on_change_country(company.country_id.id)['value']['currency_id'] - res.update({'currency_id': currency_id}) + res.update({'currency_id': currency_id.id}) chart_templates = account_chart_template.search([('visible', '=', True)]) if chart_templates: diff --git a/addons/mrp/wizard/change_production_qty.py b/addons/mrp/wizard/change_production_qty.py index e9588516a0c..3422edd8cb5 100644 --- a/addons/mrp/wizard/change_production_qty.py +++ b/addons/mrp/wizard/change_production_qty.py @@ -68,7 +68,7 @@ class ChangeProductionQty(models.TransientModel): cycle_number * operation.time_cycle * 100.0 / operation.workcenter_id.time_efficiency) quantity = wo.qty_production - wo.qty_produced if production.product_id.tracking == 'serial': - quantity = 1.0 if float_is_zero(quantity, precision_digits=precision) else 0.0 + quantity = 1.0 if not float_is_zero(quantity, precision_digits=precision) else 0.0 else: quantity = quantity if (quantity > 0) else 0 if float_is_zero(quantity, precision_digits=precision): diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index cc04f10b198..d9fe56cd5e5 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1125,12 +1125,15 @@ var ClientListScreenWidget = ScreenWidget.extend({ var self = this; var order = this.pos.get_order(); if( this.has_client_changed() ){ - if ( this.new_client ) { + var default_fiscal_position_id = _.find(this.pos.fiscal_positions, function(fp) { + return fp.id === self.pos.config.default_fiscal_position_id[0]; + }); + if ( this.new_client && this.new_client.property_account_position_id ) { order.fiscal_position = _.find(this.pos.fiscal_positions, function (fp) { return fp.id === self.new_client.property_account_position_id[0]; - }); + }) || default_fiscal_position_id; } else { - order.fiscal_position = undefined; + order.fiscal_position = default_fiscal_position_id; } order.set_client(this.new_client); diff --git a/addons/product/models/product.py b/addons/product/models/product.py index d258315cced..a5ce68d1773 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -32,10 +32,13 @@ class ProductCategory(models.Model): help="The number of products under this category (Does not consider the children categories)") def _compute_product_count(self): - read_group_res = self.env['product.template'].read_group([('categ_id', 'in', self.ids)], ['categ_id'], ['categ_id']) + read_group_res = self.env['product.template'].read_group([('categ_id', 'child_of', self.ids)], ['categ_id'], ['categ_id']) group_data = dict((data['categ_id'][0], data['categ_id_count']) for data in read_group_res) for categ in self: - categ.product_count = group_data.get(categ.id, 0) + product_count = 0 + for sub_categ_id in categ.search([('id', 'child_of', categ.id)]).ids: + product_count += group_data.get(sub_categ_id, 0) + categ.product_count = product_count @api.constrains('parent_id') def _check_category_recursion(self): diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index 78de88c74da..69c9dd895d7 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -112,7 +112,7 @@ - + diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 5f1b2996ec4..36310219909 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -243,7 +243,8 @@ class Project(models.Model): project = super(Project, self).copy(default) for follower in self.message_follower_ids: project.message_subscribe(partner_ids=follower.partner_id.ids, subtype_ids=follower.subtype_ids.ids) - self.map_tasks(project.id) + if 'tasks' not in default: + self.map_tasks(project.id) return project @api.model @@ -264,6 +265,8 @@ class Project(models.Model): if 'active' in vals: # archiving/unarchiving a project does it on its tasks, too self.with_context(active_test=False).mapped('tasks').write({'active': vals['active']}) + # archiving/unarchiving a project implies that we don't want to use the analytic account anymore + self.with_context(active_test=False).mapped('analytic_account_id').write({'active': vals['active']}) return res @api.multi diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index 4fe6e9b31b8..a8b87210a09 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -1250,7 +1250,7 @@ var FieldBinaryFile = FieldBinary.extend({ this._super(); if (this.get("effective_readonly")) { this.$el.click(function(ev) { - if (self.get('value')) { + if (self.get('value') && self.view.datarecord.id) { self.on_save_as(ev); } return false; @@ -1268,6 +1268,11 @@ var FieldBinaryFile = FieldBinary.extend({ this.do_toggle(!!this.get('value')); if (this.get('value')) { this.$el.empty().append($("").addClass('fa fa-download')); + if (this.view.datarecord.id) { + this.$el.css('cursor', 'pointer'); + } else { + this.$el.css('cursor', 'not-allowed'); + } if (filename) { this.$el.append(" " + filename); } diff --git a/addons/web/static/src/js/views/graph_widget.js b/addons/web/static/src/js/views/graph_widget.js index 36908e65f6b..783428a7c7c 100644 --- a/addons/web/static/src/js/views/graph_widget.js +++ b/addons/web/static/src/js/views/graph_widget.js @@ -100,7 +100,7 @@ return Widget.extend({ })); } else { var chart = this['display_' + this.mode](); - if (chart) { + if (chart && chart.tooltip.chartContainer) { chart.tooltip.chartContainer(this.$el[0]); } } diff --git a/addons/web/static/src/js/views/search_inputs.js b/addons/web/static/src/js/views/search_inputs.js index c4478956499..6459fba77b8 100644 --- a/addons/web/static/src/js/views/search_inputs.js +++ b/addons/web/static/src/js/views/search_inputs.js @@ -152,7 +152,7 @@ var Field = Input.extend( /** @lends instance.web.search.Field# */ { if (domain) { value_to_domain = function (facetValue) { return new data.CompoundDomain(domain) - .set_eval_context({self: self.value_from(facetValue)}); + .set_eval_context({self: self.value_from(facetValue), raw_value: facetValue.attributes.value}); }; } else { value_to_domain = function (facetValue) { diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index 13eb568f9b7..e177846c0fd 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -355,8 +355,8 @@ var RTE = Widget.extend({ var $el = $(this); $el.find('[class]').filter(function () { - if (!this.className.match(/\S/)) { - this.removeAttribute("class"); + if (!this.getAttribute('class').match(/\S/)) { + this.removeAttribute('class'); } }); diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js index 1213b986472..bed19b0acde 100644 --- a/addons/website/static/src/js/website.snippets.animation.js +++ b/addons/website/static/src/js/website.snippets.animation.js @@ -415,16 +415,35 @@ animation.registry.media_video = animation.Class.extend({ start: function () { // TODO: this code should be refactored to make more sense and be better // integrated with Odoo (this refactoring should be done in master). - this.$target.find('iframe').remove(); - if (!this.$target.has('.media_iframe_video_size').length) { - var editor = '
 
'; - var size = '
 
'; - this.$target.html(editor+size); + var def = this._super.apply(this, arguments); + if (this.$target.children('iframe').length) { + // There already is an '); - return this._super.apply(this, arguments); + + // Bug fix / compatibility: empty the
element as all information + // to rebuild the iframe should have been saved on the
element + this.$target.empty(); + + // Add extra content for size / edition + this.$target.append( + '
 
' + + '
 
' + ); + + // Rebuild the iframe. Depending on version / compatibility / instance, + // the src is saved in the 'data-src' attribute or the + // 'data-oe-expression' one (the latter is used as a workaround in 10.0 + // system but should obviously be reviewed in master). + this.$target.append($('