From d215bd81ca6f7b35985e5eef486d03f5e723469a Mon Sep 17 00:00:00 2001 From: wan Date: Fri, 31 May 2019 15:11:45 +0000 Subject: [PATCH] [IMP] account: update the journal items lists Task 2003965 *** New menuitems for the accounting menu: Miscellaneous Journal Entries (default search on misc op journal, like in v12) Journal Items (debug mode, same as V12) Journals (=journal items) Sales (group by entry, filter sales journal) Purchase (group by entry, filter purchase journal) Bank & Cash (group by entry, filter bank,cash journal) Miscellaneous (group by entry, filter misc journal) Ledgers (=journal items) General Ledger (group by account) Partner Ledger (group by partner) Taxes (no group by) *** Expand group by by default *** Adapt the name of the groups for group by moves *** Fold the attachment viewer *** Correct the optional tree fields on invoices closes odoo/odoo#34083 Signed-off-by: Quentin De Paoli (qdp) --- addons/account/models/account_move.py | 12 +- addons/account/tests/test_payment.py | 5 +- .../account/views/account_analytic_view.xml | 2 +- addons/account/views/account_invoice_view.xml | 11 +- addons/account/views/account_menuitem.xml | 7 +- addons/account/views/account_move_views.xml | 232 ++++++++++++++++-- 6 files changed, 237 insertions(+), 32 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index fef8868f80f..e7763356e96 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -19,7 +19,7 @@ from lxml import etree class AccountMove(models.Model): _name = "account.move" _description = "Journal Entries" - _order = 'date desc, id desc' + _order = 'date desc, name desc, id desc' _inherit = ['mail.thread', 'mail.activity.mixin'] @api.model @@ -34,10 +34,11 @@ class AccountMove(models.Model): def name_get(self): result = [] for move in self: + name = move.name + if self.env.context.get('name_groupby'): + name = "**{date}**, {name} {partner}".format(date=format_date(self.env, move.date), name=move.name, partner=move.partner_id.name or "") if move.state == 'draft': name = '* ' + str(move.id) - else: - name = move.name result.append((move.id, name)) return result @@ -510,7 +511,7 @@ class AccountMove(models.Model): class AccountMoveLine(models.Model): _name = "account.move.line" _description = "Journal Item" - _order = "date desc, id desc" + _order = "date desc, move_name desc, id desc" @api.onchange('debit', 'credit', 'tax_ids', 'analytic_account_id', 'analytic_tag_ids') def onchange_tax_ids_create_aml(self): @@ -614,6 +615,7 @@ class AccountMoveLine(models.Model): record.parent_state = record.move_id.state name = fields.Char(string="Label") + move_name = fields.Char(string='Number', related='move_id.name', store=True, index=True) quantity = fields.Float(digits=dp.get_precision('Product Unit of Measure'), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very useful for some reports.") product_uom_id = fields.Many2one('uom.uom', string='Unit of Measure') @@ -1532,7 +1534,7 @@ class AccountMoveLine(models.Model): @api.multi def open_reconcile_view(self): - [action] = self.env.ref('account.action_account_moves_all_a').read() + [action] = self.env.ref('account.action_account_moves_all').read() ids = [] for aml in self: if aml.account_id.reconcile: diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 808393d89a5..1556bb14628 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -129,11 +129,10 @@ class TestPayment(AccountingTestCase): }) payment.post() self.assertRecordValues(payment.move_line_ids, [ + {'account_id': self.account_usd.id, 'debit': 0.0, 'credit': 32.70, 'amount_currency': -50, 'currency_id': self.currency_usd_id}, + {'account_id': self.transfer_account.id, 'debit': 32.70, 'credit': 0.0, 'amount_currency': 50, 'currency_id': self.currency_usd_id}, {'account_id': self.transfer_account.id, 'debit': 0.0, 'credit': 32.70, 'amount_currency': -50, 'currency_id': self.currency_usd_id}, {'account_id': self.account_eur.id, 'debit': 32.70, 'credit': 0.0, 'amount_currency': 0, 'currency_id': False}, - {'account_id': self.account_usd.id, 'debit': 0.0, 'credit': 32.70, 'amount_currency': -50, 'currency_id': self.currency_usd_id}, - {'account_id': self.transfer_account.id, 'debit': 32.70, 'credit': 0.0, 'amount_currency': 50, - 'currency_id': self.currency_usd_id}, ]) def test_payment_chf_journal_usd(self): diff --git a/addons/account/views/account_analytic_view.xml b/addons/account/views/account_analytic_view.xml index e3c773b1ce7..7f8164329b7 100644 --- a/addons/account/views/account_analytic_view.xml +++ b/addons/account/views/account_analytic_view.xml @@ -68,7 +68,7 @@ - + - + + domain="[('type_tax_use','=','purchase'),('company_id', '=', parent.company_id)]"/> @@ -539,10 +539,9 @@ - + + domain="[('type_tax_use','=','sale'),('company_id', '=', parent.company_id)]"/> diff --git a/addons/account/views/account_menuitem.xml b/addons/account/views/account_menuitem.xml index 14f667247ad..e1a8b60121e 100644 --- a/addons/account/views/account_menuitem.xml +++ b/addons/account/views/account_menuitem.xml @@ -13,9 +13,11 @@ - + + + - + @@ -34,4 +36,3 @@ - diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index aa2e1a35123..6f3dd3c1f27 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -131,7 +131,7 @@ account.move.line.tree account.move.line - + @@ -154,17 +154,111 @@ + + + + + + account.move.line.tree.grouped + account.move.line + + + + + + + + + + + + + + + + + + + + + + + -