Merge lp:~dorian-kemps/unifield-server/US-3371 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4497
Proposed branch: lp:~dorian-kemps/unifield-server/US-3371
Merge into: lp:unifield-server
Diff against target: 121 lines (+40/-25)
3 files modified
bin/addons/sale/report/sale_donation_stock_moves_report.py (+33/-6)
bin/addons/sale/report/sale_donation_stock_moves_report_xls.mako (+6/-18)
bin/addons/sale/wizard/sale_donation_stock_moves_view.xml (+1/-1)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-3371
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+330424@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/sale/report/sale_donation_stock_moves_report.py'
2--- bin/addons/sale/report/sale_donation_stock_moves_report.py 2017-08-22 14:01:48 +0000
3+++ bin/addons/sale/report/sale_donation_stock_moves_report.py 2017-09-08 14:23:21 +0000
4@@ -30,12 +30,14 @@
5 super(sale_donation_stock_moves_report_parser, self).__init__(cr, uid, name, context=context)
6 self.cr = cr
7 self.uid = uid
8+ self.user_company = self._get_user_company()
9 self.localcontext.update({
10 'time': time,
11 'getMoves': self._get_moves,
12 'isQtyOut': self._is_qty_out,
13 'getQty': self._get_qty,
14- 'getInstance': self._get_instance,
15+ 'computeCurrency': self._compute_currency,
16+ 'userCompany': self.user_company,
17 })
18
19 def _get_moves(self, report):
20@@ -71,11 +73,36 @@
21
22 return qty
23
24- def _get_instance(self):
25- '''
26- Return user's current instance
27- '''
28- return self.pool.get('res.users').browse(self.cr, self.uid, self.uid).company_id.instance_id.name
29+ def _get_user_company(self):
30+ '''
31+ Return user's current company
32+ '''
33+ return self.pool.get('res.users').browse(self.cr, self.uid, self.uid).company_id
34+
35+ def _compute_currency(self, move):
36+ '''
37+ Compute an amount of a given currency to the instance's currency
38+ '''
39+ currency_obj = self.pool.get('res.currency')
40+
41+ if not move.price_currency_id:
42+ if move.price_unit is None:
43+ return round(move.product_id.standard_price, 2)
44+ if move.type == 'in':
45+ from_currency_id = move.partner_id.property_product_pricelist_purchase.currency_id.id
46+ else:
47+ from_currency_id = move.partner_id.property_product_pricelist.currency_id.id
48+ else:
49+ from_currency_id = move.price_currency_id.id
50+
51+ context = {'date': move.date}
52+ to_currency_id = self.user_company['currency_id'].id
53+
54+ if from_currency_id == to_currency_id:
55+ return round(move.price_unit, 2)
56+
57+ return round(currency_obj.compute(self.cr, self.uid, from_currency_id, to_currency_id, move.price_unit, round=False, context=context), 2)
58+
59
60 class sale_donation_stock_moves_report_xls(SpreadsheetReport):
61 def __init__(self, name, table, rml=False, parser=report_sxw.rml_parse,
62
63=== modified file 'bin/addons/sale/report/sale_donation_stock_moves_report_xls.mako'
64--- bin/addons/sale/report/sale_donation_stock_moves_report_xls.mako 2017-08-07 09:12:29 +0000
65+++ bin/addons/sale/report/sale_donation_stock_moves_report_xls.mako 2017-09-08 14:23:21 +0000
66@@ -107,13 +107,13 @@
67 ## Qty Out
68 <Column ss:AutoFitWidth="1" ss:Width="54.25" />
69 ## Unit Price
70- <Column ss:AutoFitWidth="1" ss:Width="57.25" />
71+ <Column ss:AutoFitWidth="1" ss:Width="57.75" />
72 ## Currency (FX)
73 <Column ss:AutoFitWidth="1" ss:Width="65.75" />
74 ## Total Value
75 <Column ss:AutoFitWidth="1" ss:Width="67.25" />
76 ## Instance
77- <Column ss:AutoFitWidth="1" ss:Width="97.25" />
78+ <Column ss:AutoFitWidth="1" ss:Width="150.75" />
79
80 <%
81 headers_list = [
82@@ -165,22 +165,10 @@
83 <Cell ss:StyleID="line_right"><Data ss:Type="Number">${getQty(o)|x}</Data></Cell>
84 <Cell ss:StyleID="line_right"><Data ss:Type="Number">0.00</Data></Cell>
85 % endif
86- % if o.price_unit:
87- <Cell ss:StyleID="line_right"><Data ss:Type="Number">${round(o.price_unit, 2)|x}</Data></Cell>
88- % else:
89- <Cell ss:StyleID="line_right"><Data ss:Type="Number">${round(o.product_id.standard_price, 2)|x}</Data></Cell>
90- % endif
91- % if o.price_currency_id.name:
92- <Cell ss:StyleID="line_left"><Data ss:Type="String">${o.price_currency_id.name|x}</Data></Cell>
93- % else:
94- <Cell ss:StyleID="line_left"><Data ss:Type="String">${o.product_id.currency_id.name or ''|x}</Data></Cell>
95- % endif
96- % if o.price_unit:
97- <Cell ss:StyleID="line_right"><Data ss:Type="Number">${round(o.price_unit, 2) * getQty(o)|x}</Data></Cell>
98- % else:
99- <Cell ss:StyleID="line_right"><Data ss:Type="Number">${round(o.product_id.standard_price, 2) * getQty(o)|x}</Data></Cell>
100- % endif
101- <Cell ss:StyleID="line_right"><Data ss:Type="String">${getInstance()|x}</Data></Cell>
102+ <Cell ss:StyleID="line_right"><Data ss:Type="Number">${computeCurrency(o)|x}</Data></Cell>
103+ <Cell ss:StyleID="line_left"><Data ss:Type="String">${userCompany['currency_id'].name|x}</Data></Cell>
104+ <Cell ss:StyleID="line_right"><Data ss:Type="Number">${computeCurrency(o) * getQty(o)|x}</Data></Cell>
105+ <Cell ss:StyleID="line_left"><Data ss:Type="String">${userCompany['instance_id'].name|x}</Data></Cell>
106 </Row>
107 % endfor
108
109
110=== modified file 'bin/addons/sale/wizard/sale_donation_stock_moves_view.xml'
111--- bin/addons/sale/wizard/sale_donation_stock_moves_view.xml 2017-08-07 11:54:12 +0000
112+++ bin/addons/sale/wizard/sale_donation_stock_moves_view.xml 2017-09-08 14:23:21 +0000
113@@ -10,7 +10,7 @@
114 <separator colspan="4" string="Request parameters" />
115 <field name="start_date" />
116 <field name="end_date" />
117- <field name="partner_id" domain="[('customer', '=', True)]" on_change="partner_onchange(partner_id, move_id)" />
118+ <field name="partner_id" on_change="partner_onchange(partner_id, move_id)" />
119 <field name="partner_type" />
120 <field name="product_id" />
121 <field name="move_id" domain="[('reason_type_id.name', 'in', ['In-Kind Donation', 'Donation before expiry', 'Donation (standard)']),('state', '=', 'done'),

Subscribers

People subscribed via source and target branches