diff --git a/l10n_cn_standard_latest/__manifest__.py b/l10n_cn_standard_latest/__manifest__.py index 1d720414..557d3898 100644 --- a/l10n_cn_standard_latest/__manifest__.py +++ b/l10n_cn_standard_latest/__manifest__.py @@ -9,17 +9,17 @@ { 'name': '2025最新中国会计科目表.企业标准会计.Latest Chinese Accounting for odoo18', - 'version': '18.0.24.12.13', + 'version': '18.0.25.01.15', 'author': 'odooai.cn', 'category': 'Accounting/Localizations/Account Charts', 'website': 'https://www.odooai.cn', 'live_test_url': 'https://demo.odooapp.cn', 'license': 'LGPL-3', 'sequence': 12, - 'summary': """ + 'summary': """ Multi level account chart. Chinese enhance. Focus on account chart. Add account chart group data. Account group, Chinese tax. - Set chinese account report. + Set chinese account report. """, 'description': """ 最新中国化财务,主要针对标准会计科目表作了优化。 diff --git a/l10n_cn_standard_latest/hooks.py b/l10n_cn_standard_latest/hooks.py index c61573fe..fc69e24e 100644 --- a/l10n_cn_standard_latest/hooks.py +++ b/l10n_cn_standard_latest/hooks.py @@ -27,10 +27,10 @@ def pre_init_hook(env): def post_init_hook(env): """ 数据初始化,只在安装后执行,更新时不执行 - 注意 account.account 中 code 处理已不同,主要用 json 存在 code_store 中,故要不可使用 sql, - 同时 group_id 已为 compute 字段,无需设置 - + 中国公司,会计科目表非本模块中国企业会计科目表时,重载 + """ + env['res.company'].search(['|', ('country_id', '=', env.ref('base.cn')), ('country_id.code', '=', 'CN')]).app_set_to_odooai_cn() # cr.execute("UPDATE account_account_template set group_id = " # "(select id from account_group where account_group.code_prefix_start=trim(substring(account_account_template.code from 1 for 1)) limit 1);") diff --git a/l10n_cn_standard_latest/models/__init__.py b/l10n_cn_standard_latest/models/__init__.py index bd733064..b7b6f1a1 100644 --- a/l10n_cn_standard_latest/models/__init__.py +++ b/l10n_cn_standard_latest/models/__init__.py @@ -6,7 +6,4 @@ from . import account_tax_group from . import account_journal from . import res_currency from . import account_move - - - - +from . import res_company diff --git a/l10n_cn_standard_latest/models/account_move.py b/l10n_cn_standard_latest/models/account_move.py index 2e3839cd..a0f291cd 100644 --- a/l10n_cn_standard_latest/models/account_move.py +++ b/l10n_cn_standard_latest/models/account_move.py @@ -11,18 +11,18 @@ except ImportError: class AccountMove(models.Model): _inherit = 'account.move' - + @api.model def check_cn2an(self): return an2cn - + @api.model def _convert_to_amount_in_word(self, number): """Convert number to ``amount in words`` for Chinese financial usage.""" if not self.check_cn2an(): return None return an2cn(number, 'rmb') - + def _count_attachments(self): domains = [[('res_model', '=', 'account.move'), ('res_id', '=', self.id)]] statement_ids = self.line_ids.mapped('statement_id') diff --git a/l10n_cn_standard_latest/models/account_tax_group.py b/l10n_cn_standard_latest/models/account_tax_group.py index d1413359..beb0be70 100644 --- a/l10n_cn_standard_latest/models/account_tax_group.py +++ b/l10n_cn_standard_latest/models/account_tax_group.py @@ -6,4 +6,3 @@ class AccountTaxGroup(models.Model): _inherit = 'account.tax.group' active = fields.Boolean(default=True, help="Set active to false to hide the tax without removing it.") - diff --git a/l10n_cn_standard_latest/models/res_company.py b/l10n_cn_standard_latest/models/res_company.py new file mode 100644 index 00000000..1933e841 --- /dev/null +++ b/l10n_cn_standard_latest/models/res_company.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +import logging +from odoo import models, fields, api, _ + +_logger = logging.getLogger(__name__) + + +class ResCompany(models.Model): + _inherit = 'res.company' + + def app_set_to_odooai_cn(self): + for rec in self: + if rec.country_id.code == 'CN' and rec.chart_template != 'cn_standard': + has_accounting_entries = rec.root_id._existing_accounting() + if not has_accounting_entries: + unaffected_earnings_type = "equity_unaffected" + account = self.env['account.account'].with_company(rec).search([ + *self.env['account.account']._check_company_domain(rec), + ('account_type', '=', unaffected_earnings_type), + ], limit=1) + if account: + account.unlink() + rec.chart_template = 'cn_standard' + self.env['account.chart.template'].try_loading(rec.chart_template, company=rec) diff --git a/l10n_cn_standard_latest/models/template_cn_standard.py b/l10n_cn_standard_latest/models/template_cn_standard.py index 07fb773b..6bdfadd6 100644 --- a/l10n_cn_standard_latest/models/template_cn_standard.py +++ b/l10n_cn_standard_latest/models/template_cn_standard.py @@ -16,7 +16,7 @@ class AccountChartTemplate(models.AbstractModel): # 'account.reconcile.model', # 'account.fiscal.position', # ) - + @template('cn_standard') def _get_cn_standard_template_data(self): return { @@ -57,7 +57,7 @@ class AccountChartTemplate(models.AbstractModel): 'account_journal_early_pay_discount_loss_account_id': 'account_6603', }, } - + @template('cn_standard', 'account.journal') def _get_cn_account_journal(self): return { diff --git a/l10n_cn_standard_latest/static/description/index.html b/l10n_cn_standard_latest/static/description/index.html index 4a6347a6..4ddc6d37 100644 --- a/l10n_cn_standard_latest/static/description/index.html +++ b/l10n_cn_standard_latest/static/description/index.html @@ -17,7 +17,7 @@
-

Lastest update: v18.24.12.13

+

Lastest update: v18.25.01.15