fix china account level,上下级结构处理

This commit is contained in:
ivan deng
2023-03-01 23:39:49 +08:00
parent 811646c30d
commit 4aa36c65e0
35 changed files with 351 additions and 40 deletions

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
from .hooks import post_init_hook

View File

@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
# Created on 2018-08-15
# author: 广州尚鹏https://www.sunpop.cn
# email: 300883@qq.com
# resource of Sunpop
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Odoo在线中文用户手册长期更新
# https://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# https://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# https://www.sunpop.cn/odoo10_developer_document_offline/
# description:
{
'name': "App Account Multi Level Chart, parent children tree",
'version': '16.23.03.01',
'author': 'Sunpop.cn',
'category': 'Base',
'website': 'https://www.sunpop.cn',
'license': 'LGPL-3',
'sequence': 2,
'summary': """
Use for parent children tree list select navigator. Multi Level Account Chart tree.
ztree widget.
""",
'description': """
zTree widget.
Advance search with real parent children tree, ListView or KanbanView ,
eg: Account Chart tree, Product category tree,Department tree, stock location tree.
超级方便的查询,树状视图。
""",
'price': 0.00,
'currency': 'EUR',
'depends': [
'account',
'l10n_cn_standard_latest',
],
'images': ['static/description/banner.gif'],
'data': [
'views/account_account_views.xml',
],
'demo': [
],
'test': [
],
'css': [
],
'qweb': [
'static/src/xml/*.xml',
],
'js': [
],
'post_load': None,
'post_init_hook': 'post_init_hook',
'installable': True,
'application': True,
'auto_install': False,
}

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Created on 2018-10-12
# author: 广州尚鹏https://www.sunpop.cn
# email: 300883@qq.com
# resource of Sunpop
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
# Odoo在线中文用户手册长期更新
# https://www.sunpop.cn/documentation/user/10.0/zh_CN/index.html
# Odoo10离线中文用户手册下载
# https://www.sunpop.cn/odoo10_user_manual_document_offline/
# Odoo10离线开发手册下载-含python教程jquery参考Jinja2模板PostgresSQL参考odoo开发必备
# https://www.sunpop.cn/odoo10_developer_document_offline/
# description:
def post_init_hook(cr, pool):
pass
# cr.execute("")

View File

@@ -0,0 +1,14 @@
# Translation of Odoo Server.
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\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"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View File

