mirror of
https://github.com/bringout/oca-ocb-l10n_asia-pacific.git
synced 2026-04-25 07:22:06 +02:00
19.0 vanilla
This commit is contained in:
parent
7dc55599c6
commit
7f43bbbfcc
650 changed files with 45260 additions and 33436 deletions
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import template_th
|
||||
from . import res_partner
|
||||
from . import account_move
|
||||
from . import ir_actions_report
|
||||
from . import res_bank
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ from odoo.exceptions import UserError
|
|||
class IrActionsReport(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
|
||||
def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
|
||||
def _pre_render_qweb_pdf(self, report_ref, res_ids=None, data=None):
|
||||
# Check for reports only available for invoices.
|
||||
if self._get_report(report_ref).report_name == 'l10n_th.report_commercial_invoice':
|
||||
invoices = self.env['account.move'].browse(res_ids)
|
||||
if any(not x.is_invoice(include_receipts=True) for x in invoices):
|
||||
raise UserError(_("Only invoices could be printed."))
|
||||
|
||||
return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data)
|
||||
return super()._pre_render_qweb_pdf(report_ref, res_ids=res_ids, data=data)
|
||||
|
|
|
|||
67
odoo-bringout-oca-ocb-l10n_th/l10n_th/models/res_bank.py
Normal file
67
odoo-bringout-oca-ocb-l10n_th/l10n_th/models/res_bank.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# 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=[('ewallet_id', 'Ewallet ID'),
|
||||
('merchant_tax_id', 'Merchant Tax ID'),
|
||||
('mobile', "Mobile Number")],
|
||||
ondelete={'ewallet_id': 'set default', 'merchant_tax_id': 'set default', 'mobile': 'set default'})
|
||||
|
||||
@api.constrains('proxy_type', 'proxy_value', 'partner_id')
|
||||
def _check_th_proxy(self):
|
||||
tax_id_re = re.compile(r'^[0-9]{13}$')
|
||||
mobile_re = re.compile(r'^[0-9]{10}$')
|
||||
for bank in self.filtered(lambda b: b.country_code == 'TH'):
|
||||
if bank.proxy_type not in ['ewallet_id', 'merchant_tax_id', 'mobile', 'none', False]:
|
||||
raise ValidationError(_("The QR Code Type must be either Ewallet ID, Merchant Tax ID or Mobile Number to generate a Thailand Bank QR code for account number %s.", bank.acc_number))
|
||||
if bank.proxy_type == 'merchant_tax_id' and (not bank.proxy_value or not tax_id_re.match(bank.proxy_value)):
|
||||
raise ValidationError(_("The Merchant Tax ID must be in the format 1234567890123 for account number %s.", bank.acc_number))
|
||||
if bank.proxy_type == 'mobile' and (not bank.proxy_value or not mobile_re.match(bank.proxy_value)):
|
||||
raise ValidationError(_("The Mobile Number must be in the format 0812345678 for account number %s.", bank.acc_number))
|
||||
|
||||
@api.depends('country_code')
|
||||
def _compute_country_proxy_keys(self):
|
||||
bank_th = self.filtered(lambda b: b.country_code == 'TH')
|
||||
bank_th.country_proxy_keys = 'ewallet_id,merchant_tax_id,mobile'
|
||||
super(ResPartnerBank, self - bank_th)._compute_country_proxy_keys()
|
||||
|
||||
@api.depends('country_code')
|
||||
def _compute_display_qr_setting(self):
|
||||
bank_th = self.filtered(lambda b: b.country_code == 'TH')
|
||||
bank_th.display_qr_setting = True
|
||||
super(ResPartnerBank, self - bank_th)._compute_display_qr_setting()
|
||||
|
||||
def _get_merchant_account_info(self):
|
||||
if self.country_code == 'TH':
|
||||
proxy_type_mapping = {
|
||||
'mobile': 1,
|
||||
'merchant_tax_id': 2,
|
||||
'ewallet_id': 3,
|
||||
}
|
||||
proxy_value = re.sub(r"^0", "66", self.proxy_value).zfill(13) if self.proxy_type == 'mobile' else self.proxy_value
|
||||
vals = [
|
||||
(0, 'A000000677010111'),
|
||||
(proxy_type_mapping[self.proxy_type], proxy_value),
|
||||
]
|
||||
return (29, ''.join([self._serialize(*val) for val in vals]))
|
||||
return super()._get_merchant_account_info()
|
||||
|
||||
def _get_error_messages_for_qr(self, qr_method, debtor_partner, currency):
|
||||
if qr_method == 'emv_qr' and self.country_code == 'TH':
|
||||
if currency.name not in ['THB']:
|
||||
return _("Can't generate a PayNow QR code with a currency other than THB.")
|
||||
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' and self.country_code == 'TH' and self.proxy_type not in ['ewallet_id', 'merchant_tax_id', 'mobile']:
|
||||
return _("The PayNow Type must be either Ewallet ID, Merchant Tax ID or Mobile Number to generate a Thailand Bank QR code")
|
||||
|
||||
return super()._check_for_qr_code_errors(qr_method, amount, currency, debtor_partner, free_communication, structured_communication)
|
||||
|
|
@ -2,15 +2,17 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
l10n_th_branch_name = fields.Char(compute="_l10n_th_get_branch_name")
|
||||
l10n_th_branch_name = fields.Char(compute="_compute_l10n_th_branch_name")
|
||||
|
||||
def _l10n_th_get_branch_name(self):
|
||||
def _compute_l10n_th_branch_name(self):
|
||||
for partner in self:
|
||||
if not partner.is_company or partner.country_code != 'TH':
|
||||
partner.l10n_th_branch_name = ""
|
||||
else:
|
||||
code = partner.company_registry
|
||||
partner.l10n_th_branch_name = f"Branch {code}" if code else "Headquarter"
|
||||
partner.l10n_th_branch_name = partner.env._("Branch %(code)s", code=code) if code else partner.env._(
|
||||
"Headquarter")
|
||||
|
|
|
|||
43
odoo-bringout-oca-ocb-l10n_th/l10n_th/models/template_th.py
Normal file
43
odoo-bringout-oca-ocb-l10n_th/l10n_th/models/template_th.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# 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('th')
|
||||
def _get_th_template_data(self):
|
||||
return {
|
||||
'code_digits': '6',
|
||||
'property_account_receivable_id': 'l10n_th_account_112100',
|
||||
'property_account_payable_id': 'l10n_th_account_212100',
|
||||
'property_stock_valuation_account_id': 'l10n_th_account_113100',
|
||||
'downpayment_account_id': 'l10n_th_account_212400',
|
||||
}
|
||||
|
||||
@template('th', 'res.company')
|
||||
def _get_th_res_company(self):
|
||||
return {
|
||||
self.env.company.id: {
|
||||
'account_fiscal_country_id': 'base.th',
|
||||
'bank_account_code_prefix': '11120',
|
||||
'cash_account_code_prefix': '11110',
|
||||
'transfer_account_code_prefix': 'l10n_th_account_11120',
|
||||
'account_default_pos_receivable_account_id': 'l10n_th_account_112101',
|
||||
'income_currency_exchange_account_id': 'l10n_th_account_421300',
|
||||
'expense_currency_exchange_account_id': 'l10n_th_account_621200',
|
||||
'account_journal_suspense_account_id': 'l10n_th_account_111201',
|
||||
'account_journal_early_pay_discount_loss_account_id': 'l10n_th_account_411400',
|
||||
'account_journal_early_pay_discount_gain_account_id': 'l10n_th_account_421500',
|
||||
'account_sale_tax_id': 'tax_output_vat',
|
||||
'account_purchase_tax_id': 'tax_input_vat',
|
||||
'default_cash_difference_income_account_id': 'l10n_th_account_421600',
|
||||
'default_cash_difference_expense_account_id': 'l10n_th_account_622200',
|
||||
'transfer_account_id': 'l10n_th_account_111202',
|
||||
'expense_account_id': 'l10n_th_account_511100',
|
||||
'income_account_id': 'l10n_th_account_411100',
|
||||
'account_stock_valuation_id': 'l10n_th_account_113100',
|
||||
'tax_exigibility': 'True'
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue