summaryrefslogtreecommitdiff
path: root/addons/l10n_ch
diff options
context:
space:
mode:
authorLaurent Smet <las@odoo.com>2019-10-29 12:21:27 +0000
committerqdp-odoo <qdp@odoo.com>2020-04-10 09:47:24 +0000
commitcaeb782841fc5a7ad71a196e2c9ee67644ef9074 (patch)
tree28103bc29ab4f0d98162095f607c4c6ab1433f25 /addons/l10n_ch
parentb4d1360ed1d71c8fda44ca0c3b1a80d5a112b93f (diff)
[IMP] account,*: Improve bank statements/payments workflow
- Create journal entries as soon as bank/cash statement lines are created, temporary booked on a suspense account set on the journal. - Simplify the management of "blue" lines in the reconciliation widget. A "blue" line is now a journal item using a temporary liquidity account (outstanding payment/receipt accounts, set on the journal). - Adapt and simplify the bank reconciliation report. - Remove the bank reconciliation threshold date. The reconciliation report will show the not already reconciled journal entries using a liquidity account and the not already reconciled journal entries using a temporary liquidity account. Without accounting, an account.payment will involve directly the liquidity account and then, will be considered as a statement line directly. - Remove the post_at bank reconciliation feature. The "paid" state will be set on the invoices only if reconciled with a journal entry involving the journal's liquidity account. With invoicing, the payment will do that so the "in_payment" state should never be shown up. With accounting, only the statement lines have the power to move an invoice to the "paid" state. - Fix various corner cases about the management of multi-currency in bank statement lines. - Fix the conversion dates in multi-currency: Since the bank/cash is always used on the statement lines, it will use always the real "bank" date instead of the fictive payment one. - Ensure the 'reconcile' method will raise an error if the involved moves are not posted. related enterprise PR odoo/enterprise#7019 closes odoo/odoo#41301 --task: 2092096 Related: odoo/upgrade#1018 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Diffstat (limited to 'addons/l10n_ch')
-rw-r--r--addons/l10n_ch/models/account_invoice.py32
-rw-r--r--addons/l10n_ch/report/isr_report.xml12
-rw-r--r--addons/l10n_ch/report/swissqr_report.xml14
-rw-r--r--addons/l10n_ch/tests/test_ch_qr_code.py8
-rw-r--r--addons/l10n_ch/views/account_invoice_view.xml2
5 files changed, 34 insertions, 34 deletions
diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py
index fba400be9db..5e0072c76f2 100644
--- a/addons/l10n_ch/models/account_invoice.py
+++ b/addons/l10n_ch/models/account_invoice.py
@@ -28,7 +28,7 @@ class AccountMove(models.Model):
l10n_ch_isr_sent = fields.Boolean(default=False, help="Boolean value telling whether or not the ISR corresponding to this invoice has already been printed or sent by mail.")
l10n_ch_currency_name = fields.Char(related='currency_id.name', readonly=True, string="Currency Name", help="The name of this invoice's currency") #This field is used in the "invisible" condition field of the 'Print ISR' button.
- @api.depends('invoice_partner_bank_id.l10n_ch_isr_subscription_eur', 'invoice_partner_bank_id.l10n_ch_isr_subscription_chf')
+ @api.depends('partner_bank_id.l10n_ch_isr_subscription_eur', 'partner_bank_id.l10n_ch_isr_subscription_chf')
def _compute_l10n_ch_isr_subscription(self):
""" Computes the ISR subscription identifying your company or the bank that allows to generate ISR. And formats it accordingly"""
def _format_isr_subscription(isr_subscription):
@@ -46,11 +46,11 @@ class AccountMove(models.Model):
for record in self:
record.l10n_ch_isr_subscription = False
record.l10n_ch_isr_subscription_formatted = False
- if record.invoice_partner_bank_id:
+ if record.partner_bank_id:
if record.currency_id.name == 'EUR':
- isr_subscription = record.invoice_partner_bank_id.l10n_ch_isr_subscription_eur
+ isr_subscription = record.partner_bank_id.l10n_ch_isr_subscription_eur
elif record.currency_id.name == 'CHF':
- isr_subscription = record.invoice_partner_bank_id.l10n_ch_isr_subscription_chf
+ isr_subscription = record.partner_bank_id.l10n_ch_isr_subscription_chf
else:
#we don't format if in another currency as EUR or CHF
continue
@@ -60,7 +60,7 @@ class AccountMove(models.Model):
record.l10n_ch_isr_subscription = _format_isr_subscription_scanline(isr_subscription)
record.l10n_ch_isr_subscription_formatted = _format_isr_subscription(isr_subscription)
- @api.depends('name', 'invoice_partner_bank_id.l10n_ch_postal')
+ @api.depends('name', 'partner_bank_id.l10n_ch_postal')
def _compute_l10n_ch_isr_number(self):
""" The ISR reference number is 27 characters long. The first 12 of them
contain the postal account number of this ISR's issuer, removing the zeros
@@ -72,8 +72,8 @@ class AccountMove(models.Model):
of a recursive modulo 10 on its first 26 characters.
"""
for record in self:
- if record.name and record.invoice_partner_bank_id and record.invoice_partner_bank_id.l10n_ch_postal:
- invoice_issuer_ref = record.invoice_partner_bank_id.l10n_ch_postal.ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0')
+ if record.name and record.partner_bank_id and record.partner_bank_id.l10n_ch_postal:
+ invoice_issuer_ref = record.partner_bank_id.l10n_ch_postal.ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0')
invoice_ref = re.sub('[^\d]', '', record.name)
#We only keep the last digits of the sequence number if it is too long
invoice_ref = invoice_ref[-l10n_ch_ISR_NUMBER_ISSUER_LENGTH:]
@@ -95,7 +95,7 @@ class AccountMove(models.Model):
return res
for record in self:
- if record.name and record.invoice_partner_bank_id and record.invoice_partner_bank_id.l10n_ch_postal:
+ if record.name and record.partner_bank_id and record.partner_bank_id.l10n_ch_postal:
record.l10n_ch_isr_number_spaced = _space_isr_number(record.l10n_ch_isr_number)
else:
record.l10n_ch_isr_number_spaced = False
@@ -103,9 +103,9 @@ class AccountMove(models.Model):
@api.depends(
'currency_id.name', 'amount_residual', 'name',
- 'invoice_partner_bank_id.l10n_ch_postal',
- 'invoice_partner_bank_id.l10n_ch_isr_subscription_eur',
- 'invoice_partner_bank_id.l10n_ch_isr_subscription_chf')
+ 'partner_bank_id.l10n_ch_postal',
+ 'partner_bank_id.l10n_ch_isr_subscription_eur',
+ 'partner_bank_id.l10n_ch_isr_subscription_chf')
def _compute_l10n_ch_isr_optical_line(self):
""" The optical reading line of the ISR looks like this :
left>isr_ref+ bank_ref>
@@ -142,16 +142,16 @@ class AccountMove(models.Model):
@api.depends(
'move_type', 'name', 'currency_id.name',
- 'invoice_partner_bank_id.l10n_ch_postal',
- 'invoice_partner_bank_id.l10n_ch_isr_subscription_eur',
- 'invoice_partner_bank_id.l10n_ch_isr_subscription_chf')
+ 'partner_bank_id.l10n_ch_postal',
+ 'partner_bank_id.l10n_ch_isr_subscription_eur',
+ 'partner_bank_id.l10n_ch_isr_subscription_chf')
def _compute_l10n_ch_isr_valid(self):
"""Returns True if all the data required to generate the ISR are present"""
for record in self:
record.l10n_ch_isr_valid = record.move_type == 'out_invoice' and\
record.name and \
record.l10n_ch_isr_subscription and \
- record.invoice_partner_bank_id.l10n_ch_postal and \
+ record.partner_bank_id.l10n_ch_postal and \
record.l10n_ch_currency_name in ['EUR', 'CHF']
def split_total_amount(self):
@@ -171,7 +171,7 @@ class AccountMove(models.Model):
"""
self.ensure_one()
return self.display_qr_code and \
- self.invoice_partner_bank_id._eligible_for_qr_code('ch_qr', self.partner_id, self.currency_id)
+ self.partner_bank_id._eligible_for_qr_code('ch_qr', self.partner_id, self.currency_id)
def isr_print(self):
""" Triggered by the 'Print ISR' button.
diff --git a/addons/l10n_ch/report/isr_report.xml b/addons/l10n_ch/report/isr_report.xml
index bbc3ed89641..bbf50ae6e7f 100644
--- a/addons/l10n_ch/report/isr_report.xml
+++ b/addons/l10n_ch/report/isr_report.xml
@@ -62,9 +62,9 @@
<t t-if="print_bank">
<div id="voucher-for-bank">
<p t-if="not invoice.company_id.l10n_ch_isr_preprinted_bank">
- <t t-esc="invoice.invoice_partner_bank_id.bank_id.name"/><br />
- <t t-esc="invoice.invoice_partner_bank_id.bank_id.zip"/>
- <t t-esc="invoice.invoice_partner_bank_id.bank_id.city"/>
+ <t t-esc="invoice.partner_bank_id.bank_id.name"/><br />
+ <t t-esc="invoice.partner_bank_id.bank_id.zip"/>
+ <t t-esc="invoice.partner_bank_id.bank_id.city"/>
</p>
</div>
<!--Zugunsten von/En faveur de/A favore di-->
@@ -103,9 +103,9 @@
<t t-if="print_bank">
<div id="slip-for-bank">
<p t-if="not invoice.company_id.l10n_ch_isr_preprinted_bank">
- <t t-esc="invoice.invoice_partner_bank_id.bank_id.name"/><br />
- <t t-esc="invoice.invoice_partner_bank_id.bank_id.zip"/>
- <t t-esc="invoice.invoice_partner_bank_id.bank_id.city"/>
+ <t t-esc="invoice.partner_bank_id.bank_id.name"/><br />
+ <t t-esc="invoice.partner_bank_id.bank_id.zip"/>
+ <t t-esc="invoice.partner_bank_id.bank_id.city"/>
</p>
</div>
<!--Zugunsten von/En faveur de/A favore di-->
diff --git a/addons/l10n_ch/report/swissqr_report.xml b/addons/l10n_ch/report/swissqr_report.xml
index 795c675bbf9..54a3450e515 100644
--- a/addons/l10n_ch/report/swissqr_report.xml
+++ b/addons/l10n_ch/report/swissqr_report.xml
@@ -9,7 +9,7 @@
<xpath expr="//div[@id='qrcode']" position="after">
<link type="text/css" rel="stylesheet" href="/l10n_ch/static/src/scss/report_swissqr.css"/>
<div class="swissqr_content" t-if="o.display_swiss_qr_code()">
- <div class="swissqr_body" t-if="o.invoice_partner_bank_id._eligible_for_qr_code('ch_qr', o.partner_id, o.currency_id)">
+ <div class="swissqr_body" t-if="o.partner_bank_id._eligible_for_qr_code('ch_qr', o.partner_id, o.currency_id)">
<div id="title_zone" class="swissqr_column_left title_zone">
<span class="swissqr_text title title_zone">QR-bill payment part</span><br/>
</div>
@@ -19,11 +19,11 @@
<span class="swissqr_text content">Credit transfer</span>
</div>
- <img class="swissqr" t-att-src="o.invoice_partner_bank_id.build_qr_code_url(o.amount_residual, o.ref or o.name, o.invoice_payment_ref, o.currency_id, o.partner_id, 'ch_qr')"/>
+ <img class="swissqr" t-att-src="o.partner_bank_id.build_qr_code_url(o.amount_residual, o.ref or o.name, o.payment_reference, o.currency_id, o.partner_id, 'ch_qr')"/>
<div id="indications_zone" class="swissqr_column_right indication_zone">
<span class="swissqr_text title">Account</span><br/>
- <span class="swissqr_text content" t-field="o.invoice_partner_bank_id.acc_number"/><br/>
+ <span class="swissqr_text content" t-field="o.partner_bank_id.acc_number"/><br/>
<span class="swissqr_text title">Creditor</span><br/>
<span class="swissqr_text content" t-field="o.company_id.name"/><br/>
@@ -33,11 +33,11 @@
<span class="swissqr_text content" t-field="o.company_id.city"/><br/>
<span class="swissqr_text title">Reference number</span><br/>
- <t t-if="o.invoice_partner_bank_id.currency_id.name == 'EUR'">
- <span class="swissqr_text content" t-field="o.invoice_partner_bank_id.l10n_ch_isr_subscription_eur"/><br/>
+ <t t-if="o.partner_bank_id.currency_id.name == 'EUR'">
+ <span class="swissqr_text content" t-field="o.partner_bank_id.l10n_ch_isr_subscription_eur"/><br/>
</t>
- <t t-if="o.invoice_partner_bank_id.currency_id.name == 'CHF'">
- <span class="swissqr_text content" t-field="o.invoice_partner_bank_id.l10n_ch_isr_subscription_chf"/><br/>
+ <t t-if="o.partner_bank_id.currency_id.name == 'CHF'">
+ <span class="swissqr_text content" t-field="o.partner_bank_id.l10n_ch_isr_subscription_chf"/><br/>
</t>
<span class="swissqr_text title">Additional information</span><br/>
diff --git a/addons/l10n_ch/tests/test_ch_qr_code.py b/addons/l10n_ch/tests/test_ch_qr_code.py
index e46a3a2c1ec..e41dcdd03cc 100644
--- a/addons/l10n_ch/tests/test_ch_qr_code.py
+++ b/addons/l10n_ch/tests/test_ch_qr_code.py
@@ -28,9 +28,9 @@ class TestSwissQRCode(AccountTestInvoicingCommon):
'move_type': 'out_invoice',
'partner_id': cls.partner_a.id,
'currency_id': cls.env.ref('base.CHF').id,
- 'invoice_partner_bank_id': cls.swiss_iban.id,
+ 'partner_bank_id': cls.swiss_iban.id,
'company_id': cls.company_data['company'].id,
- 'invoice_payment_ref': "Papa a vu le fifi de lolo",
+ 'payment_reference': "Papa a vu le fifi de lolo",
'invoice_line_ids': [
(0, 0, {'quantity': 1, 'price_unit': 100})
],
@@ -61,13 +61,13 @@ class TestSwissQRCode(AccountTestInvoicingCommon):
self.ch_qr_invoice.generate_qr_code()
# Now, check with a QR-IBAN as the payment account
- self.ch_qr_invoice.invoice_partner_bank_id = self.swiss_qr_iban
+ self.ch_qr_invoice.partner_bank_id = self.swiss_qr_iban
with self.assertRaises(UserError, msg="It shouldn't be possible to generate a Swiss QR-cde for a QR-IBAN without giving it a valid QR-reference as payment reference."):
self.ch_qr_invoice.generate_qr_code()
# Assigning a QR reference should fix it
- self.ch_qr_invoice.invoice_payment_ref = '210000000003139471430009017'
+ self.ch_qr_invoice.payment_reference = '210000000003139471430009017'
def test_ch_qr_code_detection(self):
""" Checks Swiss QR-code auto-detection when no specific QR-method
diff --git a/addons/l10n_ch/views/account_invoice_view.xml b/addons/l10n_ch/views/account_invoice_view.xml
index a5d56df6b99..f4f9abdee17 100644
--- a/addons/l10n_ch/views/account_invoice_view.xml
+++ b/addons/l10n_ch/views/account_invoice_view.xml
@@ -6,7 +6,7 @@
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
- <xpath expr="//field[@name='invoice_sent']" position="after">
+ <xpath expr="//field[@name='is_move_sent']" position="after">
<field name="l10n_ch_isr_sent" invisible="1"/>
<field name="l10n_ch_currency_name" invisible="1" readonly="1"/>
</xpath>