diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 90223d85923..4d7add6879a 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -3,7 +3,7 @@
from odoo import api, fields, models, _
from odoo.osv import expression
from odoo.tools import float_is_zero, pycompat
-from odoo.tools import float_compare, float_round
+from odoo.tools import float_compare, float_round, float_repr
from odoo.tools.misc import formatLang
from odoo.exceptions import UserError, ValidationError
@@ -606,7 +606,8 @@ class AccountBankStatementLine(models.Model):
from_clause = "FROM account_move_line aml JOIN account_account acc ON acc.id = aml.account_id "
where_clause = """WHERE aml.company_id = %(company_id)s
AND (
- (aml.statement_id IS NULL AND aml.account_id IN %(account_payable_receivable)s)
+ (aml.statement_id IS NULL AND aml.account_id IN %(account_payable_receivable)s
+ AND aml.payment_id IS NOT NULL)
OR
("""+acc_type+""" AND aml.reconciled = false)
)"""
@@ -630,7 +631,7 @@ class AccountBankStatementLine(models.Model):
precision = st_line_currency and st_line_currency.decimal_places or company_currency.decimal_places
params = {'company_id': self.env.user.company_id.id,
'account_payable_receivable': (self.journal_id.default_credit_account_id.id, self.journal_id.default_debit_account_id.id),
- 'amount': float_round(amount, precision_digits=precision),
+ 'amount': float_repr(float_round(amount, precision_digits=precision), precision_digits=precision),
'partner_id': self.partner_id.id,
'excluded_ids': tuple(excluded_ids),
'ref': self.name,
@@ -651,9 +652,9 @@ class AccountBankStatementLine(models.Model):
# Look for a single move line with the same amount
field = currency and 'amount_residual_currency' or 'amount_residual'
liquidity_field = currency and 'amount_currency' or amount > 0 and 'debit' or 'credit'
- liquidity_amt_clause = currency and '%(amount)s' or 'abs(%(amount)s)'
+ liquidity_amt_clause = currency and '%(amount)s::numeric' or 'abs(%(amount)s::numeric)'
sql_query = self._get_common_sql_query(excluded_ids=excluded_ids) + \
- " AND ("+field+" = %(amount)s OR (acc.internal_type = 'liquidity' AND "+liquidity_field+" = " + liquidity_amt_clause + ")) \
+ " AND ("+field+" = %(amount)s::numeric OR (acc.internal_type = 'liquidity' AND "+liquidity_field+" = " + liquidity_amt_clause + ")) \
ORDER BY date_maturity desc, aml.id desc LIMIT 1"
self.env.cr.execute(sql_query, params)
results = self.env.cr.fetchone()
diff --git a/addons/account/models/account_config_settings.py b/addons/account/models/account_config_settings.py
index 21f1b10eeb7..1e64aa013a4 100644
--- a/addons/account/models/account_config_settings.py
+++ b/addons/account/models/account_config_settings.py
@@ -127,7 +127,12 @@ class AccountConfigSettings(models.TransientModel):
# related values, including the currency_id field on res_company. This in turn will trigger the recomputation
# of account_move_line related field company_currency_id which can be slow depending on the number of entries
# in the database. Thus, if we do not explicitely change the currency_id, we should not write it on the company
+ # Same for the field `code_digits` which will trigger a write on all the account.account to complete the
+ # code the missing characters to complete the desired number of digit, leading to a sql_constraint.
if ('company_id' in values and 'currency_id' in values):
- if self.env['res.company'].browse(values.get('company_id')).currency_id.id == values.get('currency_id'):
+ company = self.env['res.company'].browse(values.get('company_id'))
+ if company.currency_id.id == values.get('currency_id'):
values.pop('currency_id')
+ if company.accounts_code_digits == values.get('code_digits'):
+ values.pop('code_digits')
return super(AccountConfigSettings, self).create(values)
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py
index 12c34e659b6..b84aa3513cc 100644
--- a/addons/account/models/account_invoice.py
+++ b/addons/account/models/account_invoice.py
@@ -489,7 +489,7 @@ class AccountInvoice(models.Model):
@api.onchange('invoice_line_ids')
def _onchange_invoice_line_ids(self):
taxes_grouped = self.get_taxes_values()
- tax_lines = self.tax_line_ids.browse([])
+ tax_lines = self.tax_line_ids.filtered('manual')
for tax in pycompat.values(taxes_grouped):
tax_lines += tax_lines.new(tax)
self.tax_line_ids = tax_lines
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index f50593e32cc..b7f90e49624 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -695,7 +695,7 @@ class AccountMoveLine(models.Model):
company_currency = line.account_id.company_id.currency_id
ret_line = {
'id': line.id,
- 'name': line.name != '/' and line.move_id.name + ': ' + line.name or line.move_id.name,
+ 'name': line.name and line.name != '/' and line.move_id.name + ': ' + line.name or line.move_id.name,
'ref': line.move_id.ref or '',
# For reconciliation between statement transactions and already registered payments (eg. checks)
# NB : we don't use the 'reconciled' field because the line we're selecting is not the one that gets reconciled
diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py
index 72976451e8c..f2f0f85f7c0 100644
--- a/addons/account/models/partner.py
+++ b/addons/account/models/partner.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
+from ast import literal_eval
from operator import itemgetter
import time
@@ -427,3 +428,11 @@ class ResPartner(models.Model):
return super(ResPartner, self)._commercial_fields() + \
['debit_limit', 'property_account_payable_id', 'property_account_receivable_id', 'property_account_position_id',
'property_payment_term_id', 'property_supplier_payment_term_id', 'last_time_entries_checked']
+
+ @api.multi
+ def action_view_partner_invoices(self):
+ self.ensure_one()
+ action = self.env.ref('account.action_invoice_refund_out_tree').read()[0]
+ action['domain'] = literal_eval(action['domain'])
+ action['domain'].append(('partner_id', 'child_of', self.id))
+ return action
diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml
index cf1d70b40c0..fccaea99ecc 100644
--- a/addons/account/views/account_invoice_view.xml
+++ b/addons/account/views/account_invoice_view.xml
@@ -268,13 +268,13 @@
-
+
-
+
@@ -404,13 +404,13 @@
-
+
-
+
diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml
index 9757169d898..b71980e0ece 100644
--- a/addons/account/views/account_view.xml
+++ b/addons/account/views/account_view.xml
@@ -304,8 +304,8 @@