Merge lp:~odossmann/unifield-addons/UTP_594 into lp:unifield-addons

Proposed by jftempo
Status: Needs review
Proposed branch: lp:~odossmann/unifield-addons/UTP_594
Merge into: lp:unifield-addons
Diff against target: 87 lines (+19/-6)
1 file modified
account/invoice.py (+19/-6)
To merge this branch: bzr merge lp:~odossmann/unifield-addons/UTP_594
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+236346@code.launchpad.net
To post a comment you must log in.
4629. By Olivier DOSSMANN

UTP-594 [FIX] Problems with reference in lines

4630. By Olivier DOSSMANN

UTP-594 [FIX] Problem of analytic lines after invoice validation that take the wrong reference

Unmerged revisions

4630. By Olivier DOSSMANN

UTP-594 [FIX] Problem of analytic lines after invoice validation that take the wrong reference

4629. By Olivier DOSSMANN

UTP-594 [FIX] Problems with reference in lines

4628. By Olivier DOSSMANN

UTP-594 [FIX] Make reference from Journal Items that comes from an invoice that is a refund to be the origin name of the invoice. Add also the description of the original invoice.

4627. By Olivier DOSSMANN

UTP-594 [DEL] Useless code that will be included in unifield-wm and some elements of invoice.py file.

4626. By Vincent GREINER

UTP-594 [IMP] refund link with previous invoice and update of JE/JI ref with the invoice seq number for tracibility of original invoice of the refund entries (DRAFT)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/invoice.py'
2--- account/invoice.py 2014-09-29 12:34:12 +0000
3+++ account/invoice.py 2014-09-30 08:49:55 +0000
4@@ -691,6 +691,8 @@
5 if il['account_analytic_id']:
6 if inv.type in ('in_invoice', 'in_refund'):
7 ref = inv.reference
8+ if inv.refund_source_inv_id:
9+ ref = inv.origin
10 else:
11 ref = self._convert_ref(cr, uid, inv.number)
12 if not inv.journal_id.analytic_journal_id:
13@@ -858,11 +860,15 @@
14 iml += ait_obj.move_line_get(cr, uid, inv.id)
15
16 entry_type = ''
17+ name = inv['name'] or '/'
18 if inv.type in ('in_invoice', 'in_refund'):
19 ref = inv.reference
20 entry_type = 'journal_pur_voucher'
21 if inv.type == 'in_refund':
22 entry_type = 'cont_voucher'
23+ if inv.refund_source_inv_id:
24+ ref = inv.origin
25+ name = inv.refund_source_inv_id.name
26 else:
27 ref = self._convert_ref(cr, uid, inv.number)
28 entry_type = 'journal_sale_vou'
29@@ -876,7 +882,6 @@
30 total, total_currency, iml = self.compute_invoice_totals(cr, uid, inv, company_currency, ref, iml)
31 acc_id = inv.account_id.id
32
33- name = inv['name'] or '/'
34 totlines = False
35 if inv.payment_term:
36 totlines = self.pool.get('account.payment.term').compute(cr,
37@@ -909,6 +914,7 @@
38 'currency_id': diff_currency_p \
39 and inv.currency_id.id or False,
40 'ref': ref,
41+ 'reference': ref,
42 'is_counterpart': True,
43 })
44 else:
45@@ -924,6 +930,7 @@
46 'currency_id': diff_currency_p \
47 and inv.currency_id.id or False,
48 'ref': ref,
49+ 'reference': ref,
50 'is_counterpart': True,
51 })
52
53@@ -1013,11 +1020,16 @@
54
55 self.write(cr, uid, ids, {'internal_number':number})
56
57+ from_si_refund = False
58 if invtype in ('in_invoice', 'in_refund'):
59 if not reference:
60 ref = self._convert_ref(cr, uid, number)
61 else:
62 ref = reference
63+ # UTP-594: Reference should be the origin of invoice. It should be done via action_move_create. So
64+ #+ we don't need to update analytic lines
65+ if invtype == 'in_refund' and obj_inv.refund_source_inv_id:
66+ from_si_refund = True
67 else:
68 ref = self._convert_ref(cr, uid, number)
69
70@@ -1027,11 +1039,12 @@
71 cr.execute('UPDATE account_move_line SET ref=%s ' \
72 'WHERE move_id=%s AND (ref is null OR ref = \'\')',
73 (ref, move_id))
74- cr.execute('UPDATE account_analytic_line SET ref=%s ' \
75- 'FROM account_move_line ' \
76- 'WHERE account_move_line.move_id = %s ' \
77- 'AND account_analytic_line.move_id = account_move_line.id',
78- (ref, move_id))
79+ if not from_si_refund:
80+ cr.execute('UPDATE account_analytic_line SET ref=%s ' \
81+ 'FROM account_move_line ' \
82+ 'WHERE account_move_line.move_id = %s ' \
83+ 'AND account_analytic_line.move_id = account_move_line.id',
84+ (ref, move_id))
85
86 for inv_id, name in self.name_get(cr, uid, [id]):
87 ctx = context.copy()

Subscribers

People subscribed via source and target branches