From 1cc848134d1c208601be3f1bd687120e44fc41d8 Mon Sep 17 00:00:00 2001 From: Chill Date: Tue, 27 Feb 2024 18:34:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=AD=E6=96=87=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E5=92=8C=E9=98=BF=E6=8B=89=E4=BC=AF=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- l10n_cn_standard_latest/__manifest__.py | 8 +- l10n_cn_standard_latest/models/__init__.py | 1 + .../models/account_move.py | 34 +++++ .../report/account_report.xml | 16 +++ .../report/report_voucher.xml | 121 ++++++++++++++++++ .../static/description/index.html | 4 +- 6 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 l10n_cn_standard_latest/models/account_move.py create mode 100644 l10n_cn_standard_latest/report/account_report.xml create mode 100644 l10n_cn_standard_latest/report/report_voucher.xml diff --git a/l10n_cn_standard_latest/__manifest__.py b/l10n_cn_standard_latest/__manifest__.py index 6fe45cc8..b9495288 100644 --- a/l10n_cn_standard_latest/__manifest__.py +++ b/l10n_cn_standard_latest/__manifest__.py @@ -30,7 +30,8 @@ 4. 更新税信息。 5. 增加树状结构,支持二级科目,可设置上级科目,配合 "app_web_superbar" 使用可轻易实现树状导航。 6. 使用金蝶的会计科目命名法对多级科目进行初始化。可自行调整为用友科目命名法 - 7. 注意,必须在没有业务数据,没有会计科目的初始环境。可以使用 "app_odoo_customize" 模块清除财务数据,重置会计科目。 + 7. 增加中文数字和阿拉伯数字的转换(需安装cn2an库,pip3 install cn2an) + 8. 注意,必须在没有业务数据,没有会计科目的初始环境。可以使用 "app_odoo_customize" 模块清除财务数据,重置会计科目。 如果是多语种环境需要自行更改翻译,主要体现在3%,6%,13%增值税处理。 中国财务,中国会计,中国城市 @@ -56,9 +57,14 @@ 'views/account_account_views.xml', 'views/account_views.xml', 'data/account_account_tag_data.xml', + 'report/account_report.xml', + 'report/report_voucher.xml', ], 'post_init_hook': 'post_init_hook', 'installable': True, 'application': True, 'auto_install': False, + 'external_dependencies': { + 'python': ['cn2an'] + }, } diff --git a/l10n_cn_standard_latest/models/__init__.py b/l10n_cn_standard_latest/models/__init__.py index 791ba3cb..bd733064 100644 --- a/l10n_cn_standard_latest/models/__init__.py +++ b/l10n_cn_standard_latest/models/__init__.py @@ -5,6 +5,7 @@ from . import account_account from . import account_tax_group from . import account_journal from . import res_currency +from . import account_move diff --git a/l10n_cn_standard_latest/models/account_move.py b/l10n_cn_standard_latest/models/account_move.py new file mode 100644 index 00000000..2325d311 --- /dev/null +++ b/l10n_cn_standard_latest/models/account_move.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.osv import expression + +try: + from cn2an import an2cn +except ImportError: + an2cn = None + +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') + payment_ids = self.line_ids.mapped('payment_id') + if statement_ids: + domains.append([('res_model', '=', 'account.bank.statement'), ('res_id', 'in', statement_ids.ids)]) + if payment_ids: + domains.append([('res_model', '=', 'account.payment'), ('res_id', 'in', payment_ids.ids)]) + return self.env['ir.attachment'].search_count(expression.OR(domains)) \ No newline at end of file diff --git a/l10n_cn_standard_latest/report/account_report.xml b/l10n_cn_standard_latest/report/account_report.xml new file mode 100644 index 00000000..140e68f9 --- /dev/null +++ b/l10n_cn_standard_latest/report/account_report.xml @@ -0,0 +1,16 @@ + + + + + + Voucher + account.move + qweb-pdf + l10n_cn_standard_latest.report_voucher + l10n_cn_standard_latest.report_voucher + 'Voucher_%s' % (object.name) + form + + + + diff --git a/l10n_cn_standard_latest/report/report_voucher.xml b/l10n_cn_standard_latest/report/report_voucher.xml new file mode 100644 index 00000000..be076dd7 --- /dev/null +++ b/l10n_cn_standard_latest/report/report_voucher.xml @@ -0,0 +1,121 @@ + + + + + + + + + + diff --git a/l10n_cn_standard_latest/static/description/index.html b/l10n_cn_standard_latest/static/description/index.html index 1ef8e03e..0faa080b 100644 --- a/l10n_cn_standard_latest/static/description/index.html +++ b/l10n_cn_standard_latest/static/description/index.html @@ -4,7 +4,7 @@

App Latest Chinese Account chart 2021.

Set all chinese default value. Like Default country, timezone, currency, partner...

-

Lastest update: v17.24.02.26

+

Lastest update: v17.24.02.27

@@ -14,7 +14,7 @@