From 489c5df81440202236ab37ffb2fade69f85b906e Mon Sep 17 00:00:00 2001 From: Peter Langenberg Date: Tue, 5 Feb 2013 09:37:06 +0100 Subject: [PATCH 1/2] [FIX]l10n_be_invoice_bba error message when duplicating lp bug: https://launchpad.net/bugs/1115472 fixed bzr revid: pl@agaplan.eu-20130205083706-sekknxzcl30ni9bn --- addons/l10n_be_invoice_bba/invoice.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index a23dabd7c51..97cc4ed5d7c 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -199,6 +199,18 @@ class account_invoice(osv.osv): '\nPlease create manually a unique BBA Structured Communication.')) return super(account_invoice, self).write(cr, uid, ids, vals, context) + def copy(self, cr, uid, ids, default=None, context=None): + default = default or {} + invoice = self.browse(cr, uid, ids, context=context) + reference_type = invoice.reference_type or 'none' + default['reference_type'] = reference_type + if reference_type == 'bba': + partner = invoice.partner_id + default['reference'] = self.generate_bbacomm(cr, uid, ids, + invoice.type, reference_type, + partner.id, '', context=context)['value']['reference'] + return super(account_invoice, self).copy(cr, uid, ids, default, context=context) + _columns = { 'reference': fields.char('Communication', size=64, help="The partner reference of this invoice."), 'reference_type': fields.selection(_get_reference_type, 'Communication Type', From 58bdae20d5bc7a4de9736362d9561428b2bdbac3 Mon Sep 17 00:00:00 2001 From: Peter Langenberg Date: Wed, 31 Jul 2013 17:48:38 +0200 Subject: [PATCH 2/2] [FIX] l10n_be_invoice_bba: we don't want to generate BBA communication for anything other than out_invoice bzr revid: pl@agaplan.eu-20130731154838-pjygijihw5otkk4e --- addons/l10n_be_invoice_bba/invoice.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index 97cc4ed5d7c..9e8947e5fec 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -202,13 +202,14 @@ class account_invoice(osv.osv): def copy(self, cr, uid, ids, default=None, context=None): default = default or {} invoice = self.browse(cr, uid, ids, context=context) - reference_type = invoice.reference_type or 'none' - default['reference_type'] = reference_type - if reference_type == 'bba': - partner = invoice.partner_id - default['reference'] = self.generate_bbacomm(cr, uid, ids, - invoice.type, reference_type, - partner.id, '', context=context)['value']['reference'] + if invoice.type in ['out_invoice']: + reference_type = invoice.reference_type or 'none' + default['reference_type'] = reference_type + if reference_type == 'bba': + partner = invoice.partner_id + default['reference'] = self.generate_bbacomm(cr, uid, ids, + invoice.type, reference_type, + partner.id, '', context=context)['value']['reference'] return super(account_invoice, self).copy(cr, uid, ids, default, context=context) _columns = {