diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index f0557d90321..115bf98de0d 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -965,26 +965,10 @@ class AccountMoveLine(models.Model): vals['amount_currency'] = sign * abs(sum([r.amount_residual_currency for r in self])) # Writeoff line in the account of self - first_line_dict = vals.copy() - first_line_dict['account_id'] = self[0].account_id.id - if 'analytic_account_id' in first_line_dict: - del first_line_dict['analytic_account_id'] - if 'tax_ids' in first_line_dict: - tax_ids = [] - #vals['tax_ids'] is a list of commands [[4, tax_id, None], ...] - for tax_id in vals['tax_ids']: - tax_ids.append(tax_id[1]) - amount = first_line_dict['credit'] - first_line_dict['debit'] - amount_tax = self.env['account.tax'].browse(tax_ids).compute_all(amount)['total_included'] - first_line_dict['credit'] = amount_tax > 0 and amount_tax or 0.0 - first_line_dict['debit'] = amount_tax < 0 and abs(amount_tax) or 0.0 - del first_line_dict['tax_ids'] + first_line_dict = self._prepare_writeoff_first_line_values(vals) # Writeoff line in specified writeoff account - second_line_dict = vals.copy() - second_line_dict['debit'], second_line_dict['credit'] = second_line_dict['credit'], second_line_dict['debit'] - if 'amount_currency' in vals: - second_line_dict['amount_currency'] = -second_line_dict['amount_currency'] + second_line_dict = self._prepare_writeoff_second_line_values(vals) # Create the move writeoff_move = self.env['account.move'].with_context(apply_taxes=True).create({ @@ -998,6 +982,32 @@ class AccountMoveLine(models.Model): # Return the writeoff move.line which is to be reconciled return writeoff_move.line_ids.filtered(lambda r: r.account_id == self[0].account_id) + @api.multi + def _prepare_writeoff_first_line_values(self, values): + line_values = values.copy() + line_values['account_id'] = self[0].account_id.id + if 'analytic_account_id' in line_values: + del line_values['analytic_account_id'] + if 'tax_ids' in line_values: + tax_ids = [] + # vals['tax_ids'] is a list of commands [[4, tax_id, None], ...] + for tax_id in values['tax_ids']: + tax_ids.append(tax_id[1]) + amount = line_values['credit'] - line_values['debit'] + amount_tax = self.env['account.tax'].browse(tax_ids).compute_all(amount)['total_included'] + line_values['credit'] = amount_tax > 0 and amount_tax or 0.0 + line_values['debit'] = amount_tax < 0 and abs(amount_tax) or 0.0 + del line_values['tax_ids'] + return line_values + + @api.multi + def _prepare_writeoff_second_line_values(self, values): + line_values = values.copy() + line_values['debit'], line_values['credit'] = line_values['credit'], line_values['debit'] + if 'amount_currency' in values: + line_values['amount_currency'] = -line_values['amount_currency'] + return line_values + @api.model def compute_full_after_batch_reconcile(self): """ After running the manual reconciliation wizard and making full reconciliation, we need to run this method to create diff --git a/addons/link_tracker/models/link_tracker.py b/addons/link_tracker/models/link_tracker.py index 9d688121423..bdc97778543 100644 --- a/addons/link_tracker/models/link_tracker.py +++ b/addons/link_tracker/models/link_tracker.py @@ -15,7 +15,7 @@ from werkzeug import url_encode, unescape from odoo import models, fields, api, _ from odoo.tools import ustr -URL_REGEX = r'(\bhref=[\'"](?!mailto:)([^\'"]+)[\'"])' +URL_REGEX = r'(\bhref=[\'"](?!mailto:|tel:|sms:)([^\'"]+)[\'"])' def VALIDATE_URL(url): if urlparse(url).scheme not in ('http', 'https', 'ftp', 'ftps'): diff --git a/addons/mrp/wizard/mrp_product_produce_views.xml b/addons/mrp/wizard/mrp_product_produce_views.xml index 805d05b7549..c3df10ddbbe 100644 --- a/addons/mrp/wizard/mrp_product_produce_views.xml +++ b/addons/mrp/wizard/mrp_product_produce_views.xml @@ -29,8 +29,6 @@ -