[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#106239 X-original-commit: 634c7bbe687c850b23e811b4b7e7b7da77313d99 Related: odoo/enterprise#34234 Signed-off-by: Josse Colpaert <jco@odoo.com> Signed-off-by: Mohamed Megahed Abbas Megahed SALLAM (mome) <mome@odoo.com>
This commit is contained in:
@@ -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 + '%'),
|
||||
|
||||
@@ -256,7 +256,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():
|
||||
|
||||
@@ -44,7 +44,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).
|
||||
@@ -122,11 +122,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):
|
||||
@@ -353,7 +353,7 @@ class ResPartnerBank(models.Model):
|
||||
error_messages.append(_("The account type isn't QR-IBAN or IBAN."))
|
||||
if self.partner_id.country_id.code != 'CH':
|
||||
error_messages.append(_("Your company isn't located in Switzerland."))
|
||||
if not debtor_partner or debtor_partner.country_id.code != 'CH':
|
||||
if not debtor_partner or debtor_partner.country_id.code not in ('CH', 'LI'):
|
||||
error_messages.append(_("The debtor partner's address isn't located in Switzerland."))
|
||||
if currency.id not in (self.env.ref('base.EUR').id, self.env.ref('base.CHF').id):
|
||||
error_messages.append(_("The currency isn't EUR nor CHF. \r\n"))
|
||||
|
||||
Reference in New Issue
Block a user