From 953dcda1a755c55fd8f5d73403453291a5aadb05 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 14 Oct 2008 16:43:52 +0200 Subject: [PATCH 1/5] merge bzr revid: fp@tinyerp.com-20081014144352-m1ecje3upr5d5d31 --- addons/l10n_lu/wizard/pdf_ext.py | 103 +++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 addons/l10n_lu/wizard/pdf_ext.py diff --git a/addons/l10n_lu/wizard/pdf_ext.py b/addons/l10n_lu/wizard/pdf_ext.py new file mode 100644 index 00000000000..200fa813218 --- /dev/null +++ b/addons/l10n_lu/wizard/pdf_ext.py @@ -0,0 +1,103 @@ +# -*- encoding: utf-8 -*- +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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 General Public License for more details +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +""" Copyright (c) 2003-2007 LOGILAB S.A. (Paris, FRANCE). + http://www.logilab.fr/ -- mailto:contact@logilab.fr + +manipulate pdf and fdf files. pdftk recommended. + +Notes regarding pdftk, pdf forms and fdf files (form definition file) +fields names can be extracted with: + pdftk orig.pdf generate_fdf output truc.fdf +to merge fdf and pdf: + pdftk orig.pdf fill_form test.fdf output result.pdf [flatten] +without flatten, one could further edit the resulting form. +with flatten, everything is turned into text. +""" + +import os +import tools + +HEAD="""%FDF-1.2 +%\xE2\xE3\xCF\xD3 +1 0 obj +<< +/FDF +<< +/Fields [ +""" + +TAIL="""] +>> +>> +endobj +trailer + +<< +/Root 1 0 R +>> +%%EOF +""" + +def output_field( f ): + return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] ) + +def extract_keys(lines): + keys = [] + for line in lines: + if line.startswith('/V'): + pass #print 'value',line + elif line.startswith('/T'): + key = line[7:-2] + key = ''.join(key.split('\x00')) + keys.append( key ) + return keys + +def write_field(out, key, value): + out.write("<<\n") + if value: + out.write("/V (%s)\n" %value) + else: + out.write("/V /\n") + out.write("/T (%s)\n" % output_field(key) ) + out.write(">> \n") + +def write_fields(out, fields): + out.write(HEAD) + for key in fields: + value = fields[key] + write_field(out, key, value) +# write_field(out, key+"a", value) # pour copie-carbone sur autres pages + out.write(TAIL) + +def extract_keys_from_pdf(filename): + # what about using 'pdftk filename dump_data_fields' and parsing the output ? + os.system('pdftk %s generate_fdf output /tmp/toto.fdf' % filename) + lines = file('/tmp/toto.fdf').readlines() + return extract_keys(lines) + + +def fill_pdf(infile, outfile, fields): + write_fields(file('/tmp/toto.fdf', 'w'), fields) + os.system('pdftk %s fill_form /tmp/toto.fdf output %s flatten' % (infile, outfile)) + +def testfill_pdf(infile, outfile): + keys = extract_keys_from_pdf(infile) + fields = [] + for key in keys: + fields.append( (key, key, '') ) + fill_pdf(infile, outfile, fields) + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + From ea5bbc2be403a371f7654dfb82e2d1f53b1bffe4 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 14 Oct 2008 16:44:30 +0200 Subject: [PATCH 2/5] lu bzr revid: fp@tinyerp.com-20081014144430-hd1bvcvu6gnkk13f --- addons/l10n_lu/l10n_lu_wizard.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_lu/l10n_lu_wizard.xml b/addons/l10n_lu/l10n_lu_wizard.xml index 127ff4a0ce1..dd16b17d429 100644 --- a/addons/l10n_lu/l10n_lu_wizard.xml +++ b/addons/l10n_lu/l10n_lu_wizard.xml @@ -19,7 +19,7 @@ This is the same wizard that runs from Financial Managament/Configuration/Financ id="wizard_print_vat" menu="False" model="account.tax.code" - name="l10n_lu.tax.report.wizard" string="Luxemburg VAT Declaration"/> + name="l10n_lu.tax.report.wizard" string="VAT Declaration"/> Date: Tue, 14 Oct 2008 16:51:51 +0200 Subject: [PATCH 3/5] *changed structure of menuitem bzr revid: qdp@tinyerp.com-20081014145151-lmh64c22hjx9q2u3 --- addons/account/account_menuitem.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/account_menuitem.xml b/addons/account/account_menuitem.xml index 9b3726b5c40..a9500a37187 100644 --- a/addons/account/account_menuitem.xml +++ b/addons/account/account_menuitem.xml @@ -10,12 +10,13 @@ + - + From 0f77409530c1efb027d8e7a7a6795c9167b6b727 Mon Sep 17 00:00:00 2001 From: qdp Date: Tue, 14 Oct 2008 17:01:23 +0200 Subject: [PATCH 4/5] *bugfixed the chart generation from a chart template bzr revid: qdp@tinyerp.com-20081014150123-xs4zvgy2tzce34qw --- addons/account/account.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 729037102b3..fee6d951e9a 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1953,8 +1953,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): for key,value in todo_dict.items(): if value['account_collected_id'] or value['account_paid_id']: obj_acc_tax.write(cr, uid, [key], vals={ - 'account_collected_id': value['account_collected_id'], - 'account_paid_id': value['account_paid_id'], + 'account_collected_id': acc_template_ref[value['account_collected_id']], + 'account_paid_id': acc_template_ref[value['account_paid_id']], }) # Creating Journals From 9aded621bd4617f870c450297866ebba25412065 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 14 Oct 2008 17:05:12 +0200 Subject: [PATCH 5/5] date invoice fix bzr revid: fp@tinyerp.com-20081014150512-xkxgkl0lwb5e4n0i --- addons/account/invoice.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index b81c624ded4..611ebf7fe84 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -171,7 +171,7 @@ class account_invoice(osv.osv): ('cancel','Canceled') ],'State', select=True, readonly=True), - 'date_invoice': fields.date('Date Invoiced', required=True, states={'open':[('readonly',True)],'close':[('readonly',True)]}), + 'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)],'close':[('readonly',True)]}), 'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}), @@ -203,7 +203,7 @@ class account_invoice(osv.osv): } _defaults = { 'type': _get_type, - 'date_invoice': lambda *a: time.strftime('%Y-%m-%d'), + #'date_invoice': lambda *a: time.strftime('%Y-%m-%d'), 'state': lambda *a: 'draft', 'journal_id': _get_journal, 'currency_id': _get_currency, @@ -332,9 +332,9 @@ class account_invoice(osv.osv): if default is None: default = {} default = default.copy() - default.update({'state':'draft', 'number':False, 'move_id':False,}) + default.update({'state':'draft', 'number':False, 'move_id':False}) if 'date_invoice' not in default: - default['date_invoice'] = time.strftime('%Y-%m-%d') + default['date_invoice'] = False if 'date_due' not in default: default['date_due'] = False return super(account_invoice, self).copy(cr, uid, id, default, context) @@ -428,6 +428,8 @@ class account_invoice(osv.osv): continue if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0): raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.')) + if not inv.date_invoice: + self.write(cr, uid, [inv.id], {'date_invoice':time.strftime('%Y-%m-%d')}) company_currency = inv.company_id.currency_id.id # create the analytical lines line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line'] @@ -473,7 +475,7 @@ class account_invoice(osv.osv): i['amount_currency'] = i['price'] i['price'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, i['price'], - context={'date': inv.date_invoice}) + context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}) else: i['amount_currency'] = False i['currency_id'] = False @@ -534,7 +536,7 @@ class account_invoice(osv.osv): 'ref': ref }) - date = inv.date_invoice + date = inv.date_invoice or time.strftime('%Y-%m-%d') part = inv.partner_id.id line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})) ,iml) @@ -549,7 +551,7 @@ class account_invoice(osv.osv): move = {'name': name, 'line_id': line, 'journal_id': journal_id} period_id=inv.period_id and inv.period_id.id or False if not period_id: - period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice),('date_stop','>=',inv.date_invoice)]) + period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))]) if len(period_ids): period_id=period_ids[0] if period_id: