mirror of
https://github.com/bringout/oca-ocb-l10n_asia-pacific.git
synced 2026-04-26 16:42:06 +02:00
19.0 vanilla
This commit is contained in:
parent
7dc55599c6
commit
7f43bbbfcc
650 changed files with 45260 additions and 33436 deletions
4
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/__init__.py
Normal file
4
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import account_move
|
||||
from . import res_bank
|
||||
from . import template_vn
|
||||
12
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/account_move.py
Normal file
12
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/account_move.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
l10n_vn_e_invoice_number = fields.Char(
|
||||
string='eInvoice Number',
|
||||
help='Electronic Invoicing number.',
|
||||
copy=False,
|
||||
)
|
||||
96
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/res_bank.py
Normal file
96
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/res_bank.py
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import re
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResPartnerBank(models.Model):
|
||||
_inherit = 'res.partner.bank'
|
||||
|
||||
proxy_type = fields.Selection(selection_add=[('merchant_id', 'Merchant ID'),
|
||||
('payment_service', 'Payment Service'),
|
||||
('atm_card', 'ATM Card Number'),
|
||||
('bank_acc', 'Bank Account')],
|
||||
ondelete={'merchant_id': 'set default', 'payment_service': 'set default', 'atm_card': 'set default', 'bank_acc': 'set default'})
|
||||
|
||||
@api.constrains('proxy_type')
|
||||
def _check_vn_proxy(self):
|
||||
for bank in self.filtered(lambda b: b.country_code == 'VN'):
|
||||
if bank.proxy_type not in ['merchant_id', 'payment_service', 'atm_card', 'bank_acc', 'none', False]:
|
||||
raise ValidationError(_("The QR Code Type must be either Merchant ID, ATM Card Number or Bank Account to generate a Vietnam Bank QR code for account number %s.", bank.acc_number))
|
||||
|
||||
@api.depends('country_code')
|
||||
def _compute_country_proxy_keys(self):
|
||||
bank_vn = self.filtered(lambda b: b.country_code == 'VN')
|
||||
bank_vn.country_proxy_keys = 'merchant_id,payment_service,atm_card,bank_acc'
|
||||
super(ResPartnerBank, self - bank_vn)._compute_country_proxy_keys()
|
||||
|
||||
@api.depends('country_code')
|
||||
def _compute_display_qr_setting(self):
|
||||
bank_vn = self.filtered(lambda b: b.country_code == 'VN')
|
||||
bank_vn.display_qr_setting = True
|
||||
super(ResPartnerBank, self - bank_vn)._compute_display_qr_setting()
|
||||
|
||||
def _get_merchant_account_info(self):
|
||||
|
||||
proxy_type_mapping = {
|
||||
'merchant_id': 'QRPUSH',
|
||||
'payment_service': 'QRPUSH',
|
||||
'atm_card': 'QRIBFTTC',
|
||||
'bank_acc': 'QRIBFTTA',
|
||||
}
|
||||
|
||||
if self.country_code != 'VN' or self.proxy_type not in proxy_type_mapping:
|
||||
return super()._get_merchant_account_info()
|
||||
|
||||
payment_network = [
|
||||
(0, self.bank_bic),
|
||||
(1, self.proxy_value),
|
||||
]
|
||||
vals = [
|
||||
(0, 'A000000727'),
|
||||
(1, ''.join([self._serialize(*val) for val in payment_network])),
|
||||
(2, proxy_type_mapping[self.proxy_type]),
|
||||
]
|
||||
return (38, ''.join([self._serialize(*val) for val in vals]))
|
||||
|
||||
def _get_additional_data_field(self, comment):
|
||||
if self.country_code == 'VN':
|
||||
# The first check is too permissive for VietQR.
|
||||
return self._serialize(8, re.sub(r"[^a-zA-Z0-9 _\\\-.]+", "", comment))
|
||||
return super()._get_additional_data_field(comment)
|
||||
|
||||
def _get_qr_code_vals_list(self, qr_method, amount, currency, debtor_partner, free_communication, structured_communication):
|
||||
res = super()._get_qr_code_vals_list(qr_method, amount, currency, debtor_partner, free_communication, structured_communication)
|
||||
if self.country_code == 'VN':
|
||||
merchant_city = (self.partner_id.city and self._remove_accents(self.partner_id.city)[:15]) or (self.partner_id.state_id and self._remove_accents(self.partner_id.state_id.name)[:15]) or ''
|
||||
res[8] = (60, merchant_city)
|
||||
return res
|
||||
|
||||
def _get_error_messages_for_qr(self, qr_method, debtor_partner, currency):
|
||||
if qr_method == 'emv_qr' and self.country_code == 'VN':
|
||||
if currency.name not in ['VND']:
|
||||
return _("Can't generate a Vietnamese QR banking code with a currency other than VND.")
|
||||
if not self.bank_bic:
|
||||
return _("Missing Bank Identifier Code.\n"
|
||||
"Please configure the Bank Identifier Code inside the bank settings.")
|
||||
return None
|
||||
|
||||
return super()._get_error_messages_for_qr(qr_method, debtor_partner, currency)
|
||||
|
||||
def _check_for_qr_code_errors(self, qr_method, amount, currency, debtor_partner, free_communication, structured_communication):
|
||||
if qr_method != 'emv_qr' or self.country_code != 'VN':
|
||||
return super()._check_for_qr_code_errors(qr_method, amount, currency, debtor_partner, free_communication, structured_communication)
|
||||
|
||||
if not (self.partner_id.city or self.partner_id.state_id):
|
||||
return _("Missing Merchant City or State.")
|
||||
if not self.proxy_type:
|
||||
return _("Missing Proxy Type.")
|
||||
if self.proxy_type not in ['merchant_id', 'payment_service', 'atm_card', 'bank_acc']:
|
||||
return _("The proxy type %s is not supported for Vietnamese partners. It must be either Merchant ID, ATM Card Number or Bank Account", self.proxy_type)
|
||||
if not self.proxy_value:
|
||||
return _("Missing Proxy Value.")
|
||||
if not self._get_merchant_account_info():
|
||||
return _("Missing Merchant Account Information.")
|
||||
67
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/template_vn.py
Normal file
67
odoo-bringout-oca-ocb-l10n_vn/l10n_vn/models/template_vn.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models
|
||||
from odoo.addons.account.models.chart_template import template
|
||||
|
||||
|
||||
class AccountChartTemplate(models.AbstractModel):
|
||||
_inherit = 'account.chart.template'
|
||||
|
||||
@template('vn')
|
||||
def _get_vn_template_data(self):
|
||||
return {
|
||||
'code_digits': '4',
|
||||
'property_account_receivable_id': 'chart1311',
|
||||
'property_account_payable_id': 'chart3311',
|
||||
'property_stock_valuation_account_id': 'chart1551',
|
||||
'display_invoice_amount_total_words': True,
|
||||
}
|
||||
|
||||
@template('vn', 'res.company')
|
||||
def _get_vn_res_company(self):
|
||||
return {
|
||||
self.env.company.id: {
|
||||
'anglo_saxon_accounting': True,
|
||||
'account_fiscal_country_id': 'base.vn',
|
||||
'bank_account_code_prefix': '112',
|
||||
'cash_account_code_prefix': '111',
|
||||
'transfer_account_code_prefix': '113',
|
||||
'account_default_pos_receivable_account_id': 'chart1311',
|
||||
'income_currency_exchange_account_id': 'chart515',
|
||||
'expense_currency_exchange_account_id': 'chart635',
|
||||
'account_journal_early_pay_discount_loss_account_id': 'chart635',
|
||||
'account_journal_early_pay_discount_gain_account_id': 'chart515',
|
||||
'account_sale_tax_id': 'tax_sale_vat10',
|
||||
'account_purchase_tax_id': 'tax_purchase_vat10',
|
||||
'transfer_account_id': 'chart1131',
|
||||
'expense_account_id': 'chart632',
|
||||
'income_account_id': 'chart5111',
|
||||
'deferred_expense_account_id': 'chart2421',
|
||||
'deferred_revenue_account_id': 'chart33871',
|
||||
'account_production_wip_account_id': 'chart154',
|
||||
'default_cash_difference_income_account_id': 'chart711',
|
||||
'default_cash_difference_expense_account_id': 'chart811',
|
||||
'tax_calculation_rounding_method': 'round_per_line',
|
||||
'account_stock_journal_id': 'inventory_valuation',
|
||||
'account_stock_valuation_id': 'chart152',
|
||||
'account_journal_suspense_account_id': 'chart1121',
|
||||
},
|
||||
}
|
||||
|
||||
@template('vn', 'account.account')
|
||||
def _get_vn_account_account(self):
|
||||
return {
|
||||
'chart152': {
|
||||
'account_stock_variation_id': 'chart632',
|
||||
},
|
||||
}
|
||||
|
||||
@template('vn', 'account.journal')
|
||||
def _get_vn_account_journal(self):
|
||||
return {
|
||||
'bank': {'default_account_id': 'chart112'},
|
||||
'cash': {
|
||||
'name': self.env._("Cash"),
|
||||
'type': 'cash',
|
||||
'default_account_id': 'chart1111',
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue