Skip to content
Snippets Groups Projects
Commit e7704303 authored by momegahed's avatar momegahed
Browse files

[FIX] l10n_ch: QR-Invoice don't work for LI customers

Issue :
- Liechtenstein adapted the same QR-Invoice as Switzerland.
However, Odoo only allows the issuance of QR-Invoices to
swiss customers

https://www.llb.li/en/private/paying-and-saving/payment-services/qr-bill#:~:text=Standing%20orders%20based%20on%20orange%20payment%20slips%20can%20no%20longer%20be%20processed%20after%2030%20September%202022.%20Therefore%2C%20these%20standing%20orders%20need%20to%20be%20newly%20set%20up%20on%20the%20basis%20of%20QR%20bills

.

Fix:
- Allow LI users to be issued QR-Invoices

OPW-2977644

closes odoo/odoo#106153

X-original-commit: 5ce35848
Related: odoo/enterprise#34185
Signed-off-by: default avatarJosse Colpaert <jco@odoo.com>
Signed-off-by: default avatarMohamed Megahed Abbas Megahed SALLAM (mome) <mome@odoo.com>
parent a45d4bd9
Branches
Tags
No related merge requests found
......@@ -15,8 +15,8 @@ def load_translations(env):
def init_settings(env):
'''If the company is localized in Switzerland, activate the cash rounding by default.
'''
# The cash rounding is activated by default only if the company is localized in Switzerland.
for company in env['res.company'].search([('partner_id.country_id.code', '=', "CH")]):
# The cash rounding is activated by default only if the company is localized in Switzerland or Liechtenstein.
for company in env['res.company'].search([('partner_id.country_id.code', 'in', ["CH", "LI"])]):
res_config_id = env['res.config.settings'].create({
'company_id': company.id,
'group_cash_rounding': True
......
......@@ -9,7 +9,7 @@ class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"
def _find_or_create_bank_account(self):
if self.company_id.account_fiscal_country_id.code == 'CH' and _is_l10n_ch_postal(self.account_number):
if self.company_id.account_fiscal_country_id.code in ('CH', 'LI') and _is_l10n_ch_postal(self.account_number):
bank_account = self.env['res.partner.bank'].search(
[('company_id', '=', self.company_id.id),
('sanitized_acc_number', 'like', self.account_number + '%'),
......
......@@ -242,7 +242,7 @@ class AccountMove(models.Model):
@api.depends('move_type', 'partner_bank_id', 'payment_reference')
def _compute_l10n_ch_isr_needs_fixing(self):
for inv in self:
if inv.move_type == 'in_invoice' and inv.company_id.account_fiscal_country_id.code == "CH":
if inv.move_type == 'in_invoice' and inv.company_id.account_fiscal_country_id.code in ('CH', 'LI'):
partner_bank = inv.partner_bank_id
needs_isr_ref = partner_bank.l10n_ch_qr_iban or partner_bank._is_isr_issuer()
if needs_isr_ref and not inv._has_isr_ref():
......
......@@ -45,7 +45,7 @@ def validate_qr_iban(qr_iban):
# We sanitize first so that _check_qr_iban_range() can extract correct IID from IBAN to validate it.
sanitized_qr_iban = sanitize_account_number(qr_iban)
if sanitized_qr_iban[:2] != 'CH':
if sanitized_qr_iban[:2] not in ['CH', 'LI']:
raise ValidationError(_("QR-IBAN numbers are only available in Switzerland."))
# Now, check if it's valid QR-IBAN (based on its IID).
......@@ -123,11 +123,11 @@ class ResPartnerBank(models.Model):
def _compute_l10n_ch_show_subscription(self):
for bank in self:
if bank.partner_id:
bank.l10n_ch_show_subscription = bank.partner_id.ref_company_ids.country_id.code == 'CH'
bank.l10n_ch_show_subscription = bank.partner_id.ref_company_ids.country_id.code in ('CH', 'LI')
elif bank.company_id:
bank.l10n_ch_show_subscription = bank.company_id.account_fiscal_country_id.code == 'CH'
bank.l10n_ch_show_subscription = bank.company_id.account_fiscal_country_id.code in ('CH', 'LI')
else:
bank.l10n_ch_show_subscription = self.env.company.account_fiscal_country_id.code == 'CH'
bank.l10n_ch_show_subscription = self.env.company.account_fiscal_country_id.code in ('CH', 'LI')
@api.depends('acc_number', 'acc_type')
def _compute_sanitized_acc_number(self):
......@@ -207,7 +207,7 @@ class ResPartnerBank(models.Model):
CHXX 0900 0XXX XXXX XXXX K
Where 09000 is the clearing number
"""
return iban.startswith('CH') and iban[4:9] == CLEARING
return iban.startswith(('CH', 'LI')) and iban[4:9] == CLEARING
@api.model
def _pretty_postal_num(self, number):
......@@ -351,7 +351,7 @@ class ResPartnerBank(models.Model):
return self.acc_type == 'iban' and \
self.partner_id.country_id.code == 'CH' and \
(not debtor_partner or debtor_partner.country_id.code == 'CH') \
(not debtor_partner or debtor_partner.country_id.code in ('CH', 'LI')) \
and currency.name in ('EUR', 'CHF')
return super()._eligible_for_qr_code(qr_method, debtor_partner, currency)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment