[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) <flg@odoo.com>
This commit is contained in:
Maximilien (malb)
2023-12-04 08:51:53 +00:00
parent 8b22980e25
commit a42f975df2
5 changed files with 71 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
@@ -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',
}
@@ -0,0 +1,2 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_move
@@ -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
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_move_form_l10n_dk" model="ir.ui.view">
<field name="name">account.move.form.l10n_dk</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='journal_div']" position="after">
<field name="l10n_dk_show_currency_rate" invisible="1"/>
<field name="l10n_dk_currency_rate_at_transaction" invisible="not l10n_dk_show_currency_rate"/>
</xpath>
</field>
</record>
<record id="view_move_line_tree_l10n_dk" model="ir.ui.view">
<field name="name">account.move.line.tree.l10n_dk</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_move_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='credit']" position="after">
<field name="currency_rate" string="Rate" optional="hide"/>
</xpath>
</field>
</record>
</odoo>