diff --git a/app_account_superbar_chinese/__manifest__.py b/app_account_superbar_chinese/__manifest__.py index 776e68f6..b397bb35 100644 --- a/app_account_superbar_chinese/__manifest__.py +++ b/app_account_superbar_chinese/__manifest__.py @@ -58,5 +58,5 @@ 'post_init_hook': 'post_init_hook', 'installable': True, 'application': True, - 'auto_install': True, + 'auto_install': False, } diff --git a/app_base_chinese/models/account.py b/app_base_chinese/models/account.py new file mode 100644 index 00000000..0ae929f4 --- /dev/null +++ b/app_base_chinese/models/account.py @@ -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.')) + diff --git a/app_base_chinese/models/res_currency.py b/app_base_chinese/models/res_currency.py new file mode 100644 index 00000000..4b090498 --- /dev/null +++ b/app_base_chinese/models/res_currency.py @@ -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) diff --git a/app_product_superbar/__manifest__.py b/app_product_superbar/__manifest__.py index da73cdca..0fd302a1 100644 --- a/app_product_superbar/__manifest__.py +++ b/app_product_superbar/__manifest__.py @@ -17,7 +17,7 @@ { 'name': "App product browse by category navigator", - 'version': '11.0.10.15', + 'version': '12.0.11.15', 'author': 'Sunpop.cn', 'category': 'Base', 'website': 'http://www.sunpop.cn', diff --git a/l10n_cn_standard_lastest/__manifest__.py b/l10n_cn_standard_lastest/__manifest__.py index 9b6faf1b..2ce92201 100644 --- a/l10n_cn_standard_lastest/__manifest__.py +++ b/l10n_cn_standard_lastest/__manifest__.py @@ -32,7 +32,8 @@ 3. 补充分类及标签信息。 4. 更新税信息。 5. 增加树状结构,可设置上级科目,配合 "app_web_superbar" 使用可轻易实现树状导航。 - 6. 注意,必须在没有业务数据,没有会计科目的初始环境。可以使用 "app_odoo_customize" 模块清除财务数据,重置会计科目。 + 6. 使用金蝶的会计科目命名法对多级科目进行初始化。可自行调整为用友科目命名法 + 7. 注意,必须在没有业务数据,没有会计科目的初始环境。可以使用 "app_odoo_customize" 模块清除财务数据,重置会计科目。 如果是多语种环境需要自行更改翻译,主要体现在16%增值税处理。 广州尚鹏,Sunpop.cn diff --git a/l10n_cn_standard_lastest/i18n/zh_CN.po b/l10n_cn_standard_lastest/i18n/zh_CN.po index cc59c690..a9c8ca65 100644 --- a/l10n_cn_standard_lastest/i18n/zh_CN.po +++ b/l10n_cn_standard_lastest/i18n/zh_CN.po @@ -21,22 +21,22 @@ msgid "Account" 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 +#: code:addons/l10n_cn_standard_lastest/models/account_account.py:43 +#: 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" msgstr "下级科目" #. 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" -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 "财务" - +msgstr "科目组" #. module: l10n_cn_standard_lastest #: model:ir.ui.menu,name:account.menu_finance @@ -44,20 +44,26 @@ msgid "Finance" msgstr "财务" #. 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_template_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 msgid "Left Parent" 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 +#: code:addons/l10n_cn_standard_lastest/models/account_chart_template.py:65 +#, 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" msgstr "上级科目" #. 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_template_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 msgid "Right Parent" msgstr "右父项" @@ -66,13 +72,4 @@ msgstr "右父项" msgid "Templates for Accounts" 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%销项税" diff --git a/l10n_cn_standard_lastest/models/__init__.py b/l10n_cn_standard_lastest/models/__init__.py index c3793b8b..304827af 100644 --- a/l10n_cn_standard_lastest/models/__init__.py +++ b/l10n_cn_standard_lastest/models/__init__.py @@ -3,6 +3,9 @@ from . import account_account_template from . import account_account from . import account_chart_template +from . import account_journal +from . import res_currency + diff --git a/l10n_cn_standard_lastest/models/account_account.py b/l10n_cn_standard_lastest/models/account_account.py index 072f4195..bd4a042a 100644 --- a/l10n_cn_standard_lastest/models/account_account.py +++ b/l10n_cn_standard_lastest/models/account_account.py @@ -15,8 +15,8 @@ # http://www.sunpop.cn/odoo10_developer_document_offline/ # description: -from odoo import api, fields, models, exceptions, _ - +from odoo import api, fields, models, _ +from odoo.exceptions import UserError, ValidationError class AccountAccount(models.Model): _inherit = ['account.account'] @@ -31,3 +31,14 @@ class AccountAccount(models.Model): parent_left = fields.Integer('Left 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.')) + diff --git a/l10n_cn_standard_lastest/models/account_chart_template.py b/l10n_cn_standard_lastest/models/account_chart_template.py index 59214239..b3c062b0 100644 --- a/l10n_cn_standard_lastest/models/account_chart_template.py +++ b/l10n_cn_standard_lastest/models/account_chart_template.py @@ -15,7 +15,8 @@ # http://www.sunpop.cn/odoo10_developer_document_offline/ # description: -from odoo import api, fields, models, exceptions, _ +from odoo import api, fields, models, _ +from odoo.exceptions import UserError class AccountChartTemplate(models.Model): _inherit = "account.chart.template" @@ -33,5 +34,38 @@ class AccountChartTemplate(models.Model): }) 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, + } diff --git a/l10n_cn_standard_lastest/models/account_journal.py b/l10n_cn_standard_lastest/models/account_journal.py new file mode 100644 index 00000000..e9264e1e --- /dev/null +++ b/l10n_cn_standard_lastest/models/account_journal.py @@ -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, + } diff --git a/l10n_cn_standard_lastest/models/res_currency.py b/l10n_cn_standard_lastest/models/res_currency.py new file mode 100644 index 00000000..c20f2009 --- /dev/null +++ b/l10n_cn_standard_lastest/models/res_currency.py @@ -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) diff --git a/l10n_cn_standard_lastest/static/description/banner.png b/l10n_cn_standard_lastest/static/description/banner.png index 72efdcec..47bc8f20 100644 Binary files a/l10n_cn_standard_lastest/static/description/banner.png and b/l10n_cn_standard_lastest/static/description/banner.png differ diff --git a/l10n_cn_standard_lastest/static/description/index.html b/l10n_cn_standard_lastest/static/description/index.html index 9be5ac1f..8cdf326a 100644 --- a/l10n_cn_standard_lastest/static/description/index.html +++ b/l10n_cn_standard_lastest/static/description/index.html @@ -4,7 +4,7 @@

App Latest Chinese Account chart 2018.

Set all chinese default value. Like Default country, timezone, currency, partner...

-

Lastest update: v11.0.11.07, 2018-11-07

+

Lastest update: v12.0.11.15, 2018-11-07

diff --git a/l10n_cn_standard_lastest/views/account_account_views.xml b/l10n_cn_standard_lastest/views/account_account_views.xml index 01355774..6632abb5 100644 --- a/l10n_cn_standard_lastest/views/account_account_views.xml +++ b/l10n_cn_standard_lastest/views/account_account_views.xml @@ -7,6 +7,9 @@ account.account + + code + @@ -25,7 +28,7 @@ - app.account.list + app.account.account.form account.account