opt account

This commit is contained in:
ivan deng
2018-12-14 19:47:55 +08:00
parent ff121c9d60
commit 6511da7a53
25 changed files with 37 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

View File

@@ -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>

View File

@@ -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': [

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,5 @@
<odoo>
<data>
<!-- account -->
</data>
</odoo>

View File

@@ -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.'))

View File

@@ -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)

View File

@@ -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