Merge lp:~julie-w/unifield-server/US-8900 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 6109
Proposed branch: lp:~julie-w/unifield-server/US-8900
Merge into: lp:unifield-server
Diff against target: 126 lines (+28/-22)
2 files modified
bin/addons/account/invoice.py (+3/-2)
bin/addons/account/report/invoice_excel_export.py (+25/-20)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-8900
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+408656@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/account/invoice.py'
2--- bin/addons/account/invoice.py 2021-04-23 16:43:40 +0000
3+++ bin/addons/account/invoice.py 2021-09-15 15:25:35 +0000
4@@ -2140,7 +2140,7 @@
5 def get(self, cr, uid, key, key2, models, meta=False, context=None, res_id_req=False, without_user=True, key2_req=True, view_id=False):
6 """
7 Hides the reports:
8- - "Invoice Excel Export" in the menu of other invoices than IVO/IVI
9+ - "Invoice Excel Export" in the menu of other invoices than IVO/IVI/STV
10 - "FO Follow-up Finance" in the menu of other invoices than IVO/STV
11 - "STV/IVO lines follow-up" in the menu of other invoices than IVO/STV (+ renames it depending on the inv. type)
12 """
13@@ -2162,7 +2162,8 @@
14 elif context_stv:
15 v[2]['name'] = _('STV lines follow-up')
16 # display
17- if not context.get('is_intermission') and len(v) > 2 and v[2].get('report_name', '') == 'invoice.excel.export':
18+ if not context.get('is_intermission') and not context_stv and len(v) > 2 and \
19+ v[2].get('report_name', '') == 'invoice.excel.export':
20 continue
21 elif not context_ivo and not context_stv and len(v) > 1 and v[1] in ('fo_follow_up_finance', 'invoice_lines_follow_up'):
22 continue
23
24=== modified file 'bin/addons/account/report/invoice_excel_export.py'
25--- bin/addons/account/report/invoice_excel_export.py 2020-04-09 09:06:08 +0000
26+++ bin/addons/account/report/invoice_excel_export.py 2021-09-15 15:25:35 +0000
27@@ -37,8 +37,10 @@
28
29 def _get_distribution_lines(self, inv_line):
30 """
31- Returns distrib. line data related to the invoice line in parameter, as a list of dicts
32- Note: it gives a result even for lines without AD: the line subtotal is retrieved in any cases
33+ Returns distrib. line data related to the invoice line in parameter, as a list of dicts.
34+ Notes:
35+ - it gives a result even for lines without AD: the line subtotal is retrieved in any cases
36+ - only CC and Dest are retrieved, FP is excluded.
37 """
38 fp_distrib_line_obj = self.pool.get('funding.pool.distribution.line')
39 distrib_lines = []
40@@ -69,18 +71,19 @@
41
42 def _get_shipment_number(self, inv):
43 """
44- Returns the "shipment" or "simple OUT" number having generated the IVO if linked to a supply workflow
45- Displayed for both the IVO and the IVI.
46+ Returns the "shipment" or "simple OUT" number having generated the IVO/STV if linked to a supply workflow
47+ Displayed for both the IVO/STV and the IVI.
48 """
49 if self.invoices.get(inv.id, {}).get('shipment', None) is not None:
50 # process only once per invoice
51 return self.invoices[inv.id]['shipment']
52 ship_or_out_ref = ''
53- if inv.from_supply and inv.is_intermission:
54- if inv.type == 'out_invoice': # IVO
55+ if inv.from_supply:
56+ inv_type = self.pool.get('account.invoice').get_account_invoice_type(self.cr, self.uid, inv.id)
57+ if inv_type in ('ivo', 'stv'):
58 if inv.name:
59 ship_or_out_ref = inv.name.split()[-1]
60- elif inv.type == 'in_invoice': # IVI
61+ elif inv_type == 'ivi':
62 if inv.picking_id:
63 ship_or_out_ref = inv.picking_id.shipment_ref or ''
64 self.invoices.setdefault(inv.id, {}).update({'shipment': ship_or_out_ref})
65@@ -88,20 +91,21 @@
66
67 def _get_fo_number(self, inv):
68 """
69- Returns the FO number related to the IVO if any.
70- Displayed for both the IVO and the IVI.
71+ Returns the FO number related to the IVO/STV if any.
72+ Displayed for both the IVO/STV and the IVI.
73 """
74 if self.invoices.get(inv.id, {}).get('fo', None) is not None:
75 # process only once per invoice
76 return self.invoices[inv.id]['fo']
77 fo_number = ''
78- if inv.from_supply and inv.is_intermission:
79- if inv.type == 'out_invoice': # IVO
80+ if inv.from_supply:
81+ inv_type = self.pool.get('account.invoice').get_account_invoice_type(self.cr, self.uid, inv.id)
82+ if inv_type in ('ivo', 'stv'):
83 if inv.origin:
84 inv_source_doc_split = inv.origin.split(':')
85 if inv_source_doc_split:
86 fo_number = inv_source_doc_split[-1]
87- elif inv.type == 'in_invoice': # IVI
88+ elif inv_type == 'ivi':
89 if inv.main_purchase_id:
90 fo_number = inv.main_purchase_id.short_partner_ref or ''
91 self.invoices.setdefault(inv.id, {}).update({'fo': fo_number})
92@@ -109,25 +113,26 @@
93
94 def _get_po_number(self, inv_line):
95 """
96- Returns the PO number for Intermission Voucher Lines linked to a supply workflow.
97- For the IVO: PO to the external partner in order to buy the goods
98+ Returns the PO number for the lines linked to a supply workflow.
99+ For the IVO/STV: PO to the external partner in order to buy the goods
100 For the IVI: PO to the intermission partner which triggered the creation of the FO
101 """
102 inv = inv_line.invoice_id
103- ivo_from_supply = inv.is_intermission and inv.type == 'out_invoice' and inv.from_supply
104- if not ivo_from_supply and self.invoices.get(inv.id, {}).get('po', None) is not None:
105- # process only once per invoice except for IVO from Supply where the check must be done line by line
106+ inv_type = self.pool.get('account.invoice').get_account_invoice_type(self.cr, self.uid, inv.id)
107+ out_inv_from_supply = inv_type in ('ivo', 'stv') and inv.from_supply
108+ if not out_inv_from_supply and self.invoices.get(inv.id, {}).get('po', None) is not None:
109+ # process only once per invoice except for IVO/STV from Supply where the check must be done line by line
110 return self.invoices[inv.id]['po']
111 po_number = ''
112 po_line_obj = self.pool.get('purchase.order.line')
113- if inv.from_supply and inv.is_intermission:
114- if inv.type == 'out_invoice': # IVO
115+ if inv.from_supply:
116+ if inv_type in ('ivo', 'stv'):
117 fo_line = inv_line.sale_order_line_id
118 if fo_line and fo_line.type == 'make_to_order': # the line is sourced on a PO
119 pol_ids = po_line_obj.search(self.cr, self.uid, [('sale_order_line_id', '=', fo_line.id)])
120 if pol_ids:
121 po_number = po_line_obj.browse(self.cr, self.uid, pol_ids[0], fields_to_fetch=['order_id']).order_id.name
122- elif inv.type == 'in_invoice': # IVI
123+ elif inv_type == 'ivi':
124 if inv.main_purchase_id:
125 po_number = inv.main_purchase_id.name
126 self.invoices.setdefault(inv.id, {}).update({'po': po_number})

Subscribers

People subscribed via source and target branches