fix account

This commit is contained in:
ivan deng
2018-11-15 20:20:23 +08:00
parent 429e2c1475
commit 0626f8a102
14 changed files with 242 additions and 35 deletions

View File

@@ -58,5 +58,5 @@
'post_init_hook': 'post_init_hook', 'post_init_hook': 'post_init_hook',
'installable': True, 'installable': True,
'application': True, 'application': True,
'auto_install': True, 'auto_install': False,
} }

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from odoo.exceptions import UserError, ValidationError
from odoo import api, fields, models, _
class AccountAccount(models.Model):
_inherit = "account.account"
@api.model
def _search_new_account_code(self, company, digits, prefix):
for num in range(1, 100):
new_code = str(prefix.ljust(digits - 1, '0')) + str(num)
rec = self.search([('code', '=', new_code), ('company_id', '=', company.id)], limit=1)
if not rec:
return new_code
raise UserError(_('Cannot generate an unused account code.'))

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class ResCurrency(models.Model):
_inherit = 'res.currency'
def rmb_upper(self, value):
"""
人民币大写
传入浮点类型的值返回 unicode 字符串
:param 传入阿拉伯数字
:return 返回值是对应阿拉伯数字的绝对值的中文数字
"""
if self.name != 'CNY':
return;
rmbmap = [u"", u"", u"", u"", u"", u"", u"", u"", u"", u""]
unit = [u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"亿",
u"", u"", u"", u"", u"", u"", u"", u""]
# 冲红负数处理
xflag = 0
if value < 0:
xflag = value
value = abs(value)
# 先把value 数字进行格式化保留两位小数,转成字符串然后去除小数点
nums = map(int, list(str('%0.2f' % value).replace('.', '')))
words = []
zflag = 0 # 标记连续0次数以删除万字或适时插入零字
start = len(nums) - 3
for i in range(start, -3, -1): # 使i对应实际位数负数为角分
# 大部分情况对应数字不等于零 或者是刚开始循环
if 0 != nums[start - i] or len(words) == 0:
if zflag:
words.append(rmbmap[0])
zflag = 0
words.append(rmbmap[nums[start - i]]) # 数字对应的中文字符
words.append(unit[i + 2]) # 列表此位置的单位
# 控制‘万/元’ 万和元比较特殊如2拾万和2拾1万 无论有没有这个1 万字是必须的
elif 0 == i or (0 == i % 4 and zflag < 3):
# 上面那种情况定义了 2拾1万 的显示 这个是特殊对待的 2拾万一类的显示
words.append(unit[i + 2])
# 元(控制条件为 0 == i )和万(控制条为(0 == i % 4 and zflag < 3))的情况的处理是一样的
zflag = 0
else:
zflag += 1
if words[-1] != unit[0]: # 结尾非‘分’补整字 最小单位 如果最后一个字符不是最小单位(分)则要加一个整字
words.append(u"")
if xflag < 0: # 如果为负数则要在数字前面加上‘负’字
words.insert(0, u"")
return ''.join(words)

View File

