From ed26e9eafa31dd8bcaea491b2a6dcd1728a90bd0 Mon Sep 17 00:00:00 2001
From: Florian Gilbert
Date: Fri, 11 Oct 2019 14:04:44 +0000
Subject: [PATCH] [IMP] account: Various usability improvements List of
improvements:
Invoice/Bill
- Hide "untaxed amount" section when there is no tax.
- Remove tooltips for tax groups field.
- Remove invoice_partner_icon and set this icon in "Vendor" (in a list view)
Chart of Accounts
- Same views for config bar and regulare one
- By default don't show deprecated accounts and add filter to display them.
- Add some optional fields in list view (taxes, tags, ...)
Dashboard opening balance wizard
- The opening move entry date equals to the opening date - 1 day.
Bank Statements
- Set default order for the list view (by date desc and name desc)
Tax report configuration:
Add 3 new columns for the list view (country_id, code, tag_name)
Add 4 new searchs (name, tag_name, code, country_id)
Task ID: 2048225
closes odoo/odoo#38694
Signed-off-by: Laurent Smet
---
addons/account/models/account.py | 4 ++--
addons/account/models/account_bank_statement.py | 2 +-
addons/account/models/account_move.py | 12 ++++--------
addons/account/models/company.py | 7 ++-----
addons/account/views/account_move_views.xml | 9 +++++----
addons/account/views/account_tax_report_views.xml | 1 -
addons/account/views/account_view.xml | 9 ++++++++-
addons/account/wizard/setup_wizards.py | 7 +++++--
addons/account/wizard/setup_wizards_view.xml | 5 ++++-
9 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index b4b5e8f6aec..2d684ff14c2 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -397,10 +397,10 @@ class AccountAccount(models.Model):
self._cr.execute("""
SELECT aml.id
FROM account_move_line aml
- WHERE aml.account_id in (%s)
+ WHERE aml.account_id in %s
AND EXISTS (SELECT 1 FROM account_account_account_journal_rel WHERE account_account_id = aml.account_id)
AND NOT EXISTS (SELECT 1 FROM account_account_account_journal_rel WHERE account_account_id = aml.account_id AND account_journal_id = aml.journal_id)
- """, tuple(self.ids))
+ """, [tuple(self.ids)])
ids = self._cr.fetchall()
if ids:
raise ValidationError(_('Some journal items already exist with this account but in other journals than the allowed ones.'))
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 454ef2c5331..61f392b0892 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -219,7 +219,7 @@ class AccountBankStatement(models.Model):
_name = "account.bank.statement"
_description = "Bank Statement"
- _order = "date desc, id desc"
+ _order = "date desc, name desc, id desc"
_inherit = ['mail.thread']
name = fields.Char(string='Reference', states={'open': [('readonly', False)]}, copy=False, readonly=True)
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py
index bb20f043e8b..61e4cd87d96 100644
--- a/addons/account/models/account_move.py
+++ b/addons/account/models/account_move.py
@@ -158,7 +158,8 @@ class AccountMove(models.Model):
amount_residual_signed = fields.Monetary(string='Amount Due Signed', store=True,
compute='_compute_amount', currency_field='company_currency_id')
amount_by_group = fields.Binary(string="Tax amount by group",
- compute='_compute_invoice_taxes_by_group')
+ compute='_compute_invoice_taxes_by_group',
+ help='Edit Tax amounts if you encounter rouding issues.')
# ==== Cash basis feature fields ====
tax_cash_basis_rec_id = fields.Many2one(
@@ -236,7 +237,6 @@ class AccountMove(models.Model):
help="Auto-complete from a past bill.")
invoice_source_email = fields.Char(string='Source Email', tracking=True)
invoice_partner_display_name = fields.Char(compute='_compute_invoice_partner_display_info', store=True)
- invoice_partner_icon = fields.Char(compute='_compute_invoice_partner_display_info', store=False, compute_sudo=True)
# ==== Cash rounding fields ====
invoice_cash_rounding_id = fields.Many2one('account.cash.rounding', string='Cash Rounding Method',
@@ -1088,13 +1088,9 @@ class AccountMove(models.Model):
vendor_display_name = move.partner_id.name
if not vendor_display_name:
if move.invoice_source_email:
- vendor_display_name = _('From: ') + move.invoice_source_email
- move.invoice_partner_icon = '@'
+ vendor_display_name = _('@From: ') + move.invoice_source_email
else:
- vendor_display_name = _('Created by: %s') % (move.sudo().create_uid.name or self.env.user.name)
- move.invoice_partner_icon = '#'
- else:
- move.invoice_partner_icon = False
+ vendor_display_name = _('#Created by: %s') % (move.sudo().create_uid.name or self.env.user.name)
move.invoice_partner_display_name = vendor_display_name
@api.depends('state', 'journal_id', 'invoice_date')
diff --git a/addons/account/models/company.py b/addons/account/models/company.py
index bfe981f362c..c7ca7fba0d1 100644
--- a/addons/account/models/company.py
+++ b/addons/account/models/company.py
@@ -79,7 +79,7 @@ class ResCompany(models.Model):
#Fields of the setup step for opening move
account_opening_move_id = fields.Many2one(string='Opening Journal Entry', comodel_name='account.move', help="The journal entry containing the initial balance of all this company's accounts.")
account_opening_journal_id = fields.Many2one(string='Opening Journal', comodel_name='account.journal', related='account_opening_move_id.journal_id', help="Journal where the opening entry of this company's accounting has been posted.", readonly=False)
- account_opening_date = fields.Date(string='Opening Date', related='account_opening_move_id.date', help="Date at which the opening entry of this company's accounting has been posted.", readonly=False)
+ account_opening_date = fields.Date(string='Opening Entry', default=lambda self: fields.Date.today().replace(month=1, day=1), required=True, help="That is the date of the opening entry.")
# Fields marking the completion of a setup step
# YTI FIXME : The selection should be factorize as a static list in base, like ONBOARDING_STEP_STATES
@@ -331,10 +331,7 @@ class ResCompany(models.Model):
if not default_journal:
raise UserError(_("Please install a chart of accounts or create a miscellaneous journal before proceeding."))
- today = datetime.today().date()
- opening_date = today.replace(month=int(self.fiscalyear_last_month), day=self.fiscalyear_last_day) + timedelta(days=1)
- if opening_date > today:
- opening_date = opening_date + relativedelta(years=-1)
+ opening_date = self.account_opening_date - timedelta(days=1)
self.account_opening_move_id = self.env['account.move'].create({
'ref': _('Opening Journal Entry'),
diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml
index d53179abd4a..a27c144afa0 100644
--- a/addons/account/views/account_move_views.xml
+++ b/addons/account/views/account_move_views.xml
@@ -391,7 +391,6 @@
-
@@ -825,9 +824,11 @@
diff --git a/addons/account/views/account_tax_report_views.xml b/addons/account/views/account_tax_report_views.xml
index 49ead71fc0f..b09f1040655 100644
--- a/addons/account/views/account_tax_report_views.xml
+++ b/addons/account/views/account_tax_report_views.xml
@@ -118,7 +118,6 @@
-
diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml
index 0968754104d..04718071a24 100644
--- a/addons/account/views/account_view.xml
+++ b/addons/account/views/account_view.xml
@@ -50,12 +50,17 @@
account.account.list
account.account
-
+
+
+
+
+
+
@@ -104,6 +109,7 @@
+
@@ -134,6 +140,7 @@
to disclose a certain amount of information.
+ {'search_default_activeacc': True}
diff --git a/addons/account/wizard/setup_wizards.py b/addons/account/wizard/setup_wizards.py
index e54f38a0ea8..1925d5f9750 100644
--- a/addons/account/wizard/setup_wizards.py
+++ b/addons/account/wizard/setup_wizards.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from datetime import date
+from datetime import date, timedelta
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
@@ -47,9 +47,12 @@ class FinancialYearOpeningWizard(models.TransientModel):
# one value at a time... so it is likely to fail.
for wiz in self:
wiz.company_id.write({
- 'account_opening_date': vals.get('opening_date') or wiz.company_id.account_opening_date,
'fiscalyear_last_day': vals.get('fiscalyear_last_day') or wiz.company_id.fiscalyear_last_day,
'fiscalyear_last_month': vals.get('fiscalyear_last_month') or wiz.company_id.fiscalyear_last_month,
+ 'account_opening_date': vals.get('opening_date'),
+ })
+ wiz.company_id.account_opening_move_id.write({
+ 'date': fields.Date.from_string(vals.get('opening_date')) - timedelta(days=1),
})
vals.pop('opening_date', None)
vals.pop('fiscalyear_last_day', None)
diff --git a/addons/account/wizard/setup_wizards_view.xml b/addons/account/wizard/setup_wizards_view.xml
index 9ae9c8d00da..8e6c02f1e28 100644
--- a/addons/account/wizard/setup_wizards_view.xml
+++ b/addons/account/wizard/setup_wizards_view.xml
@@ -73,13 +73,16 @@
account.setup.opening.move.line.tree
account.account
-
+
+
+
+