19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:21 +01:00
parent 7dc55599c6
commit 7f43bbbfcc
650 changed files with 45260 additions and 33436 deletions

View file

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
# Copyright (C) 2014 Tech Receptives (<http://techreceptives.com>).
from . import template_sg
from . import account_move
from . import chart_template
from . import res_company
from . import res_bank
from . import res_partner

View file

@ -1,15 +0,0 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class AccountChartTemplate(models.Model):
_inherit = 'account.chart.template'
def _load(self, company):
res = super()._load(company)
if company.chart_template_id == self.env.ref('l10n_sg.sg_chart_template'):
company.write({
'account_sale_tax_id': self.env.ref(f'l10n_sg.{company.id}_sg_sale_tax_sr_9').id,
'account_purchase_tax_id': self.env.ref(f'l10n_sg.{company.id}_sg_purchase_tax_tx8_9').id,
})
return res

View file

@ -0,0 +1,64 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
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=[('mobile', 'Mobile Number'), ('uen', 'UEN')],
ondelete={'mobile': 'set default', 'uen': 'set default'})
@api.constrains('proxy_type', 'proxy_value', 'partner_id')
def _check_sg_proxy(self):
for bank in self.filtered(lambda b: b.country_code == 'SG'):
if bank.proxy_type not in ['mobile', 'uen', 'none', False]:
raise ValidationError(_("The PayNow Type must be either Mobile or UEN to generate a PayNow QR code for account number %s.", bank.acc_number))
@api.depends('country_code')
def _compute_country_proxy_keys(self):
bank_sg = self.filtered(lambda b: b.country_code == 'SG')
bank_sg.country_proxy_keys = 'mobile,uen'
super(ResPartnerBank, self - bank_sg)._compute_country_proxy_keys()
@api.depends('country_code')
def _compute_display_qr_setting(self):
bank_sg = self.filtered(lambda b: b.country_code == 'SG')
bank_sg.display_qr_setting = True
super(ResPartnerBank, self - bank_sg)._compute_display_qr_setting()
def _get_merchant_account_info(self):
if self.country_code == 'SG':
proxy_type_mapping = {
'mobile': 0,
'uen': 2,
}
merchant_account_vals = [
(0, 'SG.PAYNOW'), # GUID
(1, proxy_type_mapping[self.proxy_type]), # Proxy Type
(2, self.proxy_value), # Proxy Value
(3, 0), # Is Amount Editable
]
merchant_account_info = ''.join([self._serialize(*val) for val in merchant_account_vals])
return (26, merchant_account_info)
return super()._get_merchant_account_info()
def _get_additional_data_field(self, comment):
if self.country_code == 'SG':
return self._serialize(1, comment)
return super()._get_additional_data_field(comment)
def _get_error_messages_for_qr(self, qr_method, debtor_partner, currency):
if qr_method == 'emv_qr' and self.country_code == 'SG':
if currency.name not in ['SGD']:
return _("Can't generate a PayNow QR code with a currency other than SGD.")
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 == 'SG' and self.proxy_type not in ['mobile', 'uen']:
return _("The PayNow Type must be either Mobile Number or UEN.")
return super()._check_for_qr_code_errors(qr_method, amount, currency, debtor_partner, free_communication, structured_communication)

View file

@ -2,10 +2,11 @@
from odoo import fields, models
class ResCompany(models.Model):
_name = 'res.company'
_description = 'Companies'
_inherit = 'res.company'
_inherit = ['res.company']
l10n_sg_unique_entity_number = fields.Char(string='UEN', related="partner_id.l10n_sg_unique_entity_number", readonly=False)

View file

@ -2,8 +2,17 @@
from odoo import fields, models
class ResPartner(models.Model):
_name = 'res.partner'
_inherit = 'res.partner'
l10n_sg_unique_entity_number = fields.Char(string='UEN')
def _deduce_country_code(self):
if self.l10n_sg_unique_entity_number:
return 'SG'
return super()._deduce_country_code()
def _peppol_eas_endpoint_depends(self):
# extends account_edi_ubl_cii
return super()._peppol_eas_endpoint_depends() + ['l10n_sg_unique_entity_number']

View file

@ -0,0 +1,45 @@
# 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('sg')
def _get_sg_template_data(self):
return {
'code_digits': '6',
'property_account_receivable_id': 'account_account_735',
'property_account_payable_id': 'account_account_777',
}
@template('sg', 'res.company')
def _get_sg_res_company(self):
return {
self.env.company.id: {
'account_fiscal_country_id': 'base.sg',
'bank_account_code_prefix': '10141',
'cash_account_code_prefix': '10140',
'transfer_account_code_prefix': '10110',
'account_default_pos_receivable_account_id': 'account_account_737',
'income_currency_exchange_account_id': 'account_account_853',
'expense_currency_exchange_account_id': 'account_account_853',
'account_journal_early_pay_discount_loss_account_id': 'account_account_800',
'account_journal_early_pay_discount_gain_account_id': 'account_account_856',
'account_sale_tax_id': 'sg_sale_tax_sr_9',
'account_purchase_tax_id': 'sg_purchase_tax_tx8_9',
'expense_account_id': 'account_account_819',
'income_account_id': 'account_account_803',
'account_stock_journal_id': 'inventory_valuation',
'account_stock_valuation_id': 'account_account_699',
},
}
@template('sg', 'account.account')
def _get_sg_account_account(self):
return {
'account_account_699': {
'account_stock_variation_id': 'account_account_844',
},
}