@@ -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
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
|
||||
<menuitem id="menu_finance_reporting" name="Reporting" parent="account.menu_finance" sequence="8"/>
|
||||
<menuitem id="menu_finance_legal_statement" name="Legal Statements" parent="account.menu_finance" sequence="8"/>
|
||||
<menuitem id="menu_generic_report" name="Generic Reports" parent="account.menu_finance_legal_statement" sequence="8"/>
|
||||
|
||||
<menuitem id="menu_finance_entries" name="Entries Encoding" parent="account.menu_finance" sequence="2"/>
|
||||
<menuitem id="account.menu_finance_recurrent_entries" name="Recurrent Entries" parent="account.menu_finance_entries" sequence="15"/>
|
||||
|
||||
<menuitem id="menu_finance_periodical_processing" name="Periodical Processing" parent="account.menu_finance" sequence="3"/>
|
||||
<menuitem id="menu_account_end_year_treatments" name="End of Year Treatments" parent="account.menu_finance_periodical_processing" sequence="20"/>
|
||||
<menuitem id="menu_generic_report" name="Generic Reports" parent="account.menu_finance" sequence="8"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -10,7 +10,7 @@ This module install:
|
||||
*the KLUWER Chart of Accounts,
|
||||
*the Tax Code Chart for Luxembourg
|
||||
*the main taxes used in Luxembourg""",
|
||||
"depends" : ["account","account_report"],
|
||||
"depends" : ["account","account_report","base_vat","base_iban"],
|
||||
"init_xml" : [ ],
|
||||
"demo_xml" : [ "account.report.report.csv" ],
|
||||
"update_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"/>
|
||||
|
||||
<menuitem
|
||||
id="legal_lu_vat"
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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:
|
||||
|
||||
@@ -15,6 +15,7 @@ import tools
|
||||
from report.render import render
|
||||
from report.interface import report_int
|
||||
import os
|
||||
import pdf_ext
|
||||
|
||||
_tax_form = """<?xml version="1.0"?>
|
||||
<form string="VAT Legal Declaration">
|
||||
@@ -50,17 +51,28 @@ class report_custom(report_int):
|
||||
def create(self, cr, uid, ids, datas, context={}):
|
||||
print datas, ids, uid
|
||||
|
||||
taxobj = self.pool.get('account.tax.code')
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
taxobj = pool.get('account.tax.code')
|
||||
code_ids = taxobj.search(cr, uid, [('parent_id','child_of',[datas['form']['tax_code_id']])])
|
||||
result = {}
|
||||
for t in taxobj.browse(cr, uid, code_ids, {'period_id': datas['form']['period_id']}):
|
||||
if t.code:
|
||||
result[t.code] = t.sum_period
|
||||
os.system('pdftk... output /tmp/tax.pdf')
|
||||
self.obj = external_pdf(file('/tmp/tax.pdf').read())
|
||||
self.obj.render()
|
||||
result['case_'+str(t.code)] = '%.2f' % (t.sum_period or 0.0, )
|
||||
|
||||
pdf_string.close()
|
||||
user = pool.get('res.users').browse(cr, uid, uid, context)
|
||||
|
||||
# Not Clean, to be changed
|
||||
partner = user.company_id.partner_id
|
||||
result['info_name'] = user.company_id.name
|
||||
result['info_vatnum'] = partner.vat
|
||||
if partner.address:
|
||||
result['info_address'] = partner.address[0].street
|
||||
result['info_address2'] = str(partner.address[0].zip) + ' ' + str(partner.address[0].city)
|
||||
|
||||
pdf_ext.fill_pdf('addons/l10n_lu/wizard/2008_DECL_F_M10.pdf', '/tmp/output.pdf', result)
|
||||
self.obj = external_pdf(file('/tmp/output.pdf').read())
|
||||
self.obj.render()
|
||||
return (self.obj.pdf, 'pdf')
|
||||
|
||||
report_custom('report.l10n_lu.tax.report.print')
|
||||
@@ -70,7 +82,7 @@ class wizard_report(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':_tax_form, 'fields':_tax_fields, 'state':[('end','Cancel'),('pdf','Print Balance Sheet')]},
|
||||
'result': {'type':'form', 'arch':_tax_form, 'fields':_tax_fields, 'state':[('end','Cancel'),('pdf','Print VAT Declaration')]},
|
||||
},
|
||||
'pdf': {
|
||||
'actions': [],
|
||||
|
||||
Reference in New Issue
Block a user