diff --git a/l10n_cn_account_voucher/README.rst b/l10n_cn_account_voucher/README.rst new file mode 100644 index 0000000..bd27a8b --- /dev/null +++ b/l10n_cn_account_voucher/README.rst @@ -0,0 +1,69 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================== +Chinese Accounting Voucher +========================== + + +This module provides an official printout for Chinese voucher. + +Installation +============ + +To install this module, you need to: + + * have basic modules installed (account, l10n_cn_sequence_voucher) + +Configuration +============= + +To configure this module, you need to: + + * No specific configuration needed. + +Usage +===== + +To print the voucher: + +* Go to Accounting/Adviser/Journal Entries +* Select Print/Voucher + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + + +Contributors +------------ + +* Jeff/开阖软件 +* Matt.Cai +* hdjmd +* Luke Zheng + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png +:alt: Odoo Community Association +:target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/l10n_cn_account_voucher/__init__.py b/l10n_cn_account_voucher/__init__.py new file mode 100644 index 0000000..e09371c --- /dev/null +++ b/l10n_cn_account_voucher/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models, tests diff --git a/l10n_cn_account_voucher/__openerp__.py b/l10n_cn_account_voucher/__openerp__.py new file mode 100644 index 0000000..7d04672 --- /dev/null +++ b/l10n_cn_account_voucher/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "l10n_cn_account_voucher", + "version": "9.0.1.0.0", + "category": "Account", + "website": "https://www.elico-corp.com", + "author": "Elico corp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "account", + "l10n_cn_sequence_voucher", + ], + "data": [ + "views/account_move.xml", + "report/report_account_move.xml", + ], +} diff --git a/l10n_cn_account_voucher/i18n/zh_CN.po b/l10n_cn_account_voucher/i18n/zh_CN.po new file mode 100644 index 0000000..a80e73f --- /dev/null +++ b/l10n_cn_account_voucher/i18n/zh_CN.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_cn_account_voucher +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-12-01 09:27+0000\n" +"PO-Revision-Date: 2015-12-01 09:27+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_cn_account_voucher +#: model:ir.model,name:l10n_cn_account_voucher.model_account_move +msgid "Account Entry" +msgstr "科目条目" + +#. module: l10n_cn_account_voucher +#: model:ir.model.fields,field_description:l10n_cn_account_voucher.field_account_move_proof +msgid "Attachment Count" +msgstr "附件" + +#. module: l10n_cn_account_voucher +#: model:ir.model.fields,field_description:l10n_cn_account_voucher.field_account_move_line_currency_rate +msgid "Currency Rate" +msgstr "汇率" + +#. module: l10n_cn_account_voucher +#: model:ir.model.fields,field_description:l10n_cn_account_voucher.field_report_l10n_cn_account_voucher_report_account_move_display_name +msgid "Display Name" +msgstr "显示名称" + +#. module: l10n_cn_account_voucher +#: model:ir.model.fields,field_description:l10n_cn_account_voucher.field_report_l10n_cn_account_voucher_report_account_move_id +msgid "ID" +msgstr "ID" + +#. module: l10n_cn_account_voucher +#: model:ir.model,name:l10n_cn_account_voucher.model_account_move_line +msgid "Journal Item" +msgstr "分类账项目" + +#. module: l10n_cn_account_voucher +#: model:ir.model.fields,field_description:l10n_cn_account_voucher.field_report_l10n_cn_account_voucher_report_account_move___last_update +msgid "Last Modified on" +msgstr "最后修改日" + +#. module: l10n_cn_account_voucher +#: model:ir.actions.report.xml,name:l10n_cn_account_voucher.action_report_account_move +msgid "Voucher" +msgstr "凭证" + +#. module: l10n_cn_account_voucher +#: model:ir.model,name:l10n_cn_account_voucher.model_report_l10n_cn_account_voucher_report_account_move +msgid "report.l10n_cn_account_voucher.report_account_move" +msgstr "report.l10n_cn_account_voucher.report_account_move" + diff --git a/l10n_cn_account_voucher/models/__init__.py b/l10n_cn_account_voucher/models/__init__.py new file mode 100644 index 0000000..8d2eaf2 --- /dev/null +++ b/l10n_cn_account_voucher/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_move diff --git a/l10n_cn_account_voucher/models/account_move.py b/l10n_cn_account_voucher/models/account_move.py new file mode 100644 index 0000000..b88cd68 --- /dev/null +++ b/l10n_cn_account_voucher/models/account_move.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, fields, models +from math import ceil + + +class AccountMove(models.Model): + _inherit = 'account.move' + + proof = fields.Integer('Attachment Count', required=False, default=1) + chinese_sequence_number = fields.Char('Chinese Voucher Number', + size=64, copy=False, readonly=True, + help='Internal Sequence Number') + + def _paginate(self, items, max_per_page=5): + """ + The paging function + items is to page entry + max_per_page Set the number of each page + return:Number of pages + """ + count = len(items) + return int(ceil(float(count) / max_per_page)) + + @api.multi + def _get_account_name(self, id): + account_name = self.env['account.account'].browse(id).name_get()[0] + # Account move print use Account here: + return account_name[1] + + @api.model + def _get_account_partner(self, id, name): + value = 'account.account,' + str(id) + partner_prop_acc = self.env['ir.property'].search( + [('value_reference', '=', value)]) + if partner_prop_acc: + return name + else: + return False + + def _get_exchange_rate(self, line): + """ + Exchange rate: Debit or Credit / currency ammount + Why not get it from currency code + date ? + """ + exchange_rate = False + if line.amount_currency: + if line.debit > 0: + exchange_rate = line.debit / line.amount_currency + if line.credit > 0: + exchange_rate = line.credit / (-1 * line.amount_currency) + return round(exchange_rate, 6) + + def _get_unit_price(self, line): + """ + Unit price:Debit or Credit / Quantity + """ + unit_price = False + if line.quantity: + if line.debit > 0: + unit_price = line.debit / line.quantity + if line.credit > 0: + unit_price = line.credit / line.quantity + return unit_price + + def _rmb_format(self, value): + """ + Separate numerical according to the figures + """ + rounding = self.env['res.currency'].browse( + self.company_id.currency_id.id).rounding + + if value < rounding: + # if value is 0,return 0.00 + return (['' for i in range(12)] + list(( + '%0.2f' % 0).replace('.', '')))[-12:] + # change num to string, remove The decimal point + # get 12 itmes and return + return (['' for i in range(12)] + list(( + '%0.2f' % value).replace('.', '')))[-12:] + + def _rmb_upper(self, value): + """ + in capital letters + from:http://topic.csdn.net/u/20091129/20/b778a93d-9f8f-4829-9297-d05b08a23f80.html + To float value is returned, unicode string + """ + 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"兆"] + nums = map(int, list(str('%0.2f' % value).replace('.', ''))) + words = [] + # Tag 0 times in a row, to remove a swastika, + # insert zero word or timely + zflag = 0 + start = len(nums) - 3 + # Make I corresponds to the actual figures, + # negative for the corner points + for i in range(start, -3, -1): + 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]) + # Control 'ten thousand/yuan' + elif 0 == i or (0 == i % 4 and zflag < 3): + words.append(unit[i + 2]) + zflag = 0 + else: + zflag += 1 + # At the end of the 'points' to fill the whole word + if words[-1] != unit[0]: + words.append(u"整") + return ''.join(words) + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + currency_rate = fields.Float( + 'Currency Rate', digits=(10, 6), compute='_compute_currency_rate', store=True) + + @api.depends('credit', 'debit', 'amount_currency') + def _compute_currency_rate(self): + for record in self: + if record.currency_id: + if record.amount_currency: + record.currency_rate = abs( + (record.debit + or record.credit) / record.amount_currency) + else: + record.currency_rate = False diff --git a/l10n_cn_account_voucher/report/report_account_move.xml b/l10n_cn_account_voucher/report/report_account_move.xml new file mode 100644 index 0000000..1010662 --- /dev/null +++ b/l10n_cn_account_voucher/report/report_account_move.xml @@ -0,0 +1,233 @@ + + + + + + + \ No newline at end of file diff --git a/l10n_cn_account_voucher/tests/__init__.py b/l10n_cn_account_voucher/tests/__init__.py new file mode 100644 index 0000000..dc6be52 --- /dev/null +++ b/l10n_cn_account_voucher/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_account_move diff --git a/l10n_cn_account_voucher/tests/test_account_move.py b/l10n_cn_account_voucher/tests/test_account_move.py new file mode 100644 index 0000000..b08a96f --- /dev/null +++ b/l10n_cn_account_voucher/tests/test_account_move.py @@ -0,0 +1,189 @@ +# -*- coding: utf-8 -*- +# © 2016 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openerp.tests import common +import logging +_logger = logging.getLogger(__name__) +import sys +reload(sys) +sys.setdefaultencoding('utf-8') + + +class TestAccountMove(common.TransactionCase): + def setUp(self): + super(TestAccountMove, self).setUp() + + self.currency_usd_id = self.env.ref("base.USD").id + self.account_account_1 = self.env['account.account'].create({ + 'name': 'account_1', + 'code': 1111, + 'user_type_id': 4, + }) + # currency_id is False + self.account_move_line_1 = self.env['account.move.line'].create({ + 'name': 'line_1', + 'journal_id': 1, + 'date': '2015-10-10', + 'date_maturity': '2015-10-10', + 'account_id': self.account_account_1.id, + 'currency_id': False, + }) + # amount_currency is False and quantity is False + self.account_move_line_2 = self.env['account.move.line'].create({ + 'name': 'line_1', + 'journal_id': 1, + 'date': '2015-10-10', + 'date_maturity': '2015-10-10', + 'account_id': 1, + 'currency_id': 1, + 'amount_currency': False, + 'quantity': 0, + }) + # amount_currency is True and debit > 0 + self.account_move_line_3 = self.env['account.move.line'].create({ + 'name': 'line_1', + 'journal_id': 1, + 'date': '2015-10-10', + 'date_maturity': '2015-10-10', + 'account_id': 1, + 'currency_id': 1, + 'amount_currency': 2, + 'quantity': 10, + }) + # amount_currency is True + self.account_move_line_4 = self.env['account.move.line'].create({ + 'name': 'line_1', + 'journal_id': 1, + 'date': '2015-10-10', + 'date_maturity': '2015-10-10', + 'account_id': 1, + 'currency_id': 1, + 'amount_currency': 1, + 'quantity': 10, + }) + self.account_move_1 = self.env['account.move'].create({ + 'name': '/', + 'journal_id': 1, + 'date': '2015-10-10', + 'line_ids': [(0, 0, { + 'name': 'foo', + 'debit': 10, + 'account_id': self.account_account_1.id, + }), (0, 0, { + 'name': 'bar', + 'credit': 10, + 'account_id': self.account_account_1.id, + })] + }) + # amount_currency is True + self.account_move_2 = self.env['account.move'].create({ + 'name': '/', + 'journal_id': 1, + 'date': '2015-10-10', + 'line_ids': [(0, 0, { + 'name': 'foo2', + 'amount_currency': 10, + 'debit': 10, + 'currency_id': 1, + 'quantity': 2, + 'account_id': self.account_account_1.id, + }), (0, 0, { + 'name': 'bar2', + 'amount_currency': -10, + 'credit': 10, + 'currency_id': 1, + 'quantity': 2, + 'account_id': self.account_account_1.id, + })] + }) + # debit > 0 and amount_currency is True + self.line_1 = self.account_move_2.line_ids.search([ + ('name', '=', 'foo2')]) + # credit > 0 and amount_currency is True + self.line_2 = self.account_move_2.line_ids.search([ + ('name', '=', 'bar2')]) + self.ir_property_1 = self.env['ir.property'].create({ + 'fields_id': 1, + 'value_reference': 'account.account,1', + }) + + def test_paginate(self): + """ Checks if the test_paginate works properly + """ + res = self.account_move_1._paginate(self.account_move_1.line_ids) + self.assertEqual(1, res) + + def test_get_account_name(self): + """ Checks if the _get_account_name works properly + """ + res = self.account_move_1._get_account_name( + self.account_account_1.id) + self.assertEqual('1111 account_1', res) + + def test_get_account_partner(self): + """ Checks if the test_get_account_partner works properly + """ + res = self.account_move_1._get_account_partner(1, 'name') + self.assertEqual('name', res) + res = self.account_move_1._get_account_partner(2, 'name') + self.assertFalse(res) + + def test_get_exchange_rate(self): + """ Checks if the _get_exchange_rate works properly + """ + # amount_currency is False + res = self.account_move_1._get_exchange_rate(self.account_move_line_2) + self.assertEqual(0.0, res) + # amount_currency is True and debit > 0 + res = self.account_move_2._get_exchange_rate(self.line_1) + self.assertEqual(1.0, res) + # amount_currency is True and credit > 0 + res = self.account_move_2._get_exchange_rate(self.line_2) + self.assertEqual(1.0, res) + + def test_get_unit_price(self): + """ Checks if the _get_unit_price works properly + """ + # quantity is False + res = self.account_move_1._get_unit_price(self.account_move_line_2) + self.assertFalse(res) + # quantity is True and debit > 0 + res = self.account_move_1._get_unit_price(self.line_1) + self.assertEqual(5, res) + # quantity is True and credit > 0 + res = self.account_move_1._get_unit_price(self.line_2) + self.assertEqual(5, res) + + def test_rmb_format(self): + """ Checks if the _rmb_format works properly + """ + res = self.account_move_1._rmb_format(0.005) + self.assertEqual( + ['', '', '', '', '', '', '', '', '', '0', '0', '0'], + res) + res = self.account_move_1._rmb_format(1) + self.assertEqual( + ['', '', '', '', '', '', '', '', '', '1', '0', '0'], res) + + def test_rmb_upper(self): + """ Checks if the test_rmb_upper works properly + """ + res = self.account_move_1._rmb_upper(802.68) + self.assertEqual( + u'捌佰零贰元陆角捌分', res) + res = self.account_move_1._rmb_upper(801) + self.assertEqual( + u'捌佰零壹元整', res) + + def test_compute_currency_rate(self): + """ Checks if the _compute_currency_rate works properly + """ + self.account_move_line_1._compute_currency_rate() + self.assertFalse(self.account_move_line_2.currency_rate) + self.assertEqual( + self.account_move_line_3.currency_rate, abs( + (self.account_move_line_3.debit + or self.account_move_line_3.credit) / + self.account_move_line_3.amount_currency) + ) diff --git a/l10n_cn_account_voucher/views/account_move.xml b/l10n_cn_account_voucher/views/account_move.xml new file mode 100644 index 0000000..06739ea --- /dev/null +++ b/l10n_cn_account_voucher/views/account_move.xml @@ -0,0 +1,37 @@ + + + + + + + + + account.move.form.inherit.print + account.move + + + + + + + + + + account.move.form + account.move + + + + + + + + + diff --git a/l10n_cn_sequence_voucher/README.rst b/l10n_cn_sequence_voucher/README.rst new file mode 100644 index 0000000..883061e --- /dev/null +++ b/l10n_cn_sequence_voucher/README.rst @@ -0,0 +1,63 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================== +Chinese monthly sequencing +========================== + + +Change the sequence numbering of the vouchers to start over from zero every first day of the month. + +Installation +============ + +To install this module, you need to: + + * have basic modules installed (account) + +Configuration +============= + +To configure this module, you need to: + + * No specific configuration needed. + + +For further information, please visit: + + * https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + + +Contributors +------------ + +* Qiao Lei +* Luke Zheng + +Maintainer +---------- + +.. image:: https://www.elico-corp.com/logo.png + :alt: Elico Corp + :target: https://www.elico-corp.com + +This module is maintained by Elico Corporation. + +Elico Corporation offers consulting services to implement open source management software in SMEs, with a strong involvement in quality of service. + +Our headquarters are located in Shanghai with branches in Hong Kong, ShenZhen and Singapore servicing customers from Greater China, Asia Pacific, Europe, Americas, etc.. \ No newline at end of file diff --git a/l10n_cn_sequence_voucher/__init__.py b/l10n_cn_sequence_voucher/__init__.py new file mode 100644 index 0000000..1770763 --- /dev/null +++ b/l10n_cn_sequence_voucher/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models, tests diff --git a/l10n_cn_sequence_voucher/__openerp__.py b/l10n_cn_sequence_voucher/__openerp__.py new file mode 100644 index 0000000..18d3685 --- /dev/null +++ b/l10n_cn_sequence_voucher/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "l10n_cn_sequence_voucher", + "version": "9.0.1.0.0", + "category": "Account", + "website": "https://www.elico-corp.com", + "author": "Elico corp", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "account", + "l10n_cn_account_voucher", + ], + "data": [ + "views/account_journal.xml", + "views/account_move.xml", + "data/account_sequence_data.xml", + ], +} diff --git a/l10n_cn_sequence_voucher/data/account_sequence_data.xml b/l10n_cn_sequence_voucher/data/account_sequence_data.xml new file mode 100644 index 0000000..c9e36f0 --- /dev/null +++ b/l10n_cn_sequence_voucher/data/account_sequence_data.xml @@ -0,0 +1,37 @@ + + + + + + + Cash in + account.journal + 现收 + + + + Cash out + account.journal + 现付 + + + + Bank in + account.journal + 银收 + + + + Bank out + account.journal + 银付 + + + + Transfer + account.journal + + + + + diff --git a/l10n_cn_sequence_voucher/i18n/zh_CN.po b/l10n_cn_sequence_voucher/i18n/zh_CN.po new file mode 100644 index 0000000..1a4becf --- /dev/null +++ b/l10n_cn_sequence_voucher/i18n/zh_CN.po @@ -0,0 +1,114 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_cn_sequence_voucher +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-12-01 09:24+0000\n" +"PO-Revision-Date: 2015-12-01 09:24+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model,name:l10n_cn_sequence_voucher.model_account_move +msgid "Account Entry" +msgstr "科目条目" + +#. module: l10n_cn_sequence_voucher +#: model:ir.sequence,name:l10n_cn_sequence_voucher.sequence_journal_seq_bank_in +msgid "Bank in" +msgstr "银收" + +#. module: l10n_cn_sequence_voucher +#: model:ir.sequence,name:l10n_cn_sequence_voucher.sequence_journal_seq_bank_out +msgid "Bank out" +msgstr "银付" + +#. module: l10n_cn_sequence_voucher +#: model:ir.sequence,name:l10n_cn_sequence_voucher.sequence_journal_seq_cash_in +msgid "Cash in" +msgstr "现收" + +#. module: l10n_cn_sequence_voucher +#: model:ir.sequence,name:l10n_cn_sequence_voucher.sequence_journal_seq_cash_out +msgid "Cash out" +msgstr "现付" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher.field_account_move_chinese_sequence_number +msgid "Chinese Voucher Number" +msgstr "Chinese Voucher Number" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher.field_account_journal_internal_sequence_in_id +msgid "IN Sequence" +msgstr "IN Sequence" + +#. module: l10n_cn_sequence_voucher +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher.view_account_journal_form_inherit_elico +msgid "In sequence" +msgstr "In sequence" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,help:l10n_cn_sequence_voucher.field_account_move_chinese_sequence_number +msgid "Internal Sequence Number" +msgstr "Internal Sequence Number" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,help:l10n_cn_sequence_voucher.field_account_move_chinese_sequence_type +msgid "Internal Sequence Type" +msgstr "Internal Sequence Type" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model,name:l10n_cn_sequence_voucher.model_account_journal +msgid "Journal" +msgstr "分类账" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher.field_account_journal_internal_sequence_out_id +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher.view_account_journal_form_inherit_elico +msgid "Out Sequence" +msgstr "Out Sequence" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,help:l10n_cn_sequence_voucher.field_account_journal_internal_sequence_in_id +#: model:ir.model.fields,help:l10n_cn_sequence_voucher.field_account_journal_internal_sequence_out_id +msgid "This sequence will be used to maintain the internal number for the journal entries related to this journal for cash/bank in or out." +msgstr "This sequence will be used to maintain the internal number for the journal entries related to this journal for cash/bank in or out." + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,help:l10n_cn_sequence_voucher.field_account_journal_internal_sequence_transfer_id +msgid "This sequence will be used to maintain the internal number for the journal entries related to this journal for transfer." +msgstr "This sequence will be used to maintain the internal number for the journal entries related to this journal for transfer." + +#. module: l10n_cn_sequence_voucher +#: model:ir.sequence,name:l10n_cn_sequence_voucher.sequence_journal_seq_transfer +msgid "Transfer" +msgstr "转" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher.field_account_journal_internal_sequence_transfer_id +msgid "Transfer Sequence" +msgstr "Transfer Sequence" + +#. module: l10n_cn_sequence_voucher +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher.view_account_journal_form_inherit_elico +msgid "Transfer sequence" +msgstr "Transfer sequence" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher.field_account_move_chinese_sequence_type +msgid "Voucher Type change to" +msgstr "Voucher Type change to" + +#. module: l10n_cn_sequence_voucher +#: model:ir.model,name:l10n_cn_sequence_voucher.model_ir_sequence +msgid "ir.sequence" +msgstr "ir.sequence" + diff --git a/l10n_cn_sequence_voucher/models/__init__.py b/l10n_cn_sequence_voucher/models/__init__.py new file mode 100644 index 0000000..80163ab --- /dev/null +++ b/l10n_cn_sequence_voucher/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_journal, account_move, ir_sequence diff --git a/l10n_cn_sequence_voucher/models/account_journal.py b/l10n_cn_sequence_voucher/models/account_journal.py new file mode 100644 index 0000000..c6ec65d --- /dev/null +++ b/l10n_cn_sequence_voucher/models/account_journal.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import fields, models + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + internal_sequence_transfer_id = fields.Many2one( + 'ir.sequence', 'Transfer Sequence', + help='''This sequence will be used to maintain the internal number + for the journal entries related to this journal for transfer.''' + ) + internal_sequence_out_id = fields.Many2one( + 'ir.sequence', 'Out Sequence', + help='''This sequence will be used to maintain the internal number + for the journal entries related to this journal + for cash/bank in or out.''' + ) + internal_sequence_in_id = fields.Many2one( + 'ir.sequence', 'IN Sequence', + help='''This sequence will be used to maintain the internal number + for the journal entries related to this journal + for cash/bank in or out.''' + ) diff --git a/l10n_cn_sequence_voucher/models/account_move.py b/l10n_cn_sequence_voucher/models/account_move.py new file mode 100644 index 0000000..be9a064 --- /dev/null +++ b/l10n_cn_sequence_voucher/models/account_move.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, fields, models + + +class AccountMove(models.Model): + _inherit = 'account.move' + + chinese_sequence_type = fields.Selection([ + ('cash_in', '现收'), ('cash_out', '现付'), + ('bank_in', '银收'), ('bank_out', '银付'), + ('transfer', '转')], + 'Voucher Type change to', + help='Internal Sequence Type') + + @api.multi + def write(self, vals): + c = self.env.context.copy() + c['novalidate'] = True + if 'state' in vals and vals['state'] == 'posted': + for move in self: + if not move.chinese_sequence_number: + sequence_id = self.env.ref( + 'l10n_cn_sequence_voucher\ +.sequence_journal_seq_transfer')[0] + seq_no = sequence_id.next_by_id() + if seq_no: + vals['chinese_sequence_number'] = seq_no + result = super(AccountMove, self).write(vals) + return result + + @api.multi + def post(self): + obj_sequence = self.env['ir.sequence'] + res = super(AccountMove, self).post() + seq_no = False + for move in self: + if move.chinese_sequence_type: + if move.chinese_sequence_type == 'cash_in': + sequence_id = self.env.ref( + 'l10n_cn_sequence_voucher\ +.sequence_journal_seq_cash_in')[0] + if move.chinese_sequence_type == 'cash_out': + sequence_id = self.env.ref( + 'l10n_cn_sequence_voucher\ +.sequence_journal_seq_cash_out')[0] + if move.chinese_sequence_type == 'bank_in': + sequence_id = self.env.ref( + 'l10n_cn_sequence_voucher\ +.sequence_journal_seq_bank_in')[0] + if move.chinese_sequence_type == 'bank_out': + sequence_id = self.env.ref( + 'l10n_cn_sequence_voucher\ +.sequence_journal_seq_bank_out')[0] + if move.chinese_sequence_type == 'transfer': + sequence_id = self.env.ref( + 'l10n_cn_sequence_voucher\ +.sequence_journal_seq_transfer')[0] + seq_no = sequence_id.next_by_id() + if seq_no: + res = self.write({'chinese_sequence_number': seq_no}) + else: + for line in move.line_ids: + if line.account_id.code == '1001.01': + if line.credit != 0 and line.debit == 0: + if move.journal_id.internal_sequence_out_id: + sequence_id = obj_sequence.browse( + move.journal_id. + internal_sequence_out_id.id) + seq_no = sequence_id.next_by_id() + if line.credit == 0 and line.debit != 0: + if move.journal_id.internal_sequence_in_id: + sequence_id = obj_sequence.browse( + move.journal_id. + internal_sequence_in_id.id) + seq_no = sequence_id.next_by_id() + if line.account_id.code == '1002.01': + if line.credit != 0 and line.debit == 0: + if move.journal_id.internal_sequence_out_id: + sequence_id = obj_sequence.browse( + move.journal_id. + internal_sequence_out_id.id) + seq_no = sequence_id.next_by_id() + if line.credit == 0 and line.debit != 0: + if move.journal_id.internal_sequence_in_id: + sequence_id = obj_sequence.browse( + move.journal_id. + internal_sequence_in_id.id) + seq_no = sequence_id.next_by_id() + if seq_no: + res = self.write({ + 'chinese_sequence_number': seq_no}) + break + if not seq_no: + if move.journal_id.internal_sequence_transfer_id: + seq_no = obj_sequence.browse( + move.journal_id.internal_sequence_transfer_id.id).\ + next_by_id() + if seq_no: + res = self.write({'chinese_sequence_number': seq_no}) + return res diff --git a/l10n_cn_sequence_voucher/models/ir_sequence.py b/l10n_cn_sequence_voucher/models/ir_sequence.py new file mode 100644 index 0000000..673348d --- /dev/null +++ b/l10n_cn_sequence_voucher/models/ir_sequence.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import fields, models + + +class IrSequence(models.Model): + _inherit = "ir.sequence" + + name = fields.Char(translate=True) diff --git a/l10n_cn_sequence_voucher/tests/__init__.py b/l10n_cn_sequence_voucher/tests/__init__.py new file mode 100644 index 0000000..1574f26 --- /dev/null +++ b/l10n_cn_sequence_voucher/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_account_move diff --git a/l10n_cn_sequence_voucher/tests/test_account_move.py b/l10n_cn_sequence_voucher/tests/test_account_move.py new file mode 100644 index 0000000..29886b1 --- /dev/null +++ b/l10n_cn_sequence_voucher/tests/test_account_move.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +# © 2015 Elico corp (www.elico-corp.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openerp.tests import common +import logging +_logger = logging.getLogger(__name__) + + +class TestAccountMove(common.TransactionCase): + def setUp(self): + super(TestAccountMove, self).setUp() + self.account_move = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'line_ids': [ + [0, 0, {'account_id': 1, 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + self.account = self.env['account.account'].create({ + 'name': 'account_1', + 'code': '9000.00', + 'user_type_id': 4}) + # code == '1001.01' + self.account1 = self.env['account.account'].create({ + 'name': 'account_1', + 'code': '1001.01', + 'user_type_id': 4}) + self.account2 = self.env['account.account'].create({ + 'name': 'account_1', + 'code': '1002.01', + 'user_type_id': 4}) + self.account_move1 = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'chinese_sequence_type': 'cash_in', + 'line_ids': [ + [0, 0, {'account_id': 1, 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + self.account_move2 = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'chinese_sequence_type': 'cash_out', + 'line_ids': [ + [0, 0, {'account_id': 1, 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + self.account_move3 = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'chinese_sequence_type': 'bank_in', + 'line_ids': [ + [0, 0, {'account_id': 1, 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + self.account_move4 = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'chinese_sequence_type': 'bank_out', + 'line_ids': [ + [0, 0, {'account_id': 1, 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + self.account_move5 = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'chinese_sequence_type': 'transfer', + 'line_ids': [ + [0, 0, {'account_id': 1, 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + self.sequence = self.env['ir.sequence'].create({ + 'name': 'sequence_1' + }) + # internal_sequence_out_id is True + self.journal_1 = self.env['account.journal'].create({ + 'name': 'journal_1', + 'type': 'bank', + 'internal_sequence_out_id': 1, + }) + # internal_sequence_in_id is True + self.journal_2 = self.env['account.journal'].create({ + 'name': 'journal_2', + 'type': 'bank', + 'internal_sequence_in_id': 1, + }) + self.account_move6 = self.env['account.move'].create({ + 'journal_id': 1, + 'date': '2015-10-10', + 'chinese_sequence_type': False, + 'line_ids': [ + [0, 0, { + 'account_id': self.account1.id, + 'name': 'test', 'credit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'debit': 10}] + ]}) + # account code = 1001.01 + self.account_move7 = self.env['account.move'].create({ + 'journal_id': self.journal_1.id, + 'date': '2015-10-10', + 'chinese_sequence_type': False, + 'line_ids': [ + [0, 0, { + 'account_id': self.account1.id, + 'name': 'test', 'debit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'credit': 10}] + ]}) + # account code = 1001.01 + self.account_move8 = self.env['account.move'].create({ + 'journal_id': self.journal_2.id, + 'date': '2015-10-10', + 'chinese_sequence_type': False, + 'line_ids': [ + [0, 0, { + 'account_id': self.account1.id, + 'name': 'test', 'credit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'debit': 10}] + ]}) + # account code = 1002.01 + self.account_move9 = self.env['account.move'].create({ + 'journal_id': self.journal_1.id, + 'date': '2015-10-10', + 'chinese_sequence_type': False, + 'line_ids': [ + [0, 0, { + 'account_id': self.account2.id, + 'name': 'test', 'credit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'debit': 10}] + ]}) + # account code = 1002.01 + self.account_move10 = self.env['account.move'].create({ + 'journal_id': self.journal_2.id, + 'date': '2015-10-10', + 'chinese_sequence_type': False, + 'line_ids': [ + [0, 0, { + 'account_id': self.account2.id, + 'name': 'test', 'credit': 10}], + [0, 0, {'account_id': 2, 'name': 'test_2', 'debit': 10}] + ]}) + + def test_write(self): + """ Checks if the test_write works properly + """ + vals = { + } + self.account_move.write(vals) + self.assertFalse(vals.get('chinese_sequence_number', '')) + vals = { + 'state': 'posted' + } + self.account_move.write(vals) + self.assertTrue(vals.get('chinese_sequence_number', '')) + + def test_post(self): + """ Checks if the test_post works properly + """ + self.account_move1.post() + self.assertTrue(self.account_move1.chinese_sequence_number, '') + self.account_move2.post() + self.assertTrue(self.account_move2.chinese_sequence_number, '') + self.account_move3.post() + self.assertTrue(self.account_move3.chinese_sequence_number, '') + self.account_move4.post() + self.assertTrue(self.account_move4.chinese_sequence_number, '') + self.account_move5.post() + self.assertTrue(self.account_move5.chinese_sequence_number, '') + # chinese_sequence_type is False + self.account_move6.post() + self.assertTrue(self.account_move6.chinese_sequence_number, '') + self.account_move7.post() + self.assertTrue(self.account_move7.chinese_sequence_number, '') + self.account_move8.post() + self.assertTrue(self.account_move8.chinese_sequence_number, '') + self.account_move9.post() + self.assertTrue(self.account_move8.chinese_sequence_number, '') + self.account_move10.post() + self.assertTrue(self.account_move8.chinese_sequence_number, '') diff --git a/l10n_cn_sequence_voucher/views/account_journal.xml b/l10n_cn_sequence_voucher/views/account_journal.xml new file mode 100644 index 0000000..67711f6 --- /dev/null +++ b/l10n_cn_sequence_voucher/views/account_journal.xml @@ -0,0 +1,18 @@ + + + + + account.journal.form.inherit.elico + account.journal + + + + + + + + + + + + diff --git a/l10n_cn_sequence_voucher/views/account_move.xml b/l10n_cn_sequence_voucher/views/account_move.xml new file mode 100644 index 0000000..36dced2 --- /dev/null +++ b/l10n_cn_sequence_voucher/views/account_move.xml @@ -0,0 +1,17 @@ + + + + + + account.move.form.inherit.elico + account.move + + + + + + + + + + diff --git a/l10n_cn_sequence_voucher_manual/README.rst b/l10n_cn_sequence_voucher_manual/README.rst new file mode 100644 index 0000000..3c9b854 --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/README.rst @@ -0,0 +1,76 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +====================================================== +China Voucher Sequence Number Manual Generation Wizard +====================================================== + +This module extends the functionality of l10n_cn_account_voucher to support chinese voucher number generate manually. + +Installation +============ + +To install this module, you need to: + +# have basic modules installed (account, l10n_cn_sequence_voucher) + +Configuration +============= + +To configure this module, you need to: + +#. No specific configuration needed. + +Usage +===== + +To use this module, you need to: + +To generate the voucher number: + +* Go to Accounting/Adviser/Journal Entries +* Select Action/Generate Chinese Voucher Number + +.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt +.. branch is "8.0" for example + +Known issues / Roadmap +====================== + + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Matt.Cai 信熊大者得永生 + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/l10n_cn_sequence_voucher_manual/__init__.py b/l10n_cn_sequence_voucher_manual/__init__.py new file mode 100644 index 0000000..bd13c2b --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2016 cysnake4713@gmail.com +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import models diff --git a/l10n_cn_sequence_voucher_manual/__openerp__.py b/l10n_cn_sequence_voucher_manual/__openerp__.py new file mode 100644 index 0000000..d21638e --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# © 2016 cysnake4713@gmail.com +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': 'China Voucher Sequence Number Manual Generation Wizard', + 'summary': 'China Voucher Sequence Number Manual Generation Wizard', + 'version': '9.0.1.0.0', + 'category': 'Account', + 'author': 'cysnake4713@gmail.com, Odoo Community Association (OCA)', + "license": "AGPL-3", + 'email': 'cysnake4713@gmail.com', + 'application': False, + 'installable': True, + 'depends': [ + 'account', + 'l10n_cn_account_voucher', + ], + 'data': [ + 'views/voucher_wizard_view.xml', + ], +} diff --git a/l10n_cn_sequence_voucher_manual/i18n/zh_CN.po b/l10n_cn_sequence_voucher_manual/i18n/zh_CN.po new file mode 100644 index 0000000..5aab47c --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/i18n/zh_CN.po @@ -0,0 +1,153 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_cn_sequence_voucher_manual +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-03 08:53+0000\n" +"PO-Revision-Date: 2016-06-03 08:53+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model,name:l10n_cn_sequence_voucher_manual.model_account_voucher_sequence_generate_wizard +msgid "Account Voucher Sequence Generate Wizard" +msgstr "凭证号生成向导" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_number_begin +msgid "Begin Number" +msgstr "开始凭证号" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,help:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_number_begin +msgid "Begin number of Voucher" +msgstr "需要生成的凭证号码起始数字" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "Cancel" +msgstr "取消" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_create_uid +msgid "Created by" +msgstr "创建人" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_create_date +msgid "Created on" +msgstr "创建在" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_display_name +msgid "Display Name" +msgstr "显示名称" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "Generate" +msgstr "生成" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.actions.act_window,name:l10n_cn_sequence_voucher_manual.action_move_sequence_generate_wizard +msgid "Generate Chinese Voucher Number" +msgstr "生成中式会计凭证号" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "Generate Voucher Number Settings" +msgstr "凭证号设置" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_has_sequence_move_ids +msgid "Had Sequence Vouchers" +msgstr "已有凭证号" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "Has Number Vouchers" +msgstr "已有凭证号" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_id +msgid "ID" +msgstr "ID" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard___last_update +msgid "Last Modified on" +msgstr "最近修改日期" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_write_uid +msgid "Last Updated by" +msgstr "最后更新者" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_write_date +msgid "Last Updated on" +msgstr "最后更新时间" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "No Number Vouchers" +msgstr "没有凭证号" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_empty_sequence_move_ids +msgid "No Sequence Vouchers" +msgstr "没有凭证号" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,help:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_padding +msgid "Odoo will automatically adds some '0' on the left of the 'Begin Number' to get the required padding size." +msgstr "Odoo will automatically adds some '0' on the left of the 'Begin Number' to get the required padding size." + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_prefix +msgid "Prefix Code" +msgstr "预设起始字" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,help:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_prefix +msgid "Prefix value of the record for the Voucher sequence" +msgstr "Prefix value of the record for the Voucher sequence" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_is_rewrite +msgid "Rewrite Exist Number?" +msgstr "覆盖已有号码凭证号?" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_padding +msgid "Sequence Size" +msgstr "序列位数" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,field_description:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_suffix +msgid "Suffix Code" +msgstr "结尾预设字" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.model.fields,help:l10n_cn_sequence_voucher_manual.field_account_move_sequence_generate_wizard_suffix +msgid "Suffix value of the record for the Voucher" +msgstr "Suffix value of the record for the Voucher" + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "vouchers below already have chinese voucher number, will rewrite it." +msgstr "以下的凭证已有凭证号,勾选会重写他们." + +#. module: l10n_cn_sequence_voucher_manual +#: model:ir.ui.view,arch_db:l10n_cn_sequence_voucher_manual.view_move_sequence_generate_wizard_form +msgid "vouchers below will generate number by date." +msgstr "以下凭证将会按照日期重新生成凭证号." + diff --git a/l10n_cn_sequence_voucher_manual/models/__init__.py b/l10n_cn_sequence_voucher_manual/models/__init__.py new file mode 100644 index 0000000..9681c00 --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2016 cysnake4713@gmail.com +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import wizard diff --git a/l10n_cn_sequence_voucher_manual/models/wizard.py b/l10n_cn_sequence_voucher_manual/models/wizard.py new file mode 100644 index 0000000..9403bb3 --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/models/wizard.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# © 2016 cysnake4713@gmail.com +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openerp import tools +from openerp import models, fields, api +from openerp.tools.translate import _ + + +class AccountMoveSequenceGenerationWizard(models.TransientModel): + _name = 'account.move.sequence.generate.wizard' + _rec_name = 'prefix' + _description = 'Account Voucher Sequence Generation Wizard' + + prefix = fields.Char('Prefix Code', help="Prefix for the Voucher sequence", default='记') + suffix = fields.Char('Suffix Code', help="Suffix for the Voucher sequence") + number_begin = fields.Integer('Starting number', required=True, default=1, help="Begin number of Voucher") + padding = fields.Integer('Sequence Padding', required=True, default=3, + help="Odoo will automatically adds some '0' on the left of the " + "'Starting Number' to get the required padding size.") + is_rewrite = fields.Boolean('Rewriting Existing Number?', default=False) + has_sequence_move_ids = fields.Many2many('account.move', 'move_has_sequence_wizard_voucher_rel', 'wizard_id', 'move_id', + string='Had Sequence Vouchers', readonly=True) + empty_sequence_move_ids = fields.Many2many('account.move', 'move_empty_sequence_wizard_voucher_rel', 'wizard_id', 'move_id', + string='No Sequence Vouchers', readonly=True) + + @api.model + def default_get(self, fields_list): + result = super(AccountMoveSequenceGenerationWizard, self).default_get(fields_list) + if self._context.get('active_ids'): + move_ids = self._context['active_ids'] + empty_seq_move_ids = self.env['account.move'].search([('id', 'in', move_ids), ('chinese_sequence_number', '=', False)]).ids + has_seq_move_ids = self.env['account.move'].search([('id', 'in', move_ids), ('chinese_sequence_number', '!=', False)]).ids + result['has_sequence_move_ids'] = has_seq_move_ids + result['empty_sequence_move_ids'] = empty_seq_move_ids + return result + + @api.multi + def button_generate_number(self): + format_string = (self.prefix or '') + '%0' + str(self.padding) + 'd' + (self.suffix or '') + move_ids = self.empty_sequence_move_ids.ids + if self.is_rewrite: + move_ids += self.has_sequence_move_ids.ids + number = self.number_begin + for account_move in self.env['account.move'].search([('id', 'in', move_ids)], order='date asc, id asc'): + account_move.chinese_sequence_number = format_string % number + number += 1 diff --git a/l10n_cn_sequence_voucher_manual/views/voucher_wizard_view.xml b/l10n_cn_sequence_voucher_manual/views/voucher_wizard_view.xml new file mode 100644 index 0000000..e3eeae6 --- /dev/null +++ b/l10n_cn_sequence_voucher_manual/views/voucher_wizard_view.xml @@ -0,0 +1,69 @@ + + + + + Generate Chinese Voucher Number + account.move.sequence.generate.wizard + form + + + + + + + view.account.move.sequence.generate.wizard.form + account.move.sequence.generate.wizard + +
+ + + + + + + + +
Vouchers below already have Chinese voucher number and will be overwritten.
+ + + + + + + + + + + +
+ +
For the voucher below, sequence will be generated by order of date.
+ + + + + + + + + + +
+
+ +
+
+
+
+
\ No newline at end of file