@@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,181 @@
<section class="oe_container">
<div class="oe_row oe_spaced" style="max-width: 95%;">
<h2 class="oe_slogan" style="color:#875A7B;">App ztree widget, for parent children tree list. Demo for hr department employee</h2>
<h3 class="oe_slogan">Very useful for parent child relationship, like product category, stock location, hr department</h3>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
<i class="fa fa-hand-o-right"></i><b> Key features: </b>
<ul class="list-unstyled">
<li>
<i class="fa fa-check-square-o text-primary"></i>
Easy to make custom parent children tree.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Free to Use in product category.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Free to Use in stock location.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
Free to Use in hr department, employee.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
It's a widget, you can use it in anywhere in odoo.
</li>
</ul>
</div>
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
<i class="fa fa-hand-o-right"></i>
<b>
<a href="http://www.odoo.com/apps/modules/16.0/app_web_superbar/" target="_blank" class="text-danger">
Extend features. superbar advance search navigator
</a>
</b>
<ul class="list-unstyled">
<li>
<i class="fa fa-check-square-o text-primary"></i>
Easy to navigate product, employee in tree or kanban view.
</li>
</ul>
</div>
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
<i class="fa fa-hand-o-right"></i><b>Get relate Module </b>
<ul class="list-unstyled">
<li>
<i class="fa fa-link text-primary"></i>
<a href="http://www.odoo.com/apps/modules/16.0/app_web_widget_ztree/" target="_blank" class="text-danger">zTree widget (must need to use in following demo).</a>
</li>
<li>
<i class="fa fa-link text-primary"></i>
<a href="http://www.odoo.com/apps/modules/16.0/app_product_ztree/" target="_blank">Product and category.</a>
</li>
<li>
<i class="fa fa-link text-primary"></i>
<a href="http://www.odoo.com/apps/modules/16.0/app_stock_ztree/" target="_blank">Stock and Location.</a>
</li>
<li>
<i class="fa fa-link text-primary"></i>
<a href="http://www.odoo.com/apps/modules/16.0/app_hr_ztree/" target="_blank">hr department and employee.</a>
</li>
</ul>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in hr department.</h4>
<div class="oe_demo oe_screenshot">
<img src="demo4.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in hr employee.</h4>
<div class="oe_demo oe_screenshot">
<img src="demo5.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Use in product.</h4>
<div class="oe_demo oe_screenshot">
<img src="demo2.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Free to Use in product category.</h4>
<div class="oe_demo oe_screenshot">
<img src="demo1.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Free to Use in stock location.</h4>
<div class="oe_demo oe_screenshot">
<img src="demo3.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h1>&nbsp;</h1>
<h1 class="text-danger text-center">(!Need extra module and pay, release soon)Easy to navigator.</h1>
<h4 class="oe_slogan">Product, employee in kanban view</h4>
<div class="oe_demo oe_screenshot">
<img src="demo11.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">(!Need extra module and pay, release soon)List view</h4>
<div class="oe_demo oe_screenshot">
<img src="demo12.jpg">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h4 class="oe_slogan">Easy to setup just use widget='widget_select'. like this</h4>
<div class="oe_demo oe_screenshot">
<img src="setup1.jpg">
</div>
<h1><br/> Use follow param to setup widget:<br/></h1>
<h4>ztree_parent_key: --the key field of parent children relation.</h4>
<h4>ztree_expend_level: --how many level to expend the tree for initialize. Default is 2</h4>
<h4>limit: --how many record to show ztree. Default is 16</h4>
<h4>order: --the field to order by</h4>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced text-center">
<div class="oe_span12">
<h2 class="oe_slogan">Technical Help & Support</h2>
</div>
<div class="col-md-12 pad0">
<div class="oe_mt16">
<p><h4>
For any type of technical help & support requests, Feel free to contact us</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:guohuadeng@hotmail.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> guohuadeng@hotmail.com</a>
<p><h4>
Via QQ: 300883 (App user would not get QQ or any other IM support. Only for odoo project customize.)</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:300883@qq.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> 300883@qq.com</a>
</div>
<div class="oe_mt16">
<h4>
Visit our website for more support.</h4>
<h4>https://www.sunpop.cn</h4>
</div>
</div>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,15 @@
<odoo>
<data>
<!-- hr -->
<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='parent_id']" position="attributes">
<attribute name="widget">ztree_select</attribute>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -40,11 +40,11 @@
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'data/mail_channel_data.xml', 'data/mail_channel_data.xml',
'data/gpt_robot_data.xml', 'data/ai_robot_data.xml',
'data/user_partner_data.xml', 'data/user_partner_data.xml',
'data/ir_config_parameter.xml', 'data/ir_config_parameter.xml',
'views/res_config_settings_views.xml', 'views/res_config_settings_views.xml',
'views/gpt_robot_views.xml', 'views/ai_robot_views.xml',
'views/res_users_views.xml', 'views/res_users_views.xml',
], ],
'assets': { 'assets': {

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<record id="chatgpt_robot" model="gpt.robot"> <record id="chatai_robot" model="ai.robot">
<field name="name">ChatGPT odoo</field> <field name="name">ChatGPT odoo</field>
<field name="sequence">1</field> <field name="sequence">1</field>
</record> </record>
<record id="chatgpt_robot1" model="gpt.robot"> <record id="chatai_robot1" model="ai.robot">
<field name="name">ChatGPT Coding</field> <field name="name">ChatGPT Coding</field>
<field name="sequence">6</field> <field name="sequence">6</field>
</record> </record>
<record id="chatgpt_robot2" model="gpt.robot"> <record id="chatai_robot2" model="ai.robot">
<field name="name">ChatGPT Finance</field> <field name="name">ChatGPT Finance</field>
<field name="sequence">7</field> <field name="sequence">7</field>
</record> </record>

View File

@@ -9,7 +9,7 @@
<field name="login">chatgpt@sunpop.cn</field> <field name="login">chatgpt@sunpop.cn</field>
<field name="password">chatgpt</field> <field name="password">chatgpt</field>
<field name="partner_id" ref="app_chatgpt.partner_chatgpt"/> <field name="partner_id" ref="app_chatgpt.partner_chatgpt"/>
<field name="gpt_id" ref="app_chatgpt.chatgpt_robot"/> <field name="gpt_id" ref="app_chatgpt.chatai_robot"/>
<field name="company_id" ref="base.main_company"/> <field name="company_id" ref="base.main_company"/>
<field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/> <field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/>
<field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/> <field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/>
@@ -25,7 +25,7 @@
<field name="email">chatgpt1@sunpop.cn</field> <field name="email">chatgpt1@sunpop.cn</field>
<field name="password">chatgpt</field> <field name="password">chatgpt</field>
<field name="partner_id" ref="app_chatgpt.partner_chatgpt1"/> <field name="partner_id" ref="app_chatgpt.partner_chatgpt1"/>
<field name="gpt_id" ref="app_chatgpt.chatgpt_robot1"/> <field name="gpt_id" ref="app_chatgpt.chatai_robot1"/>
<field name="company_id" ref="base.main_company"/> <field name="company_id" ref="base.main_company"/>
<field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/> <field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/>
<field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/> <field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/>
@@ -41,7 +41,7 @@
<field name="email">chatgpt2@sunpop.cn</field> <field name="email">chatgpt2@sunpop.cn</field>
<field name="password">chatgpt</field> <field name="password">chatgpt</field>
<field name="partner_id" ref="app_chatgpt.partner_chatgpt2"/> <field name="partner_id" ref="app_chatgpt.partner_chatgpt2"/>
<field name="gpt_id" ref="app_chatgpt.chatgpt_robot2"/> <field name="gpt_id" ref="app_chatgpt.chatai_robot2"/>
<field name="company_id" ref="base.main_company"/> <field name="company_id" ref="base.main_company"/>
<field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/> <field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/>
<field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/> <field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/>

View File

@@ -3,6 +3,6 @@
from . import mail_channel from . import mail_channel
from . import res_config_settings from . import res_config_settings
from . import gpt_robot from . import ai_robot
from . import res_users from . import res_users
from . import mail_message from . import mail_message

View File

@@ -4,8 +4,8 @@ import requests
from odoo import api, fields, models, _ from odoo import api, fields, models, _
class GptRobot(models.Model): class AiRobot(models.Model):
_name = 'gpt.robot' _name = 'ai.robot'
_description = 'Gpt Robot' _description = 'Gpt Robot'
_order = 'sequence, name' _order = 'sequence, name'

View File

@@ -85,7 +85,7 @@ class Channel(models.Model):
to_partner_id = self.env['res.partner'] to_partner_id = self.env['res.partner']
user_id = self.env['res.users'] user_id = self.env['res.users']
author_id = msg_vals.get('author_id') author_id = msg_vals.get('author_id')
gpt_id = self.env['gpt.robot'] gpt_id = self.env['ai.robot']
channel_type = self.channel_type channel_type = self.channel_type
if channel_type == 'chat': if channel_type == 'chat':
channel_partner_ids = self.channel_partner_ids channel_partner_ids = self.channel_partner_ids

View File

@@ -6,7 +6,7 @@ from odoo import fields, models
class ResUsers(models.Model): class ResUsers(models.Model):
_inherit = "res.users" _inherit = "res.users"
gpt_id = fields.Many2one('gpt.robot', string='Bind to ChatGpt') gpt_id = fields.Many2one('ai.robot', string='Bind to ChatGpt')
gpt_policy = fields.Selection([ gpt_policy = fields.Selection([
('all', 'All Users'), ('all', 'All Users'),
('limit', 'Selected Users') ('limit', 'Selected Users')

View File

@@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_gpt_robt_user,GptRobotUser,model_gpt_robot,base.group_user,1,1,1,1 access_gpt_robt_user,AiRobotUser,model_ai_robot,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_gpt_robt_user GptRobotUser AiRobotUser model_gpt_robot model_ai_robot base.group_user 1 1 1 1

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<record id="gpt_robot_tree_view" model="ir.ui.view"> <record id="ai_robot_tree_view" model="ir.ui.view">
<field name="name">gpt.robot.tree</field> <field name="name">ai.robot.tree</field>
<field name="model">gpt.robot</field> <field name="model">ai.robot</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree> <tree>
<field name="sequence" widget="handle"/> <field name="sequence" widget="handle"/>
@@ -13,9 +13,9 @@
</field> </field>
</record> </record>
<record id="gpt_robot_form_view" model="ir.ui.view"> <record id="ai_robot_form_view" model="ir.ui.view">
<field name="name">gpt.robot.form</field> <field name="name">ai.robot.form</field>
<field name="model">gpt.robot</field> <field name="model">ai.robot</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form>
<sheet> <sheet>
@@ -32,9 +32,9 @@
</field> </field>
</record> </record>
<record id="action_gpt_robot" model="ir.actions.act_window"> <record id="action_ai_robot" model="ir.actions.act_window">
<field name="name">GPT Robot</field> <field name="name">GPT Robot</field>
<field name="res_model">gpt.robot</field> <field name="res_model">ai.robot</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="help" type="html"> <field name="help" type="html">
<p class="o_view_nocontent_smiling_face"> <p class="o_view_nocontent_smiling_face">
@@ -43,21 +43,21 @@
</field> </field>
</record> </record>
<record id="model_gpt_robot_action_disconnect" model="ir.actions.server"> <record id="model_ai_robot_action_disconnect" model="ir.actions.server">
<field name="name">Disconnect</field> <field name="name">Disconnect</field>
<field name="model_id" ref="app_chatgpt.model_gpt_robot"/> <field name="model_id" ref="app_chatgpt.model_ai_robot"/>
<field name="binding_model_id" ref="app_chatgpt.model_gpt_robot"/> <field name="binding_model_id" ref="app_chatgpt.model_ai_robot"/>
<field name="binding_view_types">list,form</field> <field name="binding_view_types">list,form</field>
<field name="state">code</field> <field name="state">code</field>
<field name="code">action = records.action_disconnect()</field> <field name="code">action = records.action_disconnect()</field>
</record> </record>
<menuitem <menuitem
id="menu_gpt_robot" id="menu_ai_robot"
name="GPT Robot" name="GPT Robot"
parent="base.menu_users" parent="base.menu_users"
sequence="2" sequence="2"
action="action_gpt_robot" action="action_ai_robot"
groups="base.group_system"/> groups="base.group_system"/>
</odoo> </odoo>

View File

@@ -285,6 +285,15 @@ class ResConfigSettings(models.TransientModel):
company_id = self.env.company.id company_id = self.env.company.id
self = self.with_company(self.env.company) self = self.with_company(self.env.company)
to_removes = [ to_removes = [
# 清除财务科目,用于重设
'res.partner.bank',
# 'account.invoice',
'account.payment',
'account.bank.statement',
# 'account.tax.account.tag',
'account.tax',
# 'wizard_multi_charts_accounts',
# 'account.account',
] ]
# todo: 要做 remove_hr因为工资表会用到 account # todo: 要做 remove_hr因为工资表会用到 account
# 更新account关联很多是多公司字段故只存在 ir_property故在原模型只能用update # 更新account关联很多是多公司字段故只存在 ir_property故在原模型只能用update
@@ -354,8 +363,10 @@ class ResConfigSettings(models.TransientModel):
pass # raise Warning(e) pass # raise Warning(e)
seqs = [] seqs = []
self.env.company.write({
'chart_template_id': False,
})
res = self.remove_app_data(to_removes, seqs) res = self.remove_app_data(to_removes, seqs)
self.env.company.write({'chart_template_id': False})
return res return res
def remove_project(self): def remove_project(self):

View File

@@ -9,7 +9,7 @@
{ {
'name': '2023最新中国企业会计表.Latest Chinese Accounting for odoo16', 'name': '2023最新中国企业会计表.Latest Chinese Accounting for odoo16',
'version': '16.23.02.14', 'version': '16.23.03.01',
'author': 'Sunpop.cn', 'author': 'Sunpop.cn',
'category': 'Accounting/Localizations/Account Charts', 'category': 'Accounting/Localizations/Account Charts',
'website': 'https://www.sunpop.cn', 'website': 'https://www.sunpop.cn',

View File

@@ -11,8 +11,8 @@
<field name="default_pos_receivable_account_id" ref="account_1124"/> <field name="default_pos_receivable_account_id" ref="account_1124"/>
</record> </record>
<function model="account.chart.template" name="try_loading"> <!-- <function model="account.chart.template" name="try_loading">-->
<value eval="[ref('l10n_cn_standard_latest.l10n_chart_china_standard_business_latest')]"/> <!-- <value eval="[ref('l10n_cn_standard_latest.l10n_chart_china_standard_business_latest')]"/>-->
</function> <!-- </function>-->
</data> </data>
</odoo> </odoo>

View File

@@ -4,7 +4,7 @@
<data noupdate="1"> <data noupdate="1">
<!-- Chart template --> <!-- Chart template -->
<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">2022中国企业会计科目表-odoo16</field> <field name="name">2023中国企业会计科目表-odoo16</field>
<field name="code_digits" eval="4" /> <field name="code_digits" eval="4" />
<field name="currency_id" ref="base.CNY" /> <field name="currency_id" ref="base.CNY" />
<field name="cash_account_code_prefix">1001</field> <field name="cash_account_code_prefix">1001</field>

View File

@@ -23,6 +23,7 @@ class AccountChartTemplate(models.Model):
@api.model @api.model
def _prepare_transfer_account_template(self): def _prepare_transfer_account_template(self):
# 初始化时,使用 _load 方法,不再使用此方法了
''' Prepare values to create the transfer account that is an intermediary account used when moving money ''' Prepare values to create the transfer account that is an intermediary account used when moving money
from a liquidity account to another. from a liquidity account to another.
@@ -55,27 +56,27 @@ class AccountChartTemplate(models.Model):
'chart_template_id': self.id, 'chart_template_id': self.id,
} }
def load_for_current_company(self, sale_tax_rate, purchase_tax_rate): def _load(self, company):
res = super(AccountChartTemplate, self).load_for_current_company(sale_tax_rate, purchase_tax_rate) res = super(AccountChartTemplate, self)._load(company)
# 更新父级 # 更新父级
company = self.env.user.company_id company = self.env.user.company_id
acc_ids = self.env['account.account'].sudo().search([('company_id', '=', company.id)]) acc_ids = self.env['account.account'].sudo().search([('company_id', '=', company.id)])
for acc in acc_ids: for acc in acc_ids:
code = acc.code code = acc.code
parent_account = self.env['account.account.template'].sudo().search([ todo_account = self.env['account.account.template'].sudo().search([
('code', '=', code), ('code', '=', code),
('chart_template_id', '=', self.id), ('chart_template_id', '=', self.id),
('parent_id', '!=', False) ('parent_id', '!=', False)
], limit=1) ], limit=1)
if len(parent_account) or code == '2221.01.01': if len(todo_account) or code == '2221.01.01':
parent_code = parent_account[0].parent_id.code parent_code = todo_account[0].parent_id.code
if parent_code: if parent_code:
parent = self.env['account.account'].sudo().search([ parent = self.env['account.account'].sudo().search([
('company_id', '=', company.id), ('company_id', '=', company.id),
('code', '=', parent_code), ('code', '=', parent_code),
], limit=1) ], limit=1)
if len(parent): if len(parent):
acc.update({ acc.write({
'parent_id': parent.id, 'parent_id': parent.id,
}) })
return res return res

View File

@@ -32,7 +32,7 @@
<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='name']" position="after"> <xpath expr="//field[@name='account_type']" position="after">
<field name="parent_id"/> <field name="parent_id"/>
</xpath> </xpath>
</field> </field>