diff --git a/app_account_chinese_ztree/static/description/banner.gif b/app_account_chinese_ztree/static/description/banner.gif deleted file mode 100644 index ac3c0327..00000000 Binary files a/app_account_chinese_ztree/static/description/banner.gif and /dev/null differ diff --git a/app_account_chinese_ztree/views/account_views.xml b/app_account_chinese_ztree/views/account_views.xml deleted file mode 100644 index cdeffb7f..00000000 --- a/app_account_chinese_ztree/views/account_views.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - app.account.account.form - account.account - - - - - ztree_select - parent_id - - - - - \ No newline at end of file diff --git a/app_account_chinese_ztree/__init__.py b/app_account_ztree/__init__.py similarity index 100% rename from app_account_chinese_ztree/__init__.py rename to app_account_ztree/__init__.py diff --git a/app_account_chinese_ztree/__manifest__.py b/app_account_ztree/__manifest__.py similarity index 94% rename from app_account_chinese_ztree/__manifest__.py rename to app_account_ztree/__manifest__.py index c90e745c..5dd50475 100644 --- a/app_account_chinese_ztree/__manifest__.py +++ b/app_account_ztree/__manifest__.py @@ -16,7 +16,7 @@ # description: { - 'name': "App Multi Level Account Chart, parent children tree", + 'name': "App Account Multi Level Chart, parent children tree", 'version': '12.0.12.14', 'author': 'Sunpop.cn', 'category': 'Base', @@ -37,7 +37,6 @@ 'currency': 'EUR', 'depends': [ 'account', - 'l10n_cn_standard_lastest', ], 'images': ['static/description/banner.gif'], 'data': [ diff --git a/app_account_chinese_ztree/hooks.py b/app_account_ztree/hooks.py similarity index 100% rename from app_account_chinese_ztree/hooks.py rename to app_account_ztree/hooks.py diff --git a/app_account_chinese_ztree/i18n/zh_CN.po b/app_account_ztree/i18n/zh_CN.po similarity index 100% rename from app_account_chinese_ztree/i18n/zh_CN.po rename to app_account_ztree/i18n/zh_CN.po diff --git a/app_account_chinese_ztree/models/__init__.py b/app_account_ztree/models/__init__.py similarity index 100% rename from app_account_chinese_ztree/models/__init__.py rename to app_account_ztree/models/__init__.py diff --git a/app_account_chinese_ztree/report/__init__.py b/app_account_ztree/report/__init__.py similarity index 100% rename from app_account_chinese_ztree/report/__init__.py rename to app_account_ztree/report/__init__.py diff --git a/app_account_ztree/static/description/banner.gif b/app_account_ztree/static/description/banner.gif new file mode 100644 index 00000000..e69de29b diff --git a/app_account_chinese_ztree/static/description/demo1.jpg b/app_account_ztree/static/description/demo1.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo1.jpg rename to app_account_ztree/static/description/demo1.jpg diff --git a/app_account_chinese_ztree/static/description/demo11.jpg b/app_account_ztree/static/description/demo11.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo11.jpg rename to app_account_ztree/static/description/demo11.jpg diff --git a/app_account_chinese_ztree/static/description/demo12.jpg b/app_account_ztree/static/description/demo12.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo12.jpg rename to app_account_ztree/static/description/demo12.jpg diff --git a/app_account_chinese_ztree/static/description/demo2.jpg b/app_account_ztree/static/description/demo2.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo2.jpg rename to app_account_ztree/static/description/demo2.jpg diff --git a/app_account_chinese_ztree/static/description/demo3.jpg b/app_account_ztree/static/description/demo3.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo3.jpg rename to app_account_ztree/static/description/demo3.jpg diff --git a/app_account_chinese_ztree/static/description/demo4.jpg b/app_account_ztree/static/description/demo4.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo4.jpg rename to app_account_ztree/static/description/demo4.jpg diff --git a/app_account_chinese_ztree/static/description/demo5.jpg b/app_account_ztree/static/description/demo5.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/demo5.jpg rename to app_account_ztree/static/description/demo5.jpg diff --git a/app_account_chinese_ztree/static/description/icon.png b/app_account_ztree/static/description/icon.png similarity index 100% rename from app_account_chinese_ztree/static/description/icon.png rename to app_account_ztree/static/description/icon.png diff --git a/app_account_chinese_ztree/static/description/index.html b/app_account_ztree/static/description/index.html similarity index 100% rename from app_account_chinese_ztree/static/description/index.html rename to app_account_ztree/static/description/index.html diff --git a/app_account_chinese_ztree/static/description/setup1.jpg b/app_account_ztree/static/description/setup1.jpg similarity index 100% rename from app_account_chinese_ztree/static/description/setup1.jpg rename to app_account_ztree/static/description/setup1.jpg diff --git a/app_account_chinese_ztree/static/img/icon_sunpop.png b/app_account_ztree/static/img/icon_sunpop.png similarity index 100% rename from app_account_chinese_ztree/static/img/icon_sunpop.png rename to app_account_ztree/static/img/icon_sunpop.png diff --git a/app_account_chinese_ztree/static/img/logo_sunpop.png b/app_account_ztree/static/img/logo_sunpop.png similarity index 100% rename from app_account_chinese_ztree/static/img/logo_sunpop.png rename to app_account_ztree/static/img/logo_sunpop.png diff --git a/app_account_ztree/views/account_views.xml b/app_account_ztree/views/account_views.xml new file mode 100644 index 00000000..663cef75 --- /dev/null +++ b/app_account_ztree/views/account_views.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/l10n_cn_standard_lastest/models/account_account.py b/l10n_cn_standard_lastest/models/account_account.py index 26fd977d..2fe1b89d 100644 --- a/l10n_cn_standard_lastest/models/account_account.py +++ b/l10n_cn_standard_lastest/models/account_account.py @@ -26,7 +26,8 @@ class AccountAccount(models.Model): # _rec_name = 'complete_name' parent_id = fields.Many2one('account.account', 'Parent Chart', index=True, ondelete='cascade') - child_id = fields.One2many('account.account', 'parent_id', 'Child Chart') + child_ids = fields.One2many('account.account', 'parent_id', 'Child Chart') + parent_path = fields.Char(index=True) @api.model def _search_new_account_code(self, company, digits, prefix): @@ -38,4 +39,3 @@ class AccountAccount(models.Model): if not rec: return new_code raise UserError(_('Cannot generate an unused account code.')) - diff --git a/l10n_cn_standard_lastest/models/account_account_template.py b/l10n_cn_standard_lastest/models/account_account_template.py index 816169f9..7e9d4057 100644 --- a/l10n_cn_standard_lastest/models/account_account_template.py +++ b/l10n_cn_standard_lastest/models/account_account_template.py @@ -26,6 +26,7 @@ class AccountAccountTemplate(models.Model): # _rec_name = 'complete_name' parent_id = fields.Many2one('account.account.template', 'Parent Chart', index=True, ondelete='cascade') - child_id = fields.One2many('account.account.template', 'parent_id', 'Child Chart') + child_ids = fields.One2many('account.account.template', 'parent_id', 'Child Chart') + parent_path = fields.Char(index=True) diff --git a/l10n_cn_standard_lastest/models/account_chart_template.py b/l10n_cn_standard_lastest/models/account_chart_template.py index b3c062b0..ae62ed27 100644 --- a/l10n_cn_standard_lastest/models/account_chart_template.py +++ b/l10n_cn_standard_lastest/models/account_chart_template.py @@ -21,19 +21,6 @@ from odoo.exceptions import UserError class AccountChartTemplate(models.Model): _inherit = "account.chart.template" - def _get_account_vals(self, company, account_template, code_acc, tax_template_ref): - res = super(AccountChartTemplate, self)._get_account_vals(company, account_template, code_acc, tax_template_ref) - if account_template.parent_id: - parent_account = self.env['account.account'].sudo().search([ - '&', - ('code', '=', account_template.parent_id.code), - ('company_id', '=', company.id) - ], limit=1) - res.update({ - 'parent_id': parent_account.id, - }) - return res - @api.model def _prepare_transfer_account_template(self): ''' Prepare values to create the transfer account that is an intermediary account used when moving money @@ -64,8 +51,35 @@ class AccountChartTemplate(models.Model): return { 'name': _('Liquidity Transfer'), 'code': new_code, + 'parent_id': self.id, 'user_type_id': current_assets_type and current_assets_type.id or False, 'reconcile': True, 'chart_template_id': self.id, } + def load_for_current_company(self, sale_tax_rate, purchase_tax_rate): + res = super(AccountChartTemplate, self).load_for_current_company(sale_tax_rate, purchase_tax_rate) + # 更新父级 + 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 + parent_account = self.env['account.account.template'].sudo().search([ + ('code', '=', code), + ('chart_template_id', '=', self.id), + ('parent_id', '!=', False) + ], limit=1) + if len(parent_account) or code == '2221.01.01': + parent_code = parent_account[0].parent_id.code + if parent_code: + parent = self.env['account.account'].sudo().search([ + ('company_id', '=', company.id), + ('code', '=', parent_code), + ], limit=1) + if len(parent): + acc.update({ + 'parent_id': parent.id, + }) + return res + +