diff --git a/app_account_ztree/__manifest__.py b/app_account_ztree/__manifest__.py index fafccae8..0eec0442 100644 --- a/app_account_ztree/__manifest__.py +++ b/app_account_ztree/__manifest__.py @@ -17,7 +17,7 @@ { 'name': "App Account Multi Level Chart, parent children tree", - 'version': '16.23.03.01', + 'version': '16.24.12.12', 'author': 'odooai.cn', 'category': 'Extra tools', 'website': 'https://www.odooai.cn', @@ -38,11 +38,11 @@ 'currency': 'EUR', 'depends': [ 'account', - 'l10n_cn_standard_latest', ], 'images': ['static/description/banner.png'], 'data': [ 'views/account_account_views.xml', + 'views/res_company_views.xml', ], 'demo': [ ], diff --git a/app_account_ztree/i18n/zh_CN.po b/app_account_ztree/i18n/zh_CN.po index f1e36e3e..77fc9d79 100644 --- a/app_account_ztree/i18n/zh_CN.po +++ b/app_account_ztree/i18n/zh_CN.po @@ -1,14 +1,95 @@ # Translation of Odoo Server. +# This file contains the translation of the following modules: +# * app_account_ztree # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 16.0+e-20231112\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-01-08 14:28+0000\n" -"PO-Revision-Date: 2018-01-08 14:28+0000\n" -"Last-Translator: <>\n" +"POT-Creation-Date: 2024-12-12 14:09+0000\n" +"PO-Revision-Date: 2024-12-12 14:09+0000\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" + +#. module: app_account_ztree +#: model:ir.model,name:app_account_ztree.model_account_account +msgid "Account" +msgstr "科目" + +#. module: app_account_ztree +#: model:ir.model,name:app_account_ztree.model_account_chart_template +msgid "Account Chart Template" +msgstr "科目表模版" + +#. module: app_account_ztree +#: model:ir.model.fields,field_description:app_account_ztree.field_res_company__coa_delimiter +msgid "COA Delimiter" +msgstr "会计科目分隔符" + +#. module: app_account_ztree +#. odoo-python +#: code:addons/app_account_ztree/models/account_chart_template.py:0 +#, python-format +msgid "Cannot generate an unused account code." +msgstr "无法生成关联会计科目" + +#. module: app_account_ztree +#: model:ir.model.fields,field_description:app_account_ztree.field_account_account__child_ids +#: model:ir.model.fields,field_description:app_account_ztree.field_account_account_template__child_ids +msgid "Child Chart" +msgstr "下级科目" + +#. module: app_account_ztree +#: model:ir.model.fields,field_description:app_account_ztree.field_account_chart_template__delimiter +msgid "Code Delimiter" +msgstr "分隔符" + +#. module: app_account_ztree +#: model:ir.model,name:app_account_ztree.model_res_company +msgid "Companies" +msgstr "公司" + +#. module: app_account_ztree +#: model:ir.model.fields,help:app_account_ztree.field_account_chart_template__delimiter +msgid "Delimiter after parent account chart" +msgstr "本会计科目与上级科目之前的分隔符" + +#. module: app_account_ztree +#: model:ir.model.fields,help:app_account_ztree.field_res_company__coa_delimiter +msgid "Delimiter after parent account in Chart of Accounts" +msgstr "当前会计科目表中,下级科目与上级科目之前的分隔符" + +#. module: app_account_ztree +#. odoo-python +#: code:addons/app_account_ztree/models/account_chart_template.py:0 +#, python-format +msgid "Liquidity Transfer" +msgstr "流动性转移" + +#. module: app_account_ztree +#: model:ir.model.fields,field_description:app_account_ztree.field_account_account__parent_id +#: model:ir.model.fields,field_description:app_account_ztree.field_account_account_template__parent_id +msgid "Parent Chart" +msgstr "上级科目" + +#. module: app_account_ztree +#: model:ir.model.fields,field_description:app_account_ztree.field_account_account__parent_path +#: model:ir.model.fields,field_description:app_account_ztree.field_account_account_template__parent_path +msgid "Parent Path" +msgstr "树状级别路径" + +#. module: app_account_ztree +#: model:ir.model,name:app_account_ztree.model_account_account_template +msgid "Templates for Accounts" +msgstr "会计科目模板" + +#. module: app_account_ztree +#. odoo-python +#: code:addons/app_account_ztree/models/account_account.py:0 +#, python-format +msgid "Update parent account chart done.
【%s】 records updated." +msgstr "更新会计科目表上下级关系完成。
【%s】 条记录更新完成。" diff --git a/app_account_ztree/models/__init__.py b/app_account_ztree/models/__init__.py index 40a96afc..ebaa5ad6 100644 --- a/app_account_ztree/models/__init__.py +++ b/app_account_ztree/models/__init__.py @@ -1 +1,7 @@ # -*- coding: utf-8 -*- + +from . import account_chart_template +from . import account_account_template +from . import account_account +from . import res_company + diff --git a/app_account_ztree/models/account_account.py b/app_account_ztree/models/account_account.py new file mode 100644 index 00000000..874ff4a3 --- /dev/null +++ b/app_account_ztree/models/account_account.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +import logging + +from odoo import fields, models, api, _ +from odoo.exceptions import UserError, ValidationError + +_logger = logging.getLogger(__name__) + + +class AccountAccount(models.Model): + _inherit = ['account.account'] + _parent_name = "parent_id" + _parent_store = True + _parent_order = 'code' + # _rec_name = 'complete_name' + + parent_id = fields.Many2one('account.account', 'Parent Chart', index=True, ondelete='cascade') + child_ids = fields.One2many('account.account', 'parent_id', 'Child Chart') + parent_path = fields.Char(index=True, unaccent=False) + + @api.model + def _search_new_account_code(self, company, digits, prefix): + # 分隔符,金蝶为 ".",用友为"",注意odoo中一级科目,现金默认定义是4位头,银行是6位头 + delimiter = company.coa_delimiter or '' + for num in range(1, 100): + new_code = str(prefix.ljust(digits - 1, '0')) + delimiter + '%02d' % (num) + rec = self.search([('code', '=', new_code), ('company_id', '=', company.id)], limit=1) + if not rec: + return new_code + return super(AccountAccount, self)._search_new_account_code(company, digits, prefix) + + def refresh_account_parent(self, company=None): + if not company: + company = self.env.user.company_id + self = self.filtered(lambda r: len(r.code) > 2).sorted(key=lambda r: r.code) + done = 0 + # 分隔符 delimiter,用友为"",金蝶为 ".",注意odoo中一级科目,现金默认定义是4位头,银行是6位头 + # 我们使用 用友的多级科目方式,自动生成下级,此处直接覆盖原生 + delimiter = company.chart_template_id.delimiter or '' + for rec in self: + if len(rec.code) > 2: + p_code = rec.code[:len(rec.code) - 2] + if delimiter and delimiter != '': + p_code = rec.code[:len(rec.code) - 2 - len(delimiter)] + p_acc = self.search([('company_id', '=', company.id), ('code', '=', p_code)]) + if p_acc and rec.parent_id != p_acc: + rec.write({'parent_id': p_acc.id}) + done += 1 + + return { + 'effect': { + 'fadeout': 'fast', + 'message': _('Update parent account chart done.
【%s】 records updated.' % done), + 'img_url': '/web/image/%s/%s/image_1024' % (self.env.user._name, + self.env.user.id) if self.env.user.image_1024 else '/web/static/src/img/smile.svg', + 'type': 'rainbow_man', + } + } diff --git a/app_account_ztree/models/account_account_template.py b/app_account_ztree/models/account_account_template.py new file mode 100644 index 00000000..1c5d5a10 --- /dev/null +++ b/app_account_ztree/models/account_account_template.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +# Created on 2018-11-28 +# author: 欧度智能,https://www.odooai.cn +# email: 300883@qq.com +# resource of odooai +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +# Odoo在线中文用户手册(长期更新) +# https://www.odooai.cn/documentation/user/10.0/zh_CN/index.html + +# Odoo10离线中文用户手册下载 +# https://www.odooai.cn/odoo10_user_manual_document_offline/ +# Odoo10离线开发手册下载-含python教程,jquery参考,Jinja2模板,PostgresSQL参考(odoo开发必备) +# https://www.odooai.cn/odoo10_developer_document_offline/ +# description: + +from odoo import api, fields, models, exceptions, _ + +class AccountAccountTemplate(models.Model): + + _inherit = ['account.account.template'] + _parent_name = "parent_id" + _parent_store = True + _parent_order = 'code' + # _rec_name = 'complete_name' + + # todo: 具体项目中,可以parent_id 处理为 compute, inverse=xxx(直接用pass),与 code_digits, + parent_id = fields.Many2one('account.account.template', 'Parent Chart', index=True, ondelete='cascade') + child_ids = fields.One2many('account.account.template', 'parent_id', 'Child Chart') + parent_path = fields.Char(index=True, unaccent=False) + + diff --git a/app_account_ztree/models/account_chart_template.py b/app_account_ztree/models/account_chart_template.py new file mode 100644 index 00000000..8d41dc9a --- /dev/null +++ b/app_account_ztree/models/account_chart_template.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- + +# Created on 2022-07-08 +# author: 欧度智能,https://www.odooai.cn +# email: 300883@qq.com +# resource of odooai +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +# Odoo16在线用户手册(长期更新) +# https://www.odooai.cn/documentation/16.0/zh_CN/index.html + +# Odoo16在线开发者手册(长期更新) +# https://www.odooai.cn/documentation/16.0/zh_CN/developer.html + +# Odoo13在线用户手册(长期更新) +# https://www.odooai.cn/documentation/user/13.0/zh_CN/index.html + +# Odoo13在线开发者手册(长期更新) +# https://www.odooai.cn/documentation/13.0/index.html + +# Odoo在线中文用户手册(长期更新) +# https://www.odooai.cn/documentation/user/10.0/zh_CN/index.html + +# Odoo10离线中文用户手册下载 +# https://www.odooai.cn/odoo10_user_manual_document_offline/ +# Odoo10离线开发手册下载-含python教程,jquery参考,Jinja2模板,PostgresSQL参考(odoo开发必备) +# https://www.odooai.cn/odoo10_developer_document_offline/ +# description: + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError + + +class AccountChartTemplate(models.Model): + # 会计科目表模板,使用此模板的会生成一样的会计科目表 + _inherit = "account.chart.template" + + # 科目分隔符 + delimiter = fields.Char(string='Code Delimiter', default='.', + help='Delimiter after parent account chart') + + @api.model + def _prepare_transfer_account_template(self): + # 分隔符,用友为"",金蝶为 ".",注意odoo中一级科目,现金默认定义是4位头,银行是6位头 + # 我们使用 用友的多级科目方式,自动生成下级,此处直接覆盖原生 + digits = self.code_digits + prefix = self.transfer_account_code_prefix or '' + # Flatten the hierarchy of chart templates. + chart_template = self + chart_templates = self + while chart_template.parent_id: + chart_templates += chart_template.parent_id + chart_template = chart_template.parent_id + delimiter = chart_template.delimiter + new_code = '' + for num in range(1, 100): + new_code = str(prefix.ljust(digits - 1, '0')) + delimiter + '%02d' % (num) + rec = self.env['account.account.template'].search( + [('code', '=', new_code), ('chart_template_id', 'in', chart_templates.ids)], limit=1) + if not rec: + break + parent = self.env['account.account.template'].search( + [('code', '=', prefix), ('chart_template_id', 'in', chart_templates.ids)], limit=1) + if new_code == '': + raise UserError(_('Cannot generate an unused account code.')) + res = { + 'name': _('Liquidity Transfer'), + 'code': new_code, + 'parent_id': parent.id if parent else False, + 'account_type': 'asset_current', + 'reconcile': True, + 'chart_template_id': self.id, + } + return res + + def _load(self, company): + # 这个是加载预制模板,在此方法中调用 _install_template ,再从中调用 _load_template 来生成会计科目 + res = super(AccountChartTemplate, self)._load(company) + # 先整体load完,再按template中的设置更新父级 + acc_ids = self.env['account.account'].sudo().search([('company_id', '=', company.id)]) + for acc in acc_ids: + code = acc.code + todo_account = self.env['account.account.template'].sudo().search([ + ('code', '=', code), + ('chart_template_id', '=', self.id), + ('parent_id', '!=', False) + ], limit=1) + if len(todo_account) or code == '2221.01.01': + parent_code = todo_account[0].parent_id.code + if parent_code: + parent = self.env['account.account'].sudo().search([ + ('company_id', '=', company.id), + ('code', '=', parent_code), + ], limit=1).exists() + if parent and acc.parent_id != parent: + acc.write({ + 'parent_id': parent.id, + }) + return res + + diff --git a/app_account_ztree/models/res_company.py b/app_account_ztree/models/res_company.py new file mode 100644 index 00000000..5f0b9208 --- /dev/null +++ b/app_account_ztree/models/res_company.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from datetime import timedelta, datetime, date +import calendar + +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError, UserError, RedirectWarning +from odoo.tools.mail import is_html_empty +from odoo.tools.misc import format_date +from odoo.tools.float_utils import float_round, float_is_zero +from odoo.addons.account.models.account_move import MAX_HASH_VERSION + + +class ResCompany(models.Model): + _inherit = ['res.company'] + + coa_delimiter = fields.Char(string='COA Delimiter', related='chart_template_id.delimiter', readonly=False, + help='Delimiter after parent account in Chart of Accounts') diff --git a/app_account_ztree/views/account_account_views.xml b/app_account_ztree/views/account_account_views.xml index 05be2788..933c0c42 100644 --- a/app_account_ztree/views/account_account_views.xml +++ b/app_account_ztree/views/account_account_views.xml @@ -1,14 +1,28 @@ - + + + app.account.account.list.view + account.account + + + + code + + + + + + + app.account.account.form account.account - - ztree_select - + + + diff --git a/app_account_ztree/views/res_company_views.xml b/app_account_ztree/views/res_company_views.xml new file mode 100644 index 00000000..8372257d --- /dev/null +++ b/app_account_ztree/views/res_company_views.xml @@ -0,0 +1,15 @@ + + + + + app.res.company.form + res.company + + + + + + + + + diff --git a/l10n_cn_standard_latest/__manifest__.py b/l10n_cn_standard_latest/__manifest__.py index 0a5592b8..2377ecb5 100644 --- a/l10n_cn_standard_latest/__manifest__.py +++ b/l10n_cn_standard_latest/__manifest__.py @@ -9,7 +9,7 @@ { 'name': '2023最新中国会计科目表.企业标准会计.Latest Chinese Accounting for odoo16', - 'version': '16.24.12.02', + 'version': '16.24.12.12', 'author': 'odooai.cn', 'category': 'Accounting/Localizations/Account Charts', 'website': 'https://www.odooai.cn', @@ -52,13 +52,13 @@ """, 'depends': [ - 'account', + 'app_account_ztree', 'app_odoo_customize', ], 'images': ['static/description/banner.png'], 'data': [ 'views/account_account_views.xml', - 'views/account_views.xml', + 'views/menus_views.xml', 'data/chart_data.xml', 'data/account_account_tag_data.xml', 'data/account.group.csv', diff --git a/l10n_cn_standard_latest/data/chart_data.xml b/l10n_cn_standard_latest/data/chart_data.xml index 90459cfe..4014ef7e 100644 --- a/l10n_cn_standard_latest/data/chart_data.xml +++ b/l10n_cn_standard_latest/data/chart_data.xml @@ -4,6 +4,7 @@ 2023中国企业会计科目表-odoo16 + . 1001 diff --git a/l10n_cn_standard_latest/models/account_account.py b/l10n_cn_standard_latest/models/account_account.py index 37038097..2c54cbd3 100644 --- a/l10n_cn_standard_latest/models/account_account.py +++ b/l10n_cn_standard_latest/models/account_account.py @@ -20,22 +20,4 @@ from odoo.exceptions import UserError, ValidationError class AccountAccount(models.Model): _inherit = ['account.account'] - _parent_name = "parent_id" - _parent_store = True - _parent_order = 'code' - # _rec_name = 'complete_name' - - parent_id = fields.Many2one('account.account', 'Parent Chart', index=True, ondelete='cascade') - child_ids = fields.One2many('account.account', 'parent_id', 'Child Chart') - parent_path = fields.Char(index=True, unaccent=False) - - @api.model - def _search_new_account_code(self, company, digits, prefix): - # 分隔符,金蝶为 ".",用友为"",注意odoo中一级科目,现金默认定义是4位头,银行是6位头 - delimiter = '.' - for num in range(1, 100): - new_code = str(prefix.ljust(digits - 1, '0')) + delimiter + '%02d' % (num) - rec = self.search([('code', '=', new_code), ('company_id', '=', company.id)], limit=1) - if not rec: - return new_code - raise UserError(_('Cannot generate an unused account code.')) + # 相关方法处理移至 app_account_ztree diff --git a/l10n_cn_standard_latest/models/account_account_template.py b/l10n_cn_standard_latest/models/account_account_template.py index 1c5d5a10..d85207c5 100644 --- a/l10n_cn_standard_latest/models/account_account_template.py +++ b/l10n_cn_standard_latest/models/account_account_template.py @@ -20,14 +20,4 @@ from odoo import api, fields, models, exceptions, _ class AccountAccountTemplate(models.Model): _inherit = ['account.account.template'] - _parent_name = "parent_id" - _parent_store = True - _parent_order = 'code' - # _rec_name = 'complete_name' - - # todo: 具体项目中,可以parent_id 处理为 compute, inverse=xxx(直接用pass),与 code_digits, - parent_id = fields.Many2one('account.account.template', 'Parent Chart', index=True, ondelete='cascade') - child_ids = fields.One2many('account.account.template', 'parent_id', 'Child Chart') - parent_path = fields.Char(index=True, unaccent=False) - - + # 相关方法处理移至 app_account_ztree diff --git a/l10n_cn_standard_latest/models/account_chart_template.py b/l10n_cn_standard_latest/models/account_chart_template.py index 0194a8b5..9a9bfe25 100644 --- a/l10n_cn_standard_latest/models/account_chart_template.py +++ b/l10n_cn_standard_latest/models/account_chart_template.py @@ -20,74 +20,4 @@ from odoo.exceptions import UserError class AccountChartTemplate(models.Model): _inherit = "account.chart.template" - - @api.model - def _prepare_transfer_account_template(self): - # 初始化时,使用 _load 方法,不再使用此方法了 - ''' Prepare values to create the transfer account that is an intermediary account used when moving money - from a liquidity account to another. - - :return: A dictionary of values to create a new account.account. - ''' - # 分隔符,金蝶为 ".",用友为"",注意odoo中一级科目,现金默认定义是4位头,银行是6位头 - delimiter = '.' - digits = self.code_digits - prefix = self.transfer_account_code_prefix or '' - # Flatten the hierarchy of chart templates. - chart_template = self - chart_templates = self - while chart_template.parent_id: - chart_templates += chart_template.parent_id - chart_template = chart_template.parent_id - new_code = '' - for num in range(1, 100): - new_code = str(prefix.ljust(digits - 1, '0')) + delimiter + '%02d' % (num) - rec = self.env['account.account.template'].search( - [('code', '=', new_code), ('chart_template_id', 'in', chart_templates.ids)], limit=1) - if not rec: - break - else: - raise UserError(_('Cannot generate an unused account code.')) - return { - 'name': _('Liquidity Transfer'), - 'code': new_code, - 'account_type': 'asset_current', - 'reconcile': True, - 'chart_template_id': self.id, - } - - def _load(self, company): - if self == self.env.ref('l10n_cn_standard_latest.l10n_chart_china_standard_business_latest', False): - # #todo: 当为 标准中国会计的处理 - # company.write({ - # 'account_journal_suspense_account_id': self.account_journal_suspense_account_id.id if self.account_journal_suspense_account_id else False, - # 'account_journal_payment_credit_account_id': self.account_journal_payment_credit_account_id.id if self.account_journal_payment_credit_account_id else False, - # 'account_journal_payment_debit_account_id': self.account_journal_payment_debit_account_id.id if self.account_journal_payment_debit_account_id else False, - # }) - pass - res = super(AccountChartTemplate, self)._load(company) - # todo: 更新已有res.partner 的字段(当原值为空时) 应收账款 = chart.property_account_receivable_id,应付账款=property_account_payable_id - # 更新父级 - company = self.env.user.company_id - acc_ids = self.env['account.account'].sudo().search([('company_id', '=', company.id)]) - for acc in acc_ids: - code = acc.code - todo_account = self.env['account.account.template'].sudo().search([ - ('code', '=', code), - ('chart_template_id', '=', self.id), - ('parent_id', '!=', False) - ], limit=1) - if len(todo_account) or code == '2221.01.01': - parent_code = todo_account[0].parent_id.code - if parent_code: - parent = self.env['account.account'].sudo().search([ - ('company_id', '=', company.id), - ('code', '=', parent_code), - ], limit=1).exists() - if parent: - acc.write({ - 'parent_id': parent.id, - }) - return res - - + # 相关方法处理移至 app_account_ztree diff --git a/l10n_cn_standard_latest/models/account_journal.py b/l10n_cn_standard_latest/models/account_journal.py index 0526f5ee..603b37e1 100644 --- a/l10n_cn_standard_latest/models/account_journal.py +++ b/l10n_cn_standard_latest/models/account_journal.py @@ -9,10 +9,6 @@ class AccountJournal(models.Model): @api.model def _prepare_liquidity_account(self, name, company, currency_id, type): - digits = 6 - chart = self.company_id.chart_template_id - if chart: - digits = int(chart.code_digits) # Seek the next available number for the account code if type == 'bank': account_code_prefix = company.bank_account_code_prefix or '' diff --git a/l10n_cn_standard_latest/static/description/index.html b/l10n_cn_standard_latest/static/description/index.html index 9c109f36..d2bcfd5b 100644 --- a/l10n_cn_standard_latest/static/description/index.html +++ b/l10n_cn_standard_latest/static/description/index.html @@ -44,9 +44,21 @@ -

Use super, easy to navigate account data.

+

使用收费模块 app_web_widget_widget + app_account_ztree 组件可方便的使用 zChart zTree来管理多层级会计科目

+
+

Use our Hierarchy Chart Of COA. Easy manage the Charts of Account with multi level.

+
+
  • + + + app_account_zchart with zTree widget (must need to pay and use in following demo). + +
  • - + +
    +
    +

    How to use

    diff --git a/l10n_cn_standard_latest/views/account_account_views.xml b/l10n_cn_standard_latest/views/account_account_views.xml index 1ad3caa8..829e7141 100644 --- a/l10n_cn_standard_latest/views/account_account_views.xml +++ b/l10n_cn_standard_latest/views/account_account_views.xml @@ -1,20 +1,8 @@ + - - app.account.list - account.account - - - - code - - - - - - app.account.setup.opening.move.line.tree account.account @@ -25,16 +13,7 @@ - - app.account.account.form - account.account - - - - - - - + app.account.account.search account.account diff --git a/l10n_cn_standard_latest/views/account_views.xml b/l10n_cn_standard_latest/views/account_views.xml deleted file mode 100644 index 3825c261..00000000 --- a/l10n_cn_standard_latest/views/account_views.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/l10n_cn_standard_latest/views/menus_views.xml b/l10n_cn_standard_latest/views/menus_views.xml new file mode 100644 index 00000000..0cee6b8a --- /dev/null +++ b/l10n_cn_standard_latest/views/menus_views.xml @@ -0,0 +1,8 @@ + + + + + Finance + + +