Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

l10n_cn_account_voucher: add a new way to generate chinese voucher number #18

Open
wants to merge 10 commits into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions l10n_cn_account_voucher/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/l10n-china/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 <https://github.com/OCA/l10n-china/issues/new?body=module:%20l10n_cn_account_voucher%0Aversion:%20{9.0}%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======


Contributors
------------

* Jeff/开阖软件 <[email protected]>
* Matt.Cai <[email protected]>
* hdjmd <[email protected]>
* Luke Zheng <[email protected]>


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.
5 changes: 5 additions & 0 deletions l10n_cn_account_voucher/__init__.py
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions l10n_cn_account_voucher/__openerp__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
62 changes: 62 additions & 0 deletions l10n_cn_account_voucher/i18n/zh_CN.po
Original file line number Diff line number Diff line change
@@ -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"

5 changes: 5 additions & 0 deletions l10n_cn_account_voucher/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
135 changes: 135 additions & 0 deletions l10n_cn_account_voucher/models/account_move.py
Original file line number Diff line number Diff line change
@@ -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
Loading