Merge lp:~mikel-martin/account-payment/fix-bug-1084559 into lp:~account-payment-team/account-payment/6.1

Proposed by mikel
Status: Merged
Merged at revision: 90
Proposed branch: lp:~mikel-martin/account-payment/fix-bug-1084559
Merge into: lp:~account-payment-team/account-payment/6.1
Diff against target: 74 lines (+1/-58)
1 file modified
account_payment_extension/account_invoice.py (+1/-58)
To merge this branch: bzr merge lp:~mikel-martin/account-payment/fix-bug-1084559
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Approve
Review via email: mp+137501@code.launchpad.net

Description of the change

As explained in https://bugs.launchpad.net/account-payment/+bug/1084559 the refund method from account_invoice was forked.

Having a look at the code the fork was unnecesary.

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Indeed, there's no need of refund method in account_payment_extension, because it doesn't perform anything new. However, if there are things related to this module to perform in that method, the solution is inheritance, not forking the method.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_payment_extension/account_invoice.py'
2--- account_payment_extension/account_invoice.py 2012-11-01 21:49:33 +0000
3+++ account_payment_extension/account_invoice.py 2012-12-03 08:23:22 +0000
4@@ -4,7 +4,7 @@
5 # OpenERP, Open Source Management Solution
6 # Copyright (c) 2008 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
7 # Jordi Esteve <jesteve@zikzakmedia.com>
8-# AvanzOSC, Avanzed Open Source Consulting
9+# AvanzOSC, Avanzed Open Source Consulting
10 # Copyright (C) 2011-2012 Iker Coranti (www.avanzosc.com). All Rights Reserved
11 # $Id$
12 #
13@@ -76,61 +76,4 @@
14 aml_obj.write(cr, uid, move_line_ids, {'partner_bank_id': inv.partner_bank_id.id})
15 return ret
16
17- def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
18- invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id', 'payment_type'])
19- obj_invoice_line = self.pool.get('account.invoice.line')
20- obj_invoice_tax = self.pool.get('account.invoice.tax')
21- obj_journal = self.pool.get('account.journal')
22- new_ids = []
23- for invoice in invoices:
24- del invoice['id']
25-
26- type_dict = {
27- 'out_invoice': 'out_refund', # Customer Invoice
28- 'in_invoice': 'in_refund', # Supplier Invoice
29- 'out_refund': 'out_invoice', # Customer Refund
30- 'in_refund': 'in_invoice', # Supplier Refund
31- }
32-
33- invoice_lines = obj_invoice_line.read(cr, uid, invoice['invoice_line'])
34- invoice_lines = self._refund_cleanup_lines(cr, uid, invoice_lines)
35-
36- tax_lines = obj_invoice_tax.read(cr, uid, invoice['tax_line'])
37- tax_lines = filter(lambda l: l['manual'], tax_lines)
38- tax_lines = self._refund_cleanup_lines(cr, uid, tax_lines)
39- if journal_id:
40- refund_journal_ids = [journal_id]
41- elif invoice['type'] == 'in_invoice':
42- refund_journal_ids = obj_journal.search(cr, uid, [('type','=','purchase_refund')])
43- else:
44- refund_journal_ids = obj_journal.search(cr, uid, [('type','=','sale_refund')])
45-
46- if not date:
47- date = time.strftime('%Y-%m-%d')
48- invoice.update({
49- 'type': type_dict[invoice['type']],
50- 'date_invoice': date,
51- 'state': 'draft',
52- 'number': False,
53- 'invoice_line': invoice_lines,
54- 'tax_line': tax_lines,
55- 'journal_id': refund_journal_ids
56- })
57- if period_id:
58- invoice.update({
59- 'period_id': period_id,
60- })
61- if description:
62- invoice.update({
63- 'name': description,
64- })
65- # take the id part of the tuple returned for many2one fields
66- for field in ('address_contact_id', 'address_invoice_id', 'partner_id',
67- 'account_id', 'currency_id', 'payment_term', 'journal_id', 'payment_type'):
68- invoice[field] = invoice[field] and invoice[field][0]
69- # create the new invoice
70- new_ids.append(self.create(cr, uid, invoice))
71-
72- return new_ids
73-
74 account_invoice()

Subscribers

People subscribed via source and target branches