opt account
|
Before Width: | Height: | Size: 3.0 MiB |
@@ -1,17 +0,0 @@
|
|||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- account -->
|
|
||||||
<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="l10n_cn_standard_lastest.app_view_account_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='parent_id']" position="attributes">
|
|
||||||
<!-- Add your fields or attributes here -->
|
|
||||||
<attribute name="widget">ztree_select</attribute>
|
|
||||||
<attribute name="ztree_parent_key">parent_id</attribute>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
# description:
|
# description:
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': "App Multi Level Account Chart, parent children tree",
|
'name': "App Account Multi Level Chart, parent children tree",
|
||||||
'version': '12.0.12.14',
|
'version': '12.0.12.14',
|
||||||
'author': 'Sunpop.cn',
|
'author': 'Sunpop.cn',
|
||||||
'category': 'Base',
|
'category': 'Base',
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
'currency': 'EUR',
|
'currency': 'EUR',
|
||||||
'depends': [
|
'depends': [
|
||||||
'account',
|
'account',
|
||||||
'l10n_cn_standard_lastest',
|
|
||||||
],
|
],
|
||||||
'images': ['static/description/banner.gif'],
|
'images': ['static/description/banner.gif'],
|
||||||
'data': [
|
'data': [
|
||||||
0
app_account_ztree/static/description/banner.gif
Normal file
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
5
app_account_ztree/views/account_views.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<!-- account -->
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -26,7 +26,8 @@ class AccountAccount(models.Model):
|
|||||||
# _rec_name = 'complete_name'
|
# _rec_name = 'complete_name'
|
||||||
|
|
||||||
parent_id = fields.Many2one('account.account', 'Parent Chart', index=True, ondelete='cascade')
|
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
|
@api.model
|
||||||
def _search_new_account_code(self, company, digits, prefix):
|
def _search_new_account_code(self, company, digits, prefix):
|
||||||
@@ -38,4 +39,3 @@ class AccountAccount(models.Model):
|
|||||||
if not rec:
|
if not rec:
|
||||||
return new_code
|
return new_code
|
||||||
raise UserError(_('Cannot generate an unused account code.'))
|
raise UserError(_('Cannot generate an unused account code.'))
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class AccountAccountTemplate(models.Model):
|
|||||||
# _rec_name = 'complete_name'
|
# _rec_name = 'complete_name'
|
||||||
|
|
||||||
parent_id = fields.Many2one('account.account.template', 'Parent Chart', index=True, ondelete='cascade')
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,19 +21,6 @@ from odoo.exceptions import UserError
|
|||||||
class AccountChartTemplate(models.Model):
|
class AccountChartTemplate(models.Model):
|
||||||
_inherit = "account.chart.template"
|
_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
|
@api.model
|
||||||
def _prepare_transfer_account_template(self):
|
def _prepare_transfer_account_template(self):
|
||||||
''' 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
|
||||||
@@ -64,8 +51,35 @@ class AccountChartTemplate(models.Model):
|
|||||||
return {
|
return {
|
||||||
'name': _('Liquidity Transfer'),
|
'name': _('Liquidity Transfer'),
|
||||||
'code': new_code,
|
'code': new_code,
|
||||||
|
'parent_id': self.id,
|
||||||
'user_type_id': current_assets_type and current_assets_type.id or False,
|
'user_type_id': current_assets_type and current_assets_type.id or False,
|
||||||
'reconcile': True,
|
'reconcile': True,
|
||||||
'chart_template_id': self.id,
|
'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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||