diff --git a/addons/account_check_writing/__init__.py b/addons/account_check_writing/__init__.py new file mode 100644 index 00000000000..0451b2bdb6a --- /dev/null +++ b/addons/account_check_writing/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import account +import account_voucher +import wizard +import report +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_check_writing/__openerp__.py b/addons/account_check_writing/__openerp__.py new file mode 100644 index 00000000000..c09288f6955 --- /dev/null +++ b/addons/account_check_writing/__openerp__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name" : "Check writing", + "version" : "1.1", + "author" : "OpenERP SA, NovaPoint Group", + "category": "Generic Modules/Accounting", + "description": """ + Module for the Check writing and check printing + """, + 'website': 'http://www.openerp.com', + 'init_xml': [], + "depends" : [ + "account_voucher", + ], + 'update_xml': [ + 'account_check_writing_report.xml', + 'account_view.xml', + 'account_voucher_view.xml', + 'account_check_writing_data.xml', + ], + 'demo_xml': [ + 'account_demo.xml', + ], + 'test': [ + ], + 'installable': True, + 'active': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_check_writing/account.py b/addons/account_check_writing/account.py new file mode 100644 index 00000000000..4dbbc245033 --- /dev/null +++ b/addons/account_check_writing/account.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv,fields + +class account_journal(osv.osv): + _inherit = "account.journal" + + _columns = { + 'allow_check_writing': fields.boolean('Allow Check writing', help='Check this if the journal is to be used for writing checks.'), + 'use_preprint_check': fields.boolean('Use Preprinted Check'), + } + +account_journal() + +class res_company(osv.osv): + _inherit = "res.company" + _columns = { + 'check_layout': fields.selection([ + ('top', 'Check on Top'), + ('middle', 'Check in middle'), + ('bottom', 'Check on bottom'), + ],"Choose Check layout", + help="Check on top is compatible with Quicken, QuickBooks and Microsoft Money. Check in middle is compatible with Peachtree, ACCPAC and DacEasy. Check on bottom is compatible with Peachtree, ACCPAC and DacEasy only" ), + } + + _defaults = { + 'check_layout' : lambda *a: 'top', + } + +res_company() +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_check_writing/account_check_writing_data.xml b/addons/account_check_writing/account_check_writing_data.xml new file mode 100644 index 00000000000..324967836c2 --- /dev/null +++ b/addons/account_check_writing/account_check_writing_data.xml @@ -0,0 +1,15 @@ + + + + + Check Number + check.number + + + + Check Number + check.number + + + + diff --git a/addons/account_check_writing/account_check_writing_report.xml b/addons/account_check_writing/account_check_writing_report.xml new file mode 100644 index 00000000000..062827d3aa2 --- /dev/null +++ b/addons/account_check_writing/account_check_writing_report.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + diff --git a/addons/account_check_writing/account_demo.xml b/addons/account_check_writing/account_demo.xml new file mode 100644 index 00000000000..d4d772f597a --- /dev/null +++ b/addons/account_check_writing/account_demo.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/addons/account_check_writing/account_view.xml b/addons/account_check_writing/account_view.xml new file mode 100644 index 00000000000..529bfab2537 --- /dev/null +++ b/addons/account_check_writing/account_view.xml @@ -0,0 +1,42 @@ + + + + + + + + account.journal.form + account.journal + form + + + + + + + + + + + + + + res.company.check.format + res.company + form + 17 + + + + + + + + + + + diff --git a/addons/account_check_writing/account_voucher.py b/addons/account_check_writing/account_voucher.py new file mode 100644 index 00000000000..5d1d08018a8 --- /dev/null +++ b/addons/account_check_writing/account_voucher.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv,fields +from tools.translate import _ +from tools.amount_to_text_en import amount_to_text +from lxml import etree + +check_layout_report = { + 'top' : 'account.print.check.top', + 'middle' : 'account.print.check.middle', + 'bottom' : 'account.print.check.bottom', +} + +class account_voucher(osv.osv): + _inherit = 'account.voucher' + + def _get_journal(self, cr, uid, context=None): + + if context is None: context = {} + + journal_pool = self.pool.get('account.journal') + invoice_pool = self.pool.get('account.invoice') + + if context.get('invoice_id', False): + currency_id = invoice_pool.browse(cr, uid, context['invoice_id'], context=context).currency_id.id + journal_id = journal_pool.search(cr, uid, [('currency', '=', currency_id)], limit=1) + return journal_id and journal_id[0] or False + + if context.get('journal_id', False): + return context.get('journal_id') + + if not context.get('journal_id', False) and context.get('search_default_journal_id', False): + return context.get('search_default_journal_id') + + ttype = context.get('type', 'bank') + + if ttype in ('payment', 'receipt'): + ttype = 'bank' + if context.get('write_check',False) : + res = journal_pool.search(cr, uid, [('allow_check_writing', '=', True)], limit=1) + else : + res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) + return res and res[0] or False + + _columns = { + 'amount_in_word' : fields.char("Amount in word" , size=128, readonly=True, states={'draft':[('readonly',False)]}), + 'allow_check' : fields.boolean('Allow Check Writing'), + 'number': fields.char('Number', size=32), + } + + _defaults = { + 'journal_id':_get_journal, + } + + def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None): + """ Inherited - add amount_in_word in return value dictionary """ + + if not context: + context = {} + default = super(account_voucher, self).onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context) + if 'value' in default: + amount = 'amount' in default['value'] and default['value']['amount'] or price + + #TODO : generic amount_to_text is not ready yet, otherwise language and currency can be passed + + amount_in_word = amount_to_text(amount) + default['value'].update({'amount_in_word':amount_in_word}) + + if journal_id: + allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id).allow_check_writing + default['value'].update({'allow_check':allow_check_writing}) + + return default + + def print_check(self, cr, uid, ids, context=None): + if not ids: return [] + + check_layout = self.browse(cr, uid, ids[0], context=context).company_id.check_layout + + return { + 'type': 'ir.actions.report.xml', + 'report_name':check_layout_report[check_layout], + 'datas': { + 'model':'account.voucher', + 'id': ids and ids[0] or False, + 'ids': ids and ids or [], + 'report_type': 'pdf' + }, + 'nodestroy': True + } + + def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): + res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) + doc = etree.XML(res['arch']) + nodes = doc.xpath("//field[@name='journal_id']") + if context.get('write_check', False) : + for node in nodes: + node.set('domain', "[('type', '=', 'bank')]") + res['arch'] = etree.tostring(doc) + return res + +account_voucher() diff --git a/addons/account_check_writing/account_voucher_view.xml b/addons/account_check_writing/account_voucher_view.xml new file mode 100644 index 00000000000..65d388ab42b --- /dev/null +++ b/addons/account_check_writing/account_voucher_view.xml @@ -0,0 +1,56 @@ + + + + + + + + account.voucher.payment.check.form + account.voucher + form + + + + + + + + + + + + + + + + + Write Checks + account.voucher + form + form,tree + [('journal_id.type', '=', 'bank'), ('type','=','payment'), ('journal_id.allow_check_writing','=',True)] + {'type':'payment','write_check':True} + + current + The check payment form allows you to track the payment you do to your suppliers specially by check. When you select a supplier, the payment method and an amount for the payment, OpenERP will propose to reconcile your payment with the open supplier invoices or bills.You can print the check + + + + + form + + + + + + + tree + + + + + + diff --git a/addons/account_check_writing/report/__init__.py b/addons/account_check_writing/report/__init__.py new file mode 100644 index 00000000000..e160380caea --- /dev/null +++ b/addons/account_check_writing/report/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import check_print + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/account_check_writing/report/check_print.py b/addons/account_check_writing/report/check_print.py new file mode 100644 index 00000000000..e0460964be5 --- /dev/null +++ b/addons/account_check_writing/report/check_print.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +from report import report_sxw +from tools import amount_to_text_en + +class report_print_check(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(report_print_check, self).__init__(cr, uid, name, context) + self.number_lines = 0 + self.number_add = 0 + self.localcontext.update({ + 'time': time, + 'get_lines': self.get_lines, + 'fill_stars' : self.fill_stars, + 'get_zip_line': self.get_zip_line, + }) + def fill_stars(self, amount): + amount = amount.replace('Dollars','') + if len(amount) < 100: #TODO + stars = 100 - len(amount) + return ' '.join([amount,'*'*stars]) + + else: return amount + + def get_zip_line(self, address): + ''' + Get the address line + ''' + ret = '' + if address: + if address.city: + ret += address.city + if address.state_id: + if address.state_id.name: + if ret: + ret += ', ' + ret += address.state_id.name + if address.zip: + if ret: + ret += ' ' + ret += address.zip + return ret + + def get_lines(self, voucher_lines): + result = [] + self.number_lines = len(voucher_lines) + print "==============",voucher_lines + for i in range(0, min(10,self.number_lines)): + if i < self.number_lines: + res = { + 'date_due' : voucher_lines[i].date_due, + 'name' : voucher_lines[i].name, + 'amount_original' : voucher_lines[i].amount_original and voucher_lines[i].amount_original or False, + 'amount_unreconciled' : voucher_lines[i].amount_unreconciled and voucher_lines[i].amount_unreconciled or False, + 'amount' : voucher_lines[i].amount and voucher_lines[i].amount or False, + } + else : + res = { + 'date_due' : False, + 'name' : False, + 'amount_original' : False, + 'amount_due' : False, + 'amount' : False, + } + result.append(res) + return result + +report_sxw.report_sxw( + 'report.account.print.check.top', + 'account.voucher', + 'addons/account_check_writing/report/check_print_top.rml', + parser=report_print_check,header=False +) + +report_sxw.report_sxw( + 'report.account.print.check.middle', + 'account.voucher', + 'addons/account_check_writing/report/check_print_middle.rml', + parser=report_print_check,header=False +) + +report_sxw.report_sxw( + 'report.account.print.check.bottom', + 'account.voucher', + 'addons/account_check_writing/report/check_print_bottom.rml', + parser=report_print_check,header=False +) +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_check_writing/report/check_print_bottom.rml b/addons/account_check_writing/report/check_print_bottom.rml new file mode 100644 index 00000000000..231edb65547 --- /dev/null +++ b/addons/account_check_writing/report/check_print_bottom.rml @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[repeatIn(objects,'voucher')]] + + + + + + + [[voucher.partner_id.name]] + + + [[ formatLang(voucher.date , date=True) or '' ]] [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + Due Date + + + Description + + + Original Amount + + + Balance Due + + + Discount + + + Payment + + + + + [[ repeatIn(get_lines(voucher.line_dr_ids),'l') ]] [[ formatLang(l['date_original'] ,date=True) or '' ]] + + + [[ l['name'] ]] + + + [[formatLang( l['amount_original']) ]] + + + [[ formatLang( l['amount_due']) ]] + + + + + + + + [[ formatLang (l['amount']) ]] + + + + + + + Check Amount + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + + + + + [[voucher.partner_id.name]] + + + [[ formatLang(voucher.date , date=True) or '' ]] [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + Due Date + + + Description + + + Original Amount + + + Balance Due + + + Discount + + + Payment + + + + + [[ repeatIn(get_lines(voucher.line_dr_ids),'l') ]] [[ formatLang(l['date_original'] ,date=True) or '' ]] + + + [[ l['name'] ]] + + + [[ formatLang (l['amount_original']) ]] + + + [[ formatLang (l['amount_due']) ]] + + + + + + + + [[ formatLang (l['amount']) ]] + + + + + + + Check Amount + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + + + + + + + + + + + + + [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + + [[ formatLang(voucher.date , date=True) or '' ]] + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + [[ voucher.partner_id.name ]] + [[ voucher.partner_id.address and voucher.partner_id.address[0] and voucher.partner_id.address[0].street or removeParentNode('para') ]] + [[ voucher.partner_id.address and voucher.partner_id.address[0] and voucher.partner_id.address[0].street2 or removeParentNode('para') ]] + [[ get_zip_line(voucher.partner_id.address) ]] + [[ voucher.partner_id.address[0].country_id.name]] + + + + + + + [[ fill_stars(voucher.amount_in_word) ]] + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/addons/account_check_writing/report/check_print_middle.rml b/addons/account_check_writing/report/check_print_middle.rml new file mode 100644 index 00000000000..a6416f9aeb2 --- /dev/null +++ b/addons/account_check_writing/report/check_print_middle.rml @@ -0,0 +1,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[repeatIn(objects,'voucher')]] + + + + + + + + + + [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + [[voucher.partner_id.name]] + + + [[ formatLang(voucher.date , date=True) or '' ]] + + + + + + + Due Date + + + Description + + + Original Amount + + + Balance Due + + + Discount + + + Payment + + + + + [[ repeatIn(get_lines(voucher.line_dr_ids),'l') ]] [[ formatLang(l['date_original'] ,date=True) or '' ]] + + + [[ l['name'] ]] + + + [[formatLang( l['amount_original']) ]] + + + [[ formatLang( l['amount_due']) ]] + + + + + + + + [[ formatLang (l['amount']) ]] + + + + + + + Check Amount + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + + + + [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + + + + + + + [[ str(fill_stars(voucher.amount_in_word)) ]] + + + + + + + + + + + + + + + + + + + + + + + + [[ formatLang(voucher.date , date=True) or '' ]] + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + [[ voucher.partner_id.name ]] + [[ voucher.partner_id.address and voucher.partner_id.address[0] and voucher.partner_id.address[0].street or removeParentNode('para') ]] + [[ voucher.partner_id.address and voucher.partner_id.address[0] and voucher.partner_id.address[0].street2 or removeParentNode('para') ]] + [[ get_zip_line(voucher.partner_id.address) ]] + [[ voucher.partner_id.address[0].country_id.name]] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[voucher.partner_id.name]] + + + [[ formatLang(voucher.date , date=True) or '' ]] + + + [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + Due Date + + + Description + + + Original Amount + + + Balance Due + + + Discount + + + Payment + + + + + [[ repeatIn(get_lines(voucher.line_dr_ids),'l') ]] [[ formatLang(l['date_original'] ,date=True) or '' ]] + + + [[ l['name'] ]] + + + [[ formatLang (l['amount_original']) ]] + + + [[ formatLang (l['amount_due']) ]] + + + + + + + + [[ formatLang (l['amount']) ]] + + + + + + + Check Amount + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + + + diff --git a/addons/account_check_writing/report/check_print_top.rml b/addons/account_check_writing/report/check_print_top.rml new file mode 100644 index 00000000000..a5068617ebe --- /dev/null +++ b/addons/account_check_writing/report/check_print_top.rml @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[repeatIn(objects,'voucher')]] + + + + + + + + + + + + + + + + + + + + + + + + [[ formatLang(voucher.date , date=True) or '' ]] [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + + + + + + [[ voucher.partner_id.name ]] + + + [[ formatLang (voucher.amount) ]] + + + + + + + [[ fill_stars(voucher.amount_in_word) ]] + + + + + + + + + + [[ voucher.partner_id.name ]] + [[ voucher.partner_id.address and voucher.partner_id.address[0] and voucher.partner_id.address[0].street2 or removeParentNode('para') ]] + [[ get_zip_line(voucher.partner_id.address[0]) ]] + [[ voucher.partner_id.address[0].country_id.name]] + + + + + + + + + + + + + + + [[ voucher.name ]] + + + + + + + + + + + + + + + + + + + + + [[voucher.partner_id.name]] + + + [[ formatLang(voucher.date , date=True) or '' ]] [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + Due Date + + + Description + + + Original Amount + + + Open Balance + + + Discount + + + Payment + + + + + [[ repeatIn(get_lines(voucher.line_dr_ids),'l') ]] [[ formatLang(l['date_due'] ,date=True) or '' ]] + + + [[ l['name'] ]] + + + [[formatLang( l['amount_original']) ]] + + + [[ formatLang( l['amount_unreconciled']) ]] + + + + + + + + [[ formatLang (l['amount']) ]] + + + + + + + Check Amount + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + + + + + [[voucher.partner_id.name]] + + + [[ formatLang(voucher.date , date=True) or '' ]] [[ voucher.journal_id.use_preprint_check and voucher.chk_seq or '' ]] + + + + + + + Due Date + + + Description + + + Original Amount + + + Open Balance + + + Discount + + + Payment + + + + + [[ repeatIn(get_lines(voucher.line_dr_ids),'l') ]] [[ formatLang(l['date_due'] ,date=True) or '' ]] + + + [[ l['name'] ]] + + + [[ formatLang (l['amount_original']) ]] + + + [[ formatLang (l['amount_unreconciled']) ]] + + + + + + + + [[ formatLang (l['amount']) ]] + + + + + + + Check Amount + + + [[ formatLang (voucher.amount) ]] + + + + + + + + + + + + + +