mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
优化会计科目表相关
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': "App Account Multi Level Chart, parent children tree",
|
'name': "App Account Multi Level Chart, parent children tree",
|
||||||
'version': '16.23.03.01',
|
'version': '16.24.12.12',
|
||||||
'author': 'odooai.cn',
|
'author': 'odooai.cn',
|
||||||
'category': 'Extra tools',
|
'category': 'Extra tools',
|
||||||
'website': 'https://www.odooai.cn',
|
'website': 'https://www.odooai.cn',
|
||||||
@@ -38,11 +38,11 @@
|
|||||||
'currency': 'EUR',
|
'currency': 'EUR',
|
||||||
'depends': [
|
'depends': [
|
||||||
'account',
|
'account',
|
||||||
'l10n_cn_standard_latest',
|
|
||||||
],
|
],
|
||||||
'images': ['static/description/banner.png'],
|
'images': ['static/description/banner.png'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/account_account_views.xml',
|
'views/account_account_views.xml',
|
||||||
|
'views/res_company_views.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,14 +1,95 @@
|
|||||||
# Translation of Odoo Server.
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * app_account_ztree
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 10.0\n"
|
"Project-Id-Version: Odoo Server 16.0+e-20231112\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2018-01-08 14:28+0000\n"
|
"POT-Creation-Date: 2024-12-12 14:09+0000\n"
|
||||||
"PO-Revision-Date: 2018-01-08 14:28+0000\n"
|
"PO-Revision-Date: 2024-12-12 14:09+0000\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Plural-Forms: \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.<br/>【%s】 records updated."
|
||||||
|
msgstr "更新会计科目表上下级关系完成。<br/>【%s】 条记录更新完成。"
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import account_chart_template
|
||||||
|
from . import account_account_template
|
||||||
|
from . import account_account
|
||||||
|
from . import res_company
|
||||||
|
|
||||||
|
|||||||
58
app_account_ztree/models/account_account.py
Normal file
58
app_account_ztree/models/account_account.py
Normal file
@@ -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.<br/>【%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',
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app_account_ztree/models/account_account_template.py
Normal file
33
app_account_ztree/models/account_account_template.py
Normal file
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
101
app_account_ztree/models/account_chart_template.py
Normal file
101
app_account_ztree/models/account_chart_template.py
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
18
app_account_ztree/models/res_company.py
Normal file
18
app_account_ztree/models/res_company.py
Normal file
@@ -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')
|
||||||
@@ -1,14 +1,28 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<!-- hr -->
|
<!-- list -->
|
||||||
|
<record id="app_view_account_list" model="ir.ui.view">
|
||||||
|
<field name="name">app.account.account.list.view</field>
|
||||||
|
<field name="model">account.account</field>
|
||||||
|
<field name="inherit_id" ref="account.view_account_list"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//tree" position="attributes">
|
||||||
|
<attribute name="default_order">code</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="field[@name='account_type']" position="after">
|
||||||
|
<field name="parent_id" optional="show"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="app_view_account_form" model="ir.ui.view">
|
<record id="app_view_account_form" model="ir.ui.view">
|
||||||
<field name="name">app.account.account.form</field>
|
<field name="name">app.account.account.form</field>
|
||||||
<field name="model">account.account</field>
|
<field name="model">account.account</field>
|
||||||
<field name="inherit_id" ref="account.view_account_form"/>
|
<field name="inherit_id" ref="account.view_account_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//field[@name='parent_id']" position="attributes">
|
<xpath expr="//field[@name='account_type']" position="after">
|
||||||
<attribute name="widget">ztree_select</attribute>
|
<field name="parent_id" widget="ztree_select"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
15
app_account_ztree/views/res_company_views.xml
Normal file
15
app_account_ztree/views/res_company_views.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="app_view_company_form" model="ir.ui.view">
|
||||||
|
<field name="name">app.res.company.form</field>
|
||||||
|
<field name="model">res.company</field>
|
||||||
|
<field name="inherit_id" ref="base.view_company_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//field[@name='currency_id']" position="after">
|
||||||
|
<field name="coa_delimiter"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': '2023最新中国会计科目表.企业标准会计.Latest Chinese Accounting for odoo16',
|
'name': '2023最新中国会计科目表.企业标准会计.Latest Chinese Accounting for odoo16',
|
||||||
'version': '16.24.12.02',
|
'version': '16.24.12.12',
|
||||||
'author': 'odooai.cn',
|
'author': 'odooai.cn',
|
||||||
'category': 'Accounting/Localizations/Account Charts',
|
'category': 'Accounting/Localizations/Account Charts',
|
||||||
'website': 'https://www.odooai.cn',
|
'website': 'https://www.odooai.cn',
|
||||||
@@ -52,13 +52,13 @@
|
|||||||
|
|
||||||
""",
|
""",
|
||||||
'depends': [
|
'depends': [
|
||||||
'account',
|
'app_account_ztree',
|
||||||
'app_odoo_customize',
|
'app_odoo_customize',
|
||||||
],
|
],
|
||||||
'images': ['static/description/banner.png'],
|
'images': ['static/description/banner.png'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/account_account_views.xml',
|
'views/account_account_views.xml',
|
||||||
'views/account_views.xml',
|
'views/menus_views.xml',
|
||||||
'data/chart_data.xml',
|
'data/chart_data.xml',
|
||||||
'data/account_account_tag_data.xml',
|
'data/account_account_tag_data.xml',
|
||||||
'data/account.group.csv',
|
'data/account.group.csv',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<record id="l10n_chart_china_standard_business_latest" model="account.chart.template">
|
<record id="l10n_chart_china_standard_business_latest" model="account.chart.template">
|
||||||
<field name="name">2023中国企业会计科目表-odoo16</field>
|
<field name="name">2023中国企业会计科目表-odoo16</field>
|
||||||
<field name="code_digits" eval="4"/>
|
<field name="code_digits" eval="4"/>
|
||||||
|
<field name="delimiter">.</field>
|
||||||
<field name="currency_id" ref="base.CNY"/>
|
<field name="currency_id" ref="base.CNY"/>
|
||||||
<field name="country_id" ref="base.cn"/>
|
<field name="country_id" ref="base.cn"/>
|
||||||
<field name="cash_account_code_prefix">1001</field>
|
<field name="cash_account_code_prefix">1001</field>
|
||||||
|
|||||||
@@ -20,22 +20,4 @@ from odoo.exceptions import UserError, ValidationError
|
|||||||
|
|
||||||
class AccountAccount(models.Model):
|
class AccountAccount(models.Model):
|
||||||
_inherit = ['account.account']
|
_inherit = ['account.account']
|
||||||
_parent_name = "parent_id"
|
# 相关方法处理移至 app_account_ztree
|
||||||
_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.'))
|
|
||||||
|
|||||||
@@ -20,14 +20,4 @@ from odoo import api, fields, models, exceptions, _
|
|||||||
class AccountAccountTemplate(models.Model):
|
class AccountAccountTemplate(models.Model):
|
||||||
|
|
||||||
_inherit = ['account.account.template']
|
_inherit = ['account.account.template']
|
||||||
_parent_name = "parent_id"
|
# 相关方法处理移至 app_account_ztree
|
||||||
_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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,74 +20,4 @@ from odoo.exceptions import UserError
|
|||||||
|
|
||||||
class AccountChartTemplate(models.Model):
|
class AccountChartTemplate(models.Model):
|
||||||
_inherit = "account.chart.template"
|
_inherit = "account.chart.template"
|
||||||
|
# 相关方法处理移至 app_account_ztree
|
||||||
@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
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ class AccountJournal(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _prepare_liquidity_account(self, name, company, currency_id, type):
|
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
|
# Seek the next available number for the account code
|
||||||
if type == 'bank':
|
if type == 'bank':
|
||||||
account_code_prefix = company.bank_account_code_prefix or ''
|
account_code_prefix = company.bank_account_code_prefix or ''
|
||||||
|
|||||||
@@ -44,9 +44,21 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="oe_slogan">Use super, easy to navigate account data.</h3>
|
<h3 class="oe_slogan">使用收费模块 app_web_widget_widget + app_account_ztree 组件可方便的使用 zChart zTree来管理多层级会计科目</h3>
|
||||||
|
<div class="oe_row text-center">
|
||||||
|
<h2>Use our Hierarchy Chart Of COA. Easy manage the Charts of Account with multi level.</h2>
|
||||||
|
</div>
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-link text-primary"></i>
|
||||||
|
<a href="./app_account_zchart" target="_blank" class="text-danger">
|
||||||
|
app_account_zchart with zTree widget (must need to pay and use in following demo).
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<img class="oe_demo oe_screenshot img img-fluid" src="superbar1.png">
|
<img class="oe_demo oe_screenshot img img-fluid" src="demo_account_zchart.jpg">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<img class="oe_demo oe_screenshot img img-fluid" src="demo_account_tree.jpg">
|
||||||
</div>
|
</div>
|
||||||
<h3 class="oe_slogan">How to use</h3>
|
<h3 class="oe_slogan">How to use</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -1,20 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
<!-- 注意,此处不再显示 parent_id 的处理, 调整至 app_account_ztree -->
|
||||||
<!-- account.account -->
|
<!-- account.account -->
|
||||||
<record id="app_view_account_list" model="ir.ui.view">
|
|
||||||
<field name="name">app.account.list</field>
|
|
||||||
<field name="model">account.account</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_list"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//tree" position="attributes">
|
|
||||||
<attribute name="default_order">code</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='account_type']" position="after">
|
|
||||||
<field name="parent_id" optional="show"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
<record id="init_accounts_tree" model="ir.ui.view">
|
<record id="init_accounts_tree" model="ir.ui.view">
|
||||||
<field name="name">app.account.setup.opening.move.line.tree</field>
|
<field name="name">app.account.setup.opening.move.line.tree</field>
|
||||||
<field name="model">account.account</field>
|
<field name="model">account.account</field>
|
||||||
@@ -25,16 +13,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="app_view_account_form" model="ir.ui.view">
|
|
||||||
<field name="name">app.account.account.form</field>
|
|
||||||
<field name="model">account.account</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='account_type']" position="after">
|
|
||||||
<field name="parent_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
<record id="app_view_account_search" model="ir.ui.view">
|
<record id="app_view_account_search" model="ir.ui.view">
|
||||||
<field name="name">app.account.account.search</field>
|
<field name="name">app.account.account.search</field>
|
||||||
<field name="model">account.account</field>
|
<field name="model">account.account</field>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- Top menu item -->
|
|
||||||
<menuitem name="Finance"
|
|
||||||
id="account.menu_finance"/>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
8
l10n_cn_standard_latest/views/menus_views.xml
Normal file
8
l10n_cn_standard_latest/views/menus_views.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="account.menu_finance" model="ir.ui.menu">
|
||||||
|
<field name="name">Finance</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user