From 0cf43b7857b45455be2076b52c99f5fa84f1a70d Mon Sep 17 00:00:00 2001 From: "Ferdinand @ Camptocamp" <> Date: Wed, 13 Apr 2011 13:02:11 +0530 Subject: [PATCH 01/43] [FIX] account: Improved invoice analysis report for calculation of total without tax lp bug: https://launchpad.net/bugs/748178 fixed bzr revid: pso@tinyerp.com-20110413073211-nktkleb1izezr7o0 --- .../account/report/account_invoice_report.py | 59 +++++++++++-------- .../report/account_invoice_report_view.xml | 4 +- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 9c7cf014e4d..4815b00ba25 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -69,6 +69,7 @@ class account_invoice_report(osv.osv): 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True), 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True), 'account_id': fields.many2one('account.account', 'Account',readonly=True), + 'account_line_id': fields.many2one('account.account', 'Account Line',readonly=True), 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True), 'residual': fields.float('Total Residual', readonly=True), 'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"), @@ -106,44 +107,48 @@ class account_invoice_report(osv.osv): ai.address_contact_id as address_contact_id, ai.address_invoice_id as address_invoice_id, ai.account_id as account_id, + ail.account_id as account_line_id, ai.partner_bank_id as partner_bank_id, sum(case when ai.type in ('out_refund','in_invoice') then - ail.quantity / u.factor * -1 + -ail.quantity / u.factor else ail.quantity / u.factor end) as product_qty, + sum(case when ai.type in ('out_refund','in_invoice') then - ail.quantity*ail.price_unit * -1 + -ail.price_subtotal else - ail.quantity*ail.price_unit + ail.price_subtotal end) / cr.rate as price_total, + +-- +-- FIXME the line total incl tax can't be caculated by deviding the invoice total / number of lines +-- sum(case when ai.type in ('out_refund','in_invoice') then - ai.amount_total * -1 + -ai.amount_total else ai.amount_total - end) / (CASE WHEN + end) / (CASE WHEN (select count(l.id) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) - where a.id=ai.id) <> 0 - THEN + where a.id=ai.id) <> 0 + THEN (select count(l.id) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) - where a.id=ai.id) - ELSE 1 + where a.id=ai.id) + ELSE 1 END) / cr.rate as price_total_tax, + (case when ai.type in ('out_refund','in_invoice') then - sum(ail.quantity*ail.price_unit*-1) + sum(-ail.price_subtotal) else - sum(ail.quantity*ail.price_unit) - end) / (CASE WHEN - (case when ai.type in ('out_refund','in_invoice') - then sum(ail.quantity/u.factor*-1) - else sum(ail.quantity/u.factor) end) <> 0 - THEN - (case when ai.type in ('out_refund','in_invoice') - then sum(ail.quantity/u.factor*-1) - else sum(ail.quantity/u.factor) end) - ELSE 1 + sum(ail.price_subtotal) + end) / (CASE WHEN sum(ail.quantity/u.factor) <> 0 + THEN + (case when ai.type in ('out_refund','in_invoice') + then sum(-ail.quantity/u.factor) + else sum(ail.quantity/u.factor) end) + ELSE 1 END) / cr.rate as price_average, @@ -159,22 +164,23 @@ class account_invoice_report(osv.osv): left join account_invoice_line as l ON (a.id=l.invoice_id) where a.id=ai.id)) as due_delay, (case when ai.type in ('out_refund','in_invoice') then - ai.residual * -1 + -ai.residual else ai.residual - end)/ (CASE WHEN + end)/ (CASE WHEN (select count(l.id) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) - where a.id=ai.id) <> 0 + where a.id=ai.id) <> 0 THEN (select count(l.id) from account_invoice_line as l left join account_invoice as a ON (a.id=l.invoice_id) - where a.id=ai.id) - ELSE 1 + where a.id=ai.id) + ELSE 1 END) / cr.rate as residual from account_invoice_line as ail left join account_invoice as ai ON (ai.id=ail.invoice_id) - left join product_template pt on (pt.id=ail.product_id) + left join product_product pr on (pr.id=ail.product_id) + left join product_template pt on (pt.id=pr.product_tmpl_id) left join product_uom u on (u.id=ail.uos_id), res_currency_rate cr where cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id) @@ -202,6 +208,7 @@ class account_invoice_report(osv.osv): ai.address_contact_id, ai.address_invoice_id, ai.account_id, + ail.account_id, ai.partner_bank_id, ai.residual, ai.amount_total, diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 6c1bc3f9762..a0a9729a775 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -27,10 +27,10 @@ + - @@ -103,6 +103,7 @@ + @@ -120,6 +121,7 @@ + From 8f3c2558ff8e5059b3d24c5d575e43d4b724d6da Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Tue, 3 May 2011 17:52:03 +0530 Subject: [PATCH 02/43] [FIX]:orphan exception:(from XRG's commit) lp bug: https://launchpad.net/bugs/720705 fixed bzr revid: nch@tinyerp.com-20110503122203-9rx2x7smdpqpm3j2 --- openerp/report/report_sxw.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/report/report_sxw.py b/openerp/report/report_sxw.py index 1eaf6974c08..e4a40087c8b 100644 --- a/openerp/report/report_sxw.py +++ b/openerp/report/report_sxw.py @@ -35,6 +35,7 @@ import zipfile import common from openerp.osv.fields import float as float_class, function as function_class from openerp.osv.orm import browse_record +from openerp.tools.translate import _ DT_FORMAT = '%Y-%m-%d' DHM_FORMAT = '%Y-%m-%d %H:%M:%S' @@ -424,7 +425,7 @@ class report_sxw(report_rml, preprocess.report): elif report_type=='mako2html': fnct = self.create_source_mako2html else: - raise 'Unknown Report Type' + raise NotImplementedError('Unknown Report Type: %s' % report_type) fnct_ret = fnct(cr, uid, ids, data, report_xml, context) if not fnct_ret: return (False,False) From 55329ffbf65caf525ad8fd0f2b4c4fea3a034268 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Tue, 3 May 2011 18:30:24 +0530 Subject: [PATCH 03/43] [FIX] hr_timesheet_*: fix yml warning bzr revid: ara@tinyerp.com-20110503130024-rs4iyy2tjcmyn7y0 --- .../hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml | 2 +- addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml index d48d045cbeb..d7b59c02124 100644 --- a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml +++ b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml @@ -56,7 +56,7 @@ for invoice in invoice_id.invoice_line: product = invoice.product_id.id - product_exp = data['product'] + product_exp = data['product'][0] assert product == product_exp assert aline.invoice_id, "Invoice created, but analytic line wasn't updated." diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index edab4b2d840..2574be443ba 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -27,7 +27,7 @@ gender: male marital: hr.hr_employee_marital_status_single name: Mark Johnson - user_id: base.user_root + user_id: base.user_demo - I create new Timesheet journal for employee. @@ -69,7 +69,7 @@ date_to: !eval "'%s-05-31' %(datetime.now().year)" name: !eval "'Week-22(%s)' %(datetime.now().year)" state: new - user_id: base.user_root + user_id: base.user_demo employee_id: 'hr_employee_employee0' - Now , at the time of login, I create Attendances and perform "Sign In" action. From 4d3fbc4e62657d353f14e23f922dcb21ef1a3017 Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of openerp <> Date: Wed, 4 May 2011 05:33:30 +0000 Subject: [PATCH 04/43] Launchpad automatic translations update. bzr revid: launchpad_translations_on_behalf_of_openerp-20110504053330-naz3xv08wgssocdu --- bin/addons/base/i18n/ru.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/addons/base/i18n/ru.po b/bin/addons/base/i18n/ru.po index f5bf904b572..b229e480b0a 100644 --- a/bin/addons/base/i18n/ru.po +++ b/bin/addons/base/i18n/ru.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 5.0.4\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2011-01-11 11:14+0000\n" -"PO-Revision-Date: 2011-04-30 18:50+0000\n" -"Last-Translator: Mustufa Rangwala (Open ERP) \n" +"PO-Revision-Date: 2011-05-03 09:12+0000\n" +"Last-Translator: Chertykov Denis \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-05-01 06:03+0000\n" +"X-Launchpad-Export-Date: 2011-05-04 05:33+0000\n" "X-Generator: Launchpad (build 12758)\n" #. module: base @@ -685,7 +685,7 @@ msgstr "Импорт / Экспорт" msgid "" "Optional domain filtering of the destination data, as a Python expression" msgstr "" -"Дополнительная фильтрация данных назначения, в виде выражения на Python" +"Дополнительная фильтрация выходных данных, в виде выражения на Python" #. module: base #: model:ir.actions.act_window,name:base.action_view_base_module_upgrade From 31eded586ecaccd34380a26ab2b478f93be6b8e0 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 4 May 2011 11:50:00 +0200 Subject: [PATCH 05/43] [FIX] reports: allow empty images with reportlab 2.5 bzr revid: chs@openerp.com-20110504095000-zaqenmjpsbl6g5ew --- bin/report/render/rml2pdf/trml2pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index df826d0eace..f58f3fd6996 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -451,7 +451,7 @@ class _rml_canvas(object): res = utils._regex.findall(node.text) for key in res: newtext = eval(key, {}, self.localcontext) - node.text = newtext + node.text = newtext or '' image_data = None if node.text: image_data = base64.decodestring(node.text) From 89af288c3b1747d59bb3ccd65a6bb85fcd542961 Mon Sep 17 00:00:00 2001 From: "Naresh (OpenERP)" Date: Thu, 5 May 2011 15:56:00 +0530 Subject: [PATCH 06/43] [FIX]:AttributeError lp bug: https://launchpad.net/bugs/675826 fixed bzr revid: nch@tinyerp.com-20110505102600-0zch200zndsdf383 --- openerp/tools/misc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index 1524d95d922..d0f8faec6e0 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -159,7 +159,7 @@ def exec_pg_command(name, *args): if not prog: raise Exception('Couldn\'t find %s' % name) args2 = (prog,) + args - + return subprocess.call(args2) def exec_pg_command_pipe(name, *args): @@ -1283,6 +1283,9 @@ def detect_server_timezone(): def get_server_timezone(): # timezone detection is safe in multithread, so lazy init is ok here + if config['timezone'] and \ + not isinstance(config['timezone'], basestring): + return 'UTC' if (not config['timezone']): config['timezone'] = detect_server_timezone() return config['timezone'] From ca5a45a3134c5570dbb5047c231cd2382ad72aad Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 5 May 2011 14:00:03 +0200 Subject: [PATCH 07/43] [IMP] l10n_be: merged the enhancements for vat declaration made by Noviat bzr revid: qdp-launchpad@openerp.com-20110505120003-apzwajpwlol7gmy1 --- .../wizard/l10n_be_account_vat_declaration.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py index 03fff730bb4..38a711f995b 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py @@ -3,6 +3,11 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). +# +# Adapted by Noviat to +# - enforce correct vat number +# - support negative balance +# - support Noviat tax code scheme # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -58,13 +63,13 @@ class l10n_be_vat_declaration(osv.osv_memory): if context is None: context = {} - list_of_tags = ['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91'] + list_of_tags = ['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','72','81','82','83','84','85','86','87','88','91'] data_tax = self.browse(cr, uid, ids[0]) if data_tax.tax_code_id: obj_company = data_tax.tax_code_id.company_id else: obj_company = obj_user.browse(cr, uid, uid, context=context).company_id - vat_no = obj_company.partner_id.vat + vat_no = obj_company.partner_id.vat.replace(' ','').upper() if not vat_no: raise osv.except_osv(_('Data Insufficient'), _('No VAT Number Associated with Main Company!')) @@ -98,15 +103,22 @@ class l10n_be_vat_declaration(osv.osv_memory): data_of_file += '\n\t\t'+ (data['client_nihil'] and 'YES' or 'NO') +'' data_of_file +='\n\t\t\n\t\t\t' + cases_list = [] for item in tax_info: if item['code'] == '91' and ending_month != 12: #the tax code 91 can only be send for the declaration of December continue if item['code']: - if item['code'] == '71-72': - item['code']='71' + if item['code'] == 'VI': + if item['sum_period'] >= 0: + item['code'] = '71' + else: + item['code'] = '72' if item['code'] in list_of_tags: - data_of_file +='\n\t\t\t\t' + str(abs(int(round(item['sum_period']*100)))) + '' + cases_list.append(item) + cases_list.sort() + for item in cases_list: + data_of_file +='\n\t\t\t\t' + str(abs(int(round(item['sum_period']*100)))) + '' data_of_file += '\n\t\t\t\n\t\t\n\t\n' model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_vat_save')], context=context) From 521e77bde268e09ea35451d9c8a274e204fbb72d Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 5 May 2011 15:27:00 +0200 Subject: [PATCH 08/43] [IMP] l10n_be: merged the enhancements for vat listing made by Noviat bzr revid: qdp-launchpad@openerp.com-20110505132700-3lersicd60vezhx6 --- .../wizard/l10_be_partner_vat_listing.py | 151 ++++++++++-------- 1 file changed, 83 insertions(+), 68 deletions(-) diff --git a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py index 4c6e495ace5..66636539233 100644 --- a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py +++ b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py @@ -4,6 +4,11 @@ # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # +# Corrections & modifications by Noviat nv/sa, (http://www.noviat.be): +# - VAT listing based upon year in stead of fiscal year +# - sql query adapted to select only 'tax-out' move lines +# - extra button to print readable PDF report +# # 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 @@ -20,39 +25,12 @@ ############################################################################## import time import base64 - from tools.translate import _ -import tools -from decimal import Decimal from osv import fields, osv -class vat_listing_clients(osv.osv_memory): - _name = 'vat.listing.clients' - _columns = { - 'name': fields.char('Client Name', size=64), - 'vat': fields.char('VAT', size=64), - 'country': fields.char('Country', size=64), - 'amount': fields.float('Amount'), - 'turnover': fields.float('Turnover'), - } - def name_get(self, cr, uid, ids, context=None): - if not len(ids): - return [] - return [(r['id'], r['name'] or '' + ' - ' + r['vat'] or '') \ - for r in self.read(cr, uid, ids, ['name', 'vat'], - context, load='_classic_write')] - - def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): - client = self.search(cr, uid, [('vat', '=', name)]+args, limit=limit, context=context) - if not client: - client = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context) - return self.name_get(cr, uid, client, context=context) - -vat_listing_clients() - -class partner_vat(osv.osv_memory): +class partner_vat_13(osv.osv_memory): """ Vat Listing """ - _name = "partner.vat" + _name = "partner.vat_13" def get_partner(self, cursor, user, ids, context=None): obj_period = self.pool.get('account.period') @@ -60,8 +38,16 @@ class partner_vat(osv.osv_memory): obj_vat_lclient = self.pool.get('vat.listing.clients') obj_model_data = self.pool.get('ir.model.data') data = self.read(cursor, user, ids)[0] - period = obj_period.search(cursor, user, [('fiscalyear_id', '=', data['fyear'][0])], context=context) - p_id_list = obj_partner.search(cursor, user, [('vat_subjected', '!=', False),('customer','=',True)], context=context) + #period = obj_period.search(cursor, user, [('fiscalyear_id', '=', data['fyear'])], context=context) + year = data['year'] + date_start = year + '-01-01' + date_stop = year + '-12-31' + period = obj_period.search(cursor, user, [('date_start' ,'>=', date_start), ('date_stop','<=',date_stop)]) + if not period: + raise osv.except_osv(_('Data Insufficient!'), _('No data for the selected Year.')) + #logger.notifyChannel('addons.'+self._name, netsvc.LOG_WARNING, 'period = %s' %period ) + + p_id_list = obj_partner.search(cursor, user, [('vat_subjected', '!=', False)], context=context) if not p_id_list: raise osv.except_osv(_('Data Insufficient!'), _('No partner has a VAT Number asociated with him.')) partners = [] @@ -79,35 +65,35 @@ class partner_vat(osv.osv_memory): break if not go_ahead: continue - cursor.execute('select b.code, sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code IN %s and l.partner_id=%s and l.period_id IN %s group by b.code',(('produit', 'tax', 'income'),obj_partner.id,tuple(period),)) + cursor.execute('select b.code, sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code IN %s and l.partner_id=%s and l.period_id IN %s group by b.code',(('income','tax_out'),obj_partner.id,tuple(period),)) line_info = cursor.fetchall() if not line_info: continue - record['vat'] = obj_partner.vat + record['vat'] = obj_partner.vat.replace(' ','').upper() #it seems that this listing is only for belgian customers record['country'] = 'BE' - record['amount'] = Decimal(str(0.0)) - record['turnover'] = Decimal(str(0.0)) + record['amount'] = 0 + record['turnover'] = 0 record['name'] = obj_partner.name for item in line_info: - if item[0] in ('produit','income'): - record['turnover'] += Decimal(str(item[1])) + if item[0] == 'income': + record['turnover'] += item[1] else: - record['amount'] += Decimal(str(item[1])) + record['amount'] += item[1] id_client = obj_vat_lclient.create(cursor, user, record, context=context) partners.append(id_client) records.append(record) - context.update({'partner_ids': partners, 'fyear': data['fyear'], 'limit_amount': data['limit_amount'], 'mand_id':data['mand_id']}) - model_data_ids = obj_model_data.search(cursor, user, [('model','=','ir.ui.view'), ('name','=','view_vat_listing')]) + context.update({'partner_ids': partners, 'year': data['year'], 'limit_amount': data['limit_amount']}) + model_data_ids = obj_model_data.search(cursor, user, [('model','=','ir.ui.view'), ('name','=','view_vat_listing_13')]) resource_id = obj_model_data.read(cursor, user, model_data_ids, fields=['res_id'])[0]['res_id'] return { 'name': 'Vat Listing', 'view_type': 'form', 'view_mode': 'form', - 'res_model': 'partner.vat.list', + 'res_model': 'partner.vat.list_13', 'views': [(resource_id,'form')], 'context': context, 'type': 'ir.actions.act_window', @@ -115,17 +101,21 @@ class partner_vat(osv.osv_memory): } _columns = { - 'fyear': fields.many2one('account.fiscalyear','Fiscal Year', required=True), - 'mand_id': fields.char('MandataireId', size=14, required=True, help="This identifies the representative of the sending company. This is a string of 14 characters"), + 'year': fields.char('Year', size=4, required=True), 'limit_amount': fields.integer('Limit Amount', required=True), - 'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"), } -partner_vat() + + _defaults={ + 'year': lambda *a: str(int(time.strftime('%Y'))-1), + 'limit_amount': 250, + } + +partner_vat_13() -class partner_vat_list(osv.osv_memory): +class partner_vat_list_13(osv.osv_memory): """ Partner Vat Listing """ - _name = "partner.vat.list" + _name = "partner.vat.list_13" _columns = { 'partner_ids': fields.many2many('vat.listing.clients', 'vat_partner_rel', 'vat_id', 'partner_id', 'Clients', required=False, help='You can remove clients/partners which you do not want to show in xml file'), 'name': fields.char('File Name', size=32), @@ -153,12 +143,15 @@ class partner_vat_list(osv.osv_memory): seq_declarantnum = obj_sequence.get(cursor, user, 'declarantnum') obj_cmpny = obj_users.browse(cursor, user, user, context=context).company_id company_vat = obj_cmpny.partner_id.vat + if not company_vat: raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!')) - cref = company_vat + seq_controlref - dnum = cref[2:] + (seq_declarantnum or '') - obj_year= obj_fyear.browse(cursor, user, context['fyear'][0], context=context) + company_vat = company_vat.replace(' ','').upper() + SenderId = company_vat[2:] + cref = SenderId + seq_controlref + dnum = cref + seq_declarantnum + #obj_year= obj_fyear.browse(cursor, user, context['fyear'], context=context) street = zip_city = country = '' addr = obj_partner.address_get(cursor, user, [obj_cmpny.partner_id.id], ['invoice']) if addr.get('invoice',False): @@ -175,16 +168,14 @@ class partner_vat_list(osv.osv_memory): country = ads.country_id.code sender_date = time.strftime('%Y-%m-%d') -# comp_name = obj_cmpny.name - data_file = '\n\n\t\t'+ tools.ustr(obj_cmpny.name) +'\n\t\t'+ tools.ustr(street) +'\n\t\t'+ tools.ustr(zip_city) +'' - data_file += '\n\t\t'+ tools.ustr(country) +'\n\t\n' - data_comp = '\n\n\t'+str(company_vat)+'\n\t'+ tools.ustr(obj_cmpny.name) +'\n\t'+ tools.ustr(street) +'\n\t'+ tools.ustr(zip_city) +'\n\t'+ tools.ustr(country) +'\n' - data_period = '\n'+ tools.ustr(obj_year.date_stop[:4]) +'' + data_file += '\n\n\t\n\t\t'+str(company_vat)+'\n\t\t'+ comp_name +'\n\t\t'+ street +'\n\t\t'+ zip_city +'' + data_file += '\n\t\t'+ country +'\n\t\n' + data_comp = '\n\n\t'+SenderId+'\n\t'+ comp_name +'\n\t'+ street +'\n\t'+ zip_city +'\n\t'+ country +'\n' + data_period = '\n' + context['year'] +'' error_message = [] data = self.read(cursor, user, ids)[0] for partner in data['partner_ids']: @@ -195,27 +186,51 @@ class partner_vat_list(osv.osv_memory): datas.append(client_data) seq = 0 data_clientinfo = '' - sum_tax = Decimal(str(0.00)) - sum_turnover=Decimal(str(0.00)) + sum_tax = 0.00 + sum_turnover = 0.00 if len(error_message): return 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message) for line in datas: if not line: continue - if Decimal(str(line['turnover'])) < Decimal(str(context['limit_amount'])): + if line['turnover'] < context['limit_amount']: continue seq += 1 - sum_tax +=Decimal(str(line['amount'])) - sum_turnover +=Decimal(str(line['turnover'])) - data_clientinfo += '\n\n\t\n\t\t'+ (line['vat'] or '')[2:] +'\n\t\t' + tools.ustr(line['country']) +'\n\t\n\t'+ str(int(Decimal(str(line['amount'] * 100)))) +'\n\t'+ str(int(Decimal(str(line['turnover'] * 100)))) +'\n' + sum_tax += line['amount'] + sum_turnover += line['turnover'] + data_clientinfo += '\n\n\t\n\t\t'+line['vat'].replace(' ','').upper()[2:] +'\n\t\t' + line['country'] +'\n\t\n\t'+str(int(round(line['amount'] * 100))) +'\n\t'+str(int(round(line['turnover'] * 100))) +'\n' - data_decl ='\n' - data_file += tools.ustr(data_decl) + tools.ustr(data_comp) + tools.ustr(data_period) + tools.ustr(data_clientinfo) + '\n' + data_decl ='\n' + data_file += data_decl + data_comp + str(data_period) + data_clientinfo + '\n\n' msg = 'Save the File with '".xml"' extension.' file_save = base64.encodestring(data_file.encode('utf8')) self.write(cursor, user, ids, {'file_save':file_save, 'msg':msg, 'name':'vat_list.xml'}, context=context) return True + + def print_vatlist(self, cursor, user, ids, context=None): + if context is None: + context = {} + obj_vat_lclient = self.pool.get('vat.listing.clients') + client_datas = [] + data = self.read(cursor, user, ids)[0] + for partner in data['partner_ids']: + if isinstance(partner, list) and partner: + client_datas.append(partner[2]) + else: + client_data = obj_vat_lclient.read(cursor, user, partner, context=context) + client_datas.append(client_data) + + datas = {'ids': []} + datas['model'] = 'res.company' + datas['year'] = context['year'] + datas['limit_amount'] = context['limit_amount'] + datas['client_datas'] = client_datas + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'partner.vat.listing.print', + 'datas': datas, + } -partner_vat_list() +partner_vat_list_13() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 8dba0bc05367ff07dd7c570374a2a5592ee32344 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 5 May 2011 16:32:06 +0200 Subject: [PATCH 09/43] [IMP] l10n_be: renamed file bzr revid: qdp-launchpad@openerp.com-20110505143206-efhub12ul3eo0fuy --- addons/l10n_be/wizard/__init__.py | 2 +- ...be_partner_vat_listing.py => l10n_be_partner_vat_listing.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename addons/l10n_be/wizard/{l10_be_partner_vat_listing.py => l10n_be_partner_vat_listing.py} (100%) diff --git a/addons/l10n_be/wizard/__init__.py b/addons/l10n_be/wizard/__init__.py index 2e09bbb17db..3201ee4dba1 100644 --- a/addons/l10n_be/wizard/__init__.py +++ b/addons/l10n_be/wizard/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import l10_be_partner_vat_listing +import l10n_be_partner_vat_listing import l10n_be_vat_intra import l10n_be_account_vat_declaration diff --git a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py b/addons/l10n_be/wizard/l10n_be_partner_vat_listing.py similarity index 100% rename from addons/l10n_be/wizard/l10_be_partner_vat_listing.py rename to addons/l10n_be/wizard/l10n_be_partner_vat_listing.py From fc60bd9cd202e7a750203815225d14e65cb70167 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Thu, 5 May 2011 16:33:29 +0200 Subject: [PATCH 10/43] [IMP] l10n_be: merged the enhancements for vat listing made by Noviat (iteration 2: the views) bzr revid: qdp-launchpad@openerp.com-20110505143329-6jvmbdkcap3ygsr2 --- .../wizard/l10n_be_partner_vat_listing.xml | 157 ++++++------------ 1 file changed, 55 insertions(+), 102 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_partner_vat_listing.xml b/addons/l10n_be/wizard/l10n_be_partner_vat_listing.xml index 7ae3a0ab73e..ff05e5ecefb 100644 --- a/addons/l10n_be/wizard/l10n_be_partner_vat_listing.xml +++ b/addons/l10n_be/wizard/l10n_be_partner_vat_listing.xml @@ -1,110 +1,63 @@ - + - + + Partner VAT Listing + partner.vat_13 + form + +
+