mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
opt account
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user