From a42f975df2612dab1f96a1298f313380e5df1292 Mon Sep 17 00:00:00 2001 From: "Maximilien (malb)" Date: Wed, 29 Nov 2023 11:39:59 +0100 Subject: [PATCH] [IMP] l10_dk_bookkeeping: rate at transaction Following the Bookkeeping Act Request we needed to have the conversion rate at the time of the move (only when having a move with a currency different as the one of the company) on the header of the form view. This pr will add a new compute stored field, that will be displayed on the header of the move only when the current company is Danemark, when the company currency is different as the move currency and if there is at least a line. The information we will display is the currency_rate of the first line since on invoice and bill the currency_rate is the same for all the lines. We also added a related on account_move_line to be able to see the rate on the journal items list view. closes odoo/odoo#141954 Task: 3592881 Signed-off-by: Florian Gilbert (flg) --- addons/l10n_dk_bookkeeping/__init__.py | 3 +++ addons/l10n_dk_bookkeeping/__manifest__.py | 18 +++++++++++++ addons/l10n_dk_bookkeeping/models/__init__.py | 2 ++ .../models/account_move.py | 23 +++++++++++++++++ .../views/account_move_views.xml | 25 +++++++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 addons/l10n_dk_bookkeeping/__init__.py create mode 100644 addons/l10n_dk_bookkeeping/__manifest__.py create mode 100644 addons/l10n_dk_bookkeeping/models/__init__.py create mode 100644 addons/l10n_dk_bookkeeping/models/account_move.py create mode 100644 addons/l10n_dk_bookkeeping/views/account_move_views.xml diff --git a/addons/l10n_dk_bookkeeping/__init__.py b/addons/l10n_dk_bookkeeping/__init__.py new file mode 100644 index 00000000000..d6210b1285d --- /dev/null +++ b/addons/l10n_dk_bookkeeping/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/addons/l10n_dk_bookkeeping/__manifest__.py b/addons/l10n_dk_bookkeeping/__manifest__.py new file mode 100644 index 00000000000..8983d830569 --- /dev/null +++ b/addons/l10n_dk_bookkeeping/__manifest__.py @@ -0,0 +1,18 @@ +{ + 'name': 'Denmark - Bookkeeping Act', + 'version': '1.0', + 'description': """ +This module contains all that is needed for the Bookkeeping Act + """, + 'summary': "Bookkeeping Act", + 'countries': ['dk'], + 'depends': [ + 'l10n_dk', + ], + 'data': [ + 'views/account_move_views.xml', + ], + 'installable': True, + 'auto_install': True, + 'license': 'LGPL-3', +} diff --git a/addons/l10n_dk_bookkeeping/models/__init__.py b/addons/l10n_dk_bookkeeping/models/__init__.py new file mode 100644 index 00000000000..00487dbe0c1 --- /dev/null +++ b/addons/l10n_dk_bookkeeping/models/__init__.py @@ -0,0 +1,2 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import account_move diff --git a/addons/l10n_dk_bookkeeping/models/account_move.py b/addons/l10n_dk_bookkeeping/models/account_move.py new file mode 100644 index 00000000000..e6e9712eee9 --- /dev/null +++ b/addons/l10n_dk_bookkeeping/models/account_move.py @@ -0,0 +1,23 @@ +from odoo import api, fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + l10n_dk_currency_rate_at_transaction = fields.Float( + string='Rate', + compute='_compute_currency_rate_at_transaction', readonly=True, store=True, + digits=0, + ) + l10n_dk_show_currency_rate = fields.Boolean(compute='_compute_show_currency_rate') + + @api.depends('line_ids') + def _compute_currency_rate_at_transaction(self): + for record in self: + if record.line_ids: + record.l10n_dk_currency_rate_at_transaction = record.line_ids[0].currency_rate + + @api.depends('country_code', 'company_currency_id', 'currency_id', 'line_ids') + def _compute_show_currency_rate(self): + for record in self: + record.l10n_dk_show_currency_rate = record.country_code == 'DK' and record.company_currency_id != record.currency_id and record.line_ids diff --git a/addons/l10n_dk_bookkeeping/views/account_move_views.xml b/addons/l10n_dk_bookkeeping/views/account_move_views.xml new file mode 100644 index 00000000000..54558c1742d --- /dev/null +++ b/addons/l10n_dk_bookkeeping/views/account_move_views.xml @@ -0,0 +1,25 @@ + + + + account.move.form.l10n_dk + account.move + + + + + + + + + + + account.move.line.tree.l10n_dk + account.move.line + + + + + + + +