@@ -17,7 +17,7 @@
{ {
'name': "App product browse by category navigator", 'name': "App product browse by category navigator",
'version': '11.0.10.15', 'version': '12.0.11.15',
'author': 'Sunpop.cn', 'author': 'Sunpop.cn',
'category': 'Base', 'category': 'Base',
'website': 'http://www.sunpop.cn', 'website': 'http://www.sunpop.cn',

View File

@@ -32,7 +32,8 @@
3. 补充分类及标签信息。 3. 补充分类及标签信息。
4. 更新税信息。 4. 更新税信息。
5. 增加树状结构,可设置上级科目,配合 "app_web_superbar" 使用可轻易实现树状导航。 5. 增加树状结构,可设置上级科目,配合 "app_web_superbar" 使用可轻易实现树状导航。
6. 注意,必须在没有业务数据,没有会计科目的初始环境。可以使用 "app_odoo_customize" 模块清除财务数据,重置会计科目。 6. 使用金蝶的会计科目命名法对多级科目进行初始化。可自行调整为用友科目命名法
7. 注意,必须在没有业务数据,没有会计科目的初始环境。可以使用 "app_odoo_customize" 模块清除财务数据,重置会计科目。
如果是多语种环境需要自行更改翻译主要体现在16%增值税处理。 如果是多语种环境需要自行更改翻译主要体现在16%增值税处理。
广州尚鹏Sunpop.cn 广州尚鹏Sunpop.cn

View File

@@ -21,22 +21,22 @@ msgid "Account"
msgstr "科目" msgstr "科目"
#. module: l10n_cn_standard_lastest #. module: l10n_cn_standard_lastest
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_child_id #: code:addons/l10n_cn_standard_lastest/models/account_account.py:43
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template_child_id #: code:addons/l10n_cn_standard_lastest/models/account_chart_template.py:62
#, python-format
msgid "Cannot generate an unused account code."
msgstr "无法创建一个无效科目代码"
#. module: l10n_cn_standard_lastest
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account__child_id
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template__child_id
msgid "Child Chart" msgid "Child Chart"
msgstr "下级科目" msgstr "下级科目"
#. module: l10n_cn_standard_lastest #. module: l10n_cn_standard_lastest
#: model:ir.ui.view,arch_db:l10n_cn_standard_lastest.app_view_account_search #: model_terms:ir.ui.view,arch_db:l10n_cn_standard_lastest.app_view_account_search
msgid "Group" msgid "Group"
msgstr "类别" msgstr "科目组"
#. module: account
#: model:ir.ui.menu,name:account.menu_finance
#: model:ir.ui.view,arch_db:account.res_config_settings_view_form
msgid "Finance"
msgstr "财务"
#. module: l10n_cn_standard_lastest #. module: l10n_cn_standard_lastest
#: model:ir.ui.menu,name:account.menu_finance #: model:ir.ui.menu,name:account.menu_finance
@@ -44,20 +44,26 @@ msgid "Finance"
msgstr "财务" msgstr "财务"
#. module: l10n_cn_standard_lastest #. module: l10n_cn_standard_lastest
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_parent_left #: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account__parent_left
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template_parent_left #: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template__parent_left
msgid "Left Parent" msgid "Left Parent"
msgstr "左父项" msgstr "左父项"
#. module: l10n_cn_standard_lastest #. module: l10n_cn_standard_lastest
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_parent_id #: code:addons/l10n_cn_standard_lastest/models/account_chart_template.py:65
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template_parent_id #, python-format
msgid "Liquidity Transfer"
msgstr "流动性转移"
#. module: l10n_cn_standard_lastest
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account__parent_id
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template__parent_id
msgid "Parent Chart" msgid "Parent Chart"
msgstr "上级科目" msgstr "上级科目"
#. module: l10n_cn_standard_lastest #. module: l10n_cn_standard_lastest
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_parent_right #: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account__parent_right
#: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template_parent_right #: model:ir.model.fields,field_description:l10n_cn_standard_lastest.field_account_account_template__parent_right
msgid "Right Parent" msgid "Right Parent"
msgstr "右父项" msgstr "右父项"
@@ -66,13 +72,4 @@ msgstr "右父项"
msgid "Templates for Accounts" msgid "Templates for Accounts"
msgstr "科目模板" msgstr "科目模板"
#. module: l10n_cn_standard_lastest
#: model:account.tax,name:l10n_cn_standard_lastest.1_vatp_standard_business
msgid "增值税16%进项税"
msgstr "增值税16%进项税"
#. module: l10n_cn_standard_lastest
#: model:account.tax,name:l10n_cn_standard_lastest.1_vats_standard_business
msgid "增值税16%销项税"
msgstr "增值税16%销项税"

View File

@@ -3,6 +3,9 @@
from . import account_account_template from . import account_account_template
from . import account_account from . import account_account
from . import account_chart_template from . import account_chart_template
from . import account_journal
from . import res_currency

View File

@@ -15,8 +15,8 @@
# http://www.sunpop.cn/odoo10_developer_document_offline/ # http://www.sunpop.cn/odoo10_developer_document_offline/
# description: # description:
from odoo import api, fields, models, exceptions, _ from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
class AccountAccount(models.Model): class AccountAccount(models.Model):
_inherit = ['account.account'] _inherit = ['account.account']
@@ -31,3 +31,14 @@ class AccountAccount(models.Model):
parent_left = fields.Integer('Left Parent', index=1) parent_left = fields.Integer('Left Parent', index=1)
parent_right = fields.Integer('Right Parent', index=1) parent_right = fields.Integer('Right Parent', index=1)
@api.model
def _search_new_account_code(self, company, digits, prefix):
# 分隔符,金蝶为 ".",用友为""注意odoo中一级科目现金默认定义是4位头银行是6位头
delimiter = '.'
for num in range(1, 100):
new_code = str(prefix.ljust(digits - 1, '0')) + delimiter + '%02d' % (num)
rec = self.search([('code', '=', new_code), ('company_id', '=', company.id)], limit=1)
if not rec:
return new_code
raise UserError(_('Cannot generate an unused account code.'))

View File

@@ -15,7 +15,8 @@
# http://www.sunpop.cn/odoo10_developer_document_offline/ # http://www.sunpop.cn/odoo10_developer_document_offline/
# description: # description:
from odoo import api, fields, models, exceptions, _ from odoo import api, fields, models, _
from odoo.exceptions import UserError
class AccountChartTemplate(models.Model): class AccountChartTemplate(models.Model):
_inherit = "account.chart.template" _inherit = "account.chart.template"
@@ -33,5 +34,38 @@ class AccountChartTemplate(models.Model):
}) })
return res 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
from a liquidity account to another.
:return: A dictionary of values to create a new account.account.
'''
# 分隔符,金蝶为 ".",用友为""注意odoo中一级科目现金默认定义是4位头银行是6位头
delimiter = '.'
digits = self.code_digits
prefix = self.transfer_account_code_prefix or ''
# Flatten the hierarchy of chart templates.
chart_template = self
chart_templates = self
while chart_template.parent_id:
chart_templates += chart_template.parent_id
chart_template = chart_template.parent_id
new_code = ''
for num in range(1, 100):
new_code = str(prefix.ljust(digits - 1, '0')) + delimiter + '%02d' % (num)
rec = self.env['account.account.template'].search(
[('code', '=', new_code), ('chart_template_id', 'in', chart_templates.ids)], limit=1)
if not rec:
break
else:
raise UserError(_('Cannot generate an unused account code.'))
current_assets_type = self.env.ref('account.data_account_type_current_assets', raise_if_not_found=False)
return {
'name': _('Liquidity Transfer'),
'code': new_code,
'user_type_id': current_assets_type and current_assets_type.id or False,
'reconcile': True,
'chart_template_id': self.id,
}

View File

@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
# 调整初始化算法
class AccountJournal(models.Model):
_inherit = "account.journal"
@api.model
def _prepare_liquidity_account(self, name, company, currency_id, type):
'''
This function prepares the value to use for the creation of the default debit and credit accounts of a
liquidity journal (created through the wizard of generating COA from templates for example).
:param name: name of the bank account
:param company: company for which the wizard is running
:param currency_id: ID of the currency in which is the bank account
:param type: either 'cash' or 'bank'
:return: mapping of field names and values
:rtype: dict
'''
digits = 6
chart = self.company_id.chart_template_id
if chart:
digits = int(chart.code_digits)
# Seek the next available number for the account code
if type == 'bank':
account_code_prefix = company.bank_account_code_prefix or ''
else:
account_code_prefix = company.cash_account_code_prefix or company.bank_account_code_prefix or ''
digits = len(account_code_prefix)
liquidity_type = self.env.ref('account.data_account_type_liquidity')
return {
'name': name,
'currency_id': currency_id or False,
'code': self.env['account.account']._search_new_account_code(company, digits, account_code_prefix),
'user_type_id': liquidity_type and liquidity_type.id or False,
'company_id': company.id,
}

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models, exceptions, _
class ResCurrency(models.Model):
_inherit = 'res.currency'
def rmb_upper(self, value):
"""
人民币大写
传入浮点类型的值返回 unicode 字符串
:param 传入阿拉伯数字
:return 返回值是对应阿拉伯数字的绝对值的中文数字
"""
if self.name != 'CNY':
return;
rmbmap = [u"", u"", u"", u"", u"", u"", u"", u"", u"", u""]
unit = [u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"亿",
u"", u"", u"", u"", u"", u"", u"", u""]
# 冲红负数处理
xflag = 0
if value < 0:
xflag = value
value = abs(value)
# 先把value 数字进行格式化保留两位小数,转成字符串然后去除小数点
nums = map(int, list(str('%0.2f' % value).replace('.', '')))
words = []
zflag = 0 # 标记连续0次数以删除万字或适时插入零字
start = len(nums) - 3
for i in range(start, -3, -1): # 使i对应实际位数负数为角分
# 大部分情况对应数字不等于零 或者是刚开始循环
if 0 != nums[start - i] or len(words) == 0:
if zflag:
words.append(rmbmap[0])
zflag = 0
words.append(rmbmap[nums[start - i]]) # 数字对应的中文字符
words.append(unit[i + 2]) # 列表此位置的单位
# 控制‘万/元’ 万和元比较特殊如2拾万和2拾1万 无论有没有这个1 万字是必须的
elif 0 == i or (0 == i % 4 and zflag < 3):
# 上面那种情况定义了 2拾1万 的显示 这个是特殊对待的 2拾万一类的显示
words.append(unit[i + 2])
# 元(控制条件为 0 == i )和万(控制条为(0 == i % 4 and zflag < 3))的情况的处理是一样的
zflag = 0
else:
zflag += 1
if words[-1] != unit[0]: # 结尾非‘分’补整字 最小单位 如果最后一个字符不是最小单位(分)则要加一个整字
words.append(u"")
if xflag < 0: # 如果为负数则要在数字前面加上‘负’字
words.insert(0, u"")
return ''.join(words)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

@@ -4,7 +4,7 @@
<h2 class="oe_slogan">App Latest Chinese Account chart 2018.</h2> <h2 class="oe_slogan">App Latest Chinese Account chart 2018.</h2>
<h3 class="oe_slogan">Set all chinese default value. Like Default country, timezone, currency, partner... </h3> <h3 class="oe_slogan">Set all chinese default value. Like Default country, timezone, currency, partner... </h3>
<div class="oe_row"> <div class="oe_row">
<h3>Lastest update: v11.0.11.07, 2018-11-07</h3> <h3>Lastest update: v12.0.11.15, 2018-11-07</h3>
<div class="oe_span12"> <div class="oe_span12">
<img class="oe_demo oe_picture oe_screenshot" src="banner.png"> <img class="oe_demo oe_picture oe_screenshot" src="banner.png">
</div> </div>

View File

@@ -7,6 +7,9 @@
<field name="model">account.account</field> <field name="model">account.account</field>
<field name="inherit_id" ref="account.view_account_list"/> <field name="inherit_id" ref="account.view_account_list"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="default_order">code</attribute>
</xpath>
<xpath expr="field[@name='user_type_id']" position="after"> <xpath expr="field[@name='user_type_id']" position="after">
<field name="group_id"/> <field name="group_id"/>
<field name="tag_ids" widget="many2many_tags"/> <field name="tag_ids" widget="many2many_tags"/>
@@ -25,7 +28,7 @@
</field> </field>
</record> </record>
<record id="app_view_account_form" model="ir.ui.view"> <record id="app_view_account_form" model="ir.ui.view">
<field name="name">app.account.list</field> <field name="name">app.account.account.form</field>
<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">