diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 2f5f40df280..37bcefb2675 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -350,6 +350,26 @@ class AccountChartTemplate(models.Model): new_xml_id = str(company.id)+'_'+template_xmlid.name return ir_model_data._update(model, template_xmlid.module, vals, xml_id=new_xml_id, store=True, noupdate=True, mode='init', res_id=False) + def _get_account_vals(self, company, account_template, code_acc, tax_template_ref): + """ This method generates a dictionnary of all the values for the account that will be created. + """ + self.ensure_one() + tax_ids = [] + for tax in account_template.tax_ids: + tax_ids.append(tax_template_ref[tax.id]) + val = { + 'name': account_template.name, + 'currency_id': account_template.currency_id and account_template.currency_id.id or False, + 'code': code_acc, + 'user_type_id': account_template.user_type_id and account_template.user_type_id.id or False, + 'reconcile': account_template.reconcile, + 'note': account_template.note, + 'tax_ids': [(6, 0, tax_ids)], + 'company_id': company.id, + 'tag_ids': [(6, 0, [t.id for t in account_template.tag_ids])], + } + return val + @api.multi def generate_account(self, tax_template_ref, acc_template_ref, code_digits, company): """ This method for generating accounts from templates. @@ -365,25 +385,11 @@ class AccountChartTemplate(models.Model): account_tmpl_obj = self.env['account.account.template'] acc_template = account_tmpl_obj.search([('nocreate', '!=', True), ('chart_template_id', '=', self.id)], order='id') for account_template in acc_template: - tax_ids = [] - for tax in account_template.tax_ids: - tax_ids.append(tax_template_ref[tax.id]) - code_main = account_template.code and len(account_template.code) or 0 code_acc = account_template.code or '' if code_main > 0 and code_main <= code_digits: code_acc = str(code_acc) + (str('0'*(code_digits-code_main))) - vals = { - 'name': account_template.name, - 'currency_id': account_template.currency_id and account_template.currency_id.id or False, - 'code': code_acc, - 'user_type_id': account_template.user_type_id and account_template.user_type_id.id or False, - 'reconcile': account_template.reconcile, - 'note': account_template.note, - 'tax_ids': [(6, 0, tax_ids)], - 'company_id': company.id, - 'tag_ids': [(6, 0, [t.id for t in account_template.tag_ids])], - } + vals = self._get_account_vals(company, account_template, code_acc, tax_template_ref) new_account = self.create_record_with_xmlid(company, account_template, 'account.account', vals) acc_template_ref[account_template.id] = new_account return acc_template_ref diff --git a/addons/account/views/res_config_view.xml b/addons/account/views/res_config_view.xml index b387d32d3fe..14b4f4000a0 100644 --- a/addons/account/views/res_config_view.xml +++ b/addons/account/views/res_config_view.xml @@ -144,7 +144,7 @@

Invoicing

-
+
@@ -176,11 +176,6 @@
Mail your invoices in one-click using Docsaway
-
diff --git a/addons/account/views/web_planner_data.xml b/addons/account/views/web_planner_data.xml index b3569deb76b..abd637d87d5 100644 --- a/addons/account/views/web_planner_data.xml +++ b/addons/account/views/web_planner_data.xml @@ -98,7 +98,7 @@ Terms & Conditions - + Change diff --git a/addons/account_accountant/views/res_config_view.xml b/addons/account_accountant/views/res_config_view.xml index dff65902427..a356583bc93 100644 --- a/addons/account_accountant/views/res_config_view.xml +++ b/addons/account_accountant/views/res_config_view.xml @@ -66,7 +66,7 @@
diff --git a/addons/auth_ldap/views/auth_ldap_config_settings_views.xml b/addons/auth_ldap/views/auth_ldap_config_settings_views.xml index 67d14215027..344aeda46b1 100644 --- a/addons/auth_ldap/views/auth_ldap_config_settings_views.xml +++ b/addons/auth_ldap/views/auth_ldap_config_settings_views.xml @@ -6,7 +6,7 @@
-
+
diff --git a/addons/auth_oauth/views/res_config_views.xml b/addons/auth_oauth/views/res_config_views.xml index 4f0912afa18..0bc57df9127 100644 --- a/addons/auth_oauth/views/res_config_views.xml +++ b/addons/auth_oauth/views/res_config_views.xml @@ -6,14 +6,14 @@
-
+
-
+
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 7f2614f0ef1..524ec1513c3 100644 --- a/addons/barcodes/static/src/js/form_view_barcode_handler.js +++ b/addons/barcodes/static/src/js/form_view_barcode_handler.js @@ -28,6 +28,8 @@ var FormViewBarcodeHandler = common.AbstractField.extend(BarcodeHandlerMixin, { this.__quantity_listener = _.bind(this._set_quantity_listener, this); BarcodeHandlerMixin.init.apply(this, arguments); + this.process_barcode_mutex = new utils.Mutex(); + return this._super.apply(this, arguments); }, @@ -153,25 +155,35 @@ var FormViewBarcodeHandler = common.AbstractField.extend(BarcodeHandlerMixin, { else if (this.form_view.get('actual_mode') === 'view') this._display_no_edit_mode_warning(); else { - // Call hook method possibly implemented by subclass - this.pre_onchange_hook(barcode).then(function(proceed) { - if (proceed === true) { - // Wait for hypothetical ongoing onchange to finish - self.form_view.onchanges_mutex.exec(function() { - // A real onchange is triggered when a value actually changes (which can correspond - // to a widget's blur event per example). Commit the value of fields before - // programmatically triggering an onchange to be consistent with this. - var mutex_commit_value = new utils.Mutex(); - _.each(self.form_view.fields, function(field) { - mutex_commit_value.exec(_.bind(field.commit_value, field)); - }); - return mutex_commit_value.def.then(function(){ - // Trigger the barcode onchange - self.set_value(barcode); - }); - }); + var process_barcode = function () { + // this function can be passed to `Mutex.exec` in order to make sure + // that every ongoing onchanges in the form view are done + var form_onchanges_mutex = function () { + return self.form_view.onchanges_mutex.def; } - }); + + // before setting the barcode field with the received barcode, we commit + // every fields of the form view and we wait for their hypothetical ongoing + // onchanges to finish + var commit_mutex = new utils.Mutex(); + _.each(self.form_view.fields, function (field) { + commit_mutex.exec(function () { + return field.commit_value(); + }); + commit_mutex.exec(form_onchanges_mutex); + }); + + return commit_mutex.def.then(function () { + return self.pre_onchange_hook(barcode).then(function (proceed) { + if (proceed) { + self.set_value(barcode); // set the barcode field with the received one + return form_onchanges_mutex(); // wait for its onchange to finish + } + }); + }); + }; + + this.process_barcode_mutex.exec(process_barcode); } }, diff --git a/addons/base_gengo/views/res_config_views.xml b/addons/base_gengo/views/res_config_views.xml index a78bf51c07f..66546b2d1e5 100644 --- a/addons/base_gengo/views/res_config_views.xml +++ b/addons/base_gengo/views/res_config_views.xml @@ -7,32 +7,32 @@
-