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

Proposed by jftempo
Status: Merged
Merged at revision: 5424
Proposed branch: lp:~dorian-kemps/unifield-server/US-4989
Merge into: lp:unifield-server
Diff against target: 185 lines (+45/-9)
5 files modified
bin/addons/consumption_calculation/expiry_calculation.py (+23/-0)
bin/addons/consumption_calculation/expiry_calculation_view.xml (+2/-1)
bin/addons/consumption_calculation/report/expiry_calculation_report.py (+14/-2)
bin/addons/consumption_calculation/report/product_likely_expire.rml (+3/-3)
bin/addons/consumption_calculation/report/product_likely_expire_xls.mako (+3/-3)
To merge this branch: bzr merge lp:~dorian-kemps/unifield-server/US-4989
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+368307@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/consumption_calculation/expiry_calculation.py'
2--- bin/addons/consumption_calculation/expiry_calculation.py 2018-10-24 14:15:20 +0000
3+++ bin/addons/consumption_calculation/expiry_calculation.py 2019-06-04 08:28:17 +0000
4@@ -26,6 +26,8 @@
5 from datetime import date, timedelta, datetime
6
7 import time
8+import tools
9+
10
11 class expiry_quantity_report(osv.osv_memory):
12 _name = 'expiry.quantity.report'
13@@ -226,6 +228,26 @@
14 res[r['id']] = r['status']
15 return res
16
17+ def _get_amc_consumption_text(self, cr, uid, ids, field_name, args, context=None):
18+ '''
19+ Return the complete name for AMC Consumption
20+ '''
21+ if context is None:
22+ context = {}
23+
24+ date_obj = self.pool.get('date.tools')
25+
26+ res = {}
27+ for r in self.read(cr, uid, ids, ['consumption_type', 'consumption_from', 'consumption_to'], context=context):
28+ if r['consumption_from'] and r['consumption_to']:
29+ d_from = date_obj.get_date_formatted(cr, uid, datetime=r['consumption_from'])
30+ d_to = date_obj.get_date_formatted(cr, uid, datetime=r['consumption_to'])
31+ res[r['id']] = _([label for val, label in CONSUMPTION_TYPE if val == r['consumption_type']][0]) + tools.ustr(' (' + d_from + ' - ' + d_to + ')')
32+ else:
33+ res[r['id']] = _([label for val, label in CONSUMPTION_TYPE if val == r['consumption_type']][0])
34+
35+ return res
36+
37 _columns = {
38 'location_id': fields.many2one('stock.location', string='Location'),
39 'msf_instance': fields.char(size=64, string='Location', readonly=True),
40@@ -241,6 +263,7 @@
41 'requestor_date': fields.datetime(string='Date of the demand'),
42 'fake_status': fields.function(_get_status, method=True, type='selection', selection=LIKELY_EXPIRE_STATUS, readonly=True, string='Status'),
43 'status': fields.selection(LIKELY_EXPIRE_STATUS, string='Status'),
44+ 'amc_consumption_text': fields.function(_get_amc_consumption_text, method=True, type="char", string='Consumption'),
45 }
46
47 _defaults = {
48
49=== modified file 'bin/addons/consumption_calculation/expiry_calculation_view.xml'
50--- bin/addons/consumption_calculation/expiry_calculation_view.xml 2018-10-24 14:15:20 +0000
51+++ bin/addons/consumption_calculation/expiry_calculation_view.xml 2019-06-04 08:28:17 +0000
52@@ -184,7 +184,8 @@
53 <separator colspan="4" string="Period of calculation" />
54 <field name="date_from" readonly="1" />
55 <field name="date_to" readonly="1" />
56- <field name="consumption_type" colspan="4" readonly="1" />
57+ <field name="consumption_type" colspan="4" readonly="1" attrs="{'invisible': [('consumption_type', '=', 'amc')]}" />
58+ <field name="amc_consumption_text" colspan="4" readonly="1" attrs="{'invisible': [('consumption_type', '!=', 'amc')]}" />
59 <separator colspan="4" string="Expired products" />
60 <field colspan="4" nolabel="1" name="line_ids" mode="tree" readonly="1">
61 <tree string="Expired products">
62
63=== modified file 'bin/addons/consumption_calculation/report/expiry_calculation_report.py'
64--- bin/addons/consumption_calculation/report/expiry_calculation_report.py 2018-09-03 09:45:36 +0000
65+++ bin/addons/consumption_calculation/report/expiry_calculation_report.py 2019-06-04 08:28:17 +0000
66@@ -21,6 +21,7 @@
67
68 import time
69 import calendar
70+import tools
71 from tools.translate import _
72
73 from report import report_sxw
74@@ -31,6 +32,8 @@
75 ('amc', _('AMC -- Average Monthly Consumption')),
76 ('rac', _('RAC -- Real Average Consumption')),
77 ]
78+
79+
80 class product_likely_expire_report_parser(report_sxw.rml_parse):
81 """UTP-770/UTP-411"""
82 def __init__(self, cr, uid, name, context=None):
83@@ -53,6 +56,7 @@
84 'getAddress': self._get_instance_addr,
85 'getCurrency': self._get_currency,
86 'toDate': self.str_to_time,
87+ 'toUstr': self.to_ustr,
88 })
89 self._dates_context = {}
90 self._report_context = {}
91@@ -61,7 +65,7 @@
92 """get period header(str)"""
93 dt_from = self.formatLang(report.date_from, date=True)
94 dt_to = self.formatLang(report.date_to, date=True)
95- res = "%s - %s" % (dt_from, dt_to,)
96+ res = tools.ustr("%s - %s" % (dt_from, dt_to,))
97 return res
98
99 def _get_report_consumption_type(self, report):
100@@ -69,7 +73,10 @@
101 res = ""
102 for val, label in CONSUMPTION_TYPE:
103 if val == report.consumption_type:
104- return _(label)
105+ if val == 'amc':
106+ return _(label) + tools.ustr(' (' + self.str_to_time(report.consumption_from) + ' - ' + self.str_to_time(report.consumption_to) + ')')
107+ else:
108+ return _(label)
109 return res
110
111 def _get_report_dates(self, report):
112@@ -259,6 +266,11 @@
113 if dtime:
114 return self.pool.get('date.tools').get_date_formatted(self.cr, self.uid, datetime=dtime)
115 return ''
116+
117+ def to_ustr(self, val):
118+ return tools.ustr(val)
119+
120+
121 report_sxw.report_sxw('report.product.likely.expire.report_pdf', 'product.likely.expire.report', 'consumption_calculation/report/product_likely_expire.rml', parser=product_likely_expire_report_parser, header=False)
122
123 class product_likely_expire_report_xls_parser(SpreadsheetReport):
124
125=== modified file 'bin/addons/consumption_calculation/report/product_likely_expire.rml'
126--- bin/addons/consumption_calculation/report/product_likely_expire.rml 2018-09-04 14:54:02 +0000
127+++ bin/addons/consumption_calculation/report/product_likely_expire.rml 2019-06-04 08:28:17 +0000
128@@ -17,7 +17,7 @@
129 <stylesheet>
130
131 <blockTableStyle id="TitleTable">
132- <blockAlignment value="CENTRE"/>
133+ <blockAlignment value="CENTER"/>
134 <blockValign value="MIDDLE"/>
135 <lineStyle kind="OUTLINE" colorName="black" />
136 </blockTableStyle>
137@@ -53,7 +53,7 @@
138
139 [[ setLang('en_US') ]]
140
141- <blockTable colWidths="310.0,132.0,310.0" style="TitleTable">
142+ <blockTable colWidths="285.0,182.0,285.0" style="TitleTable">
143 <tr>
144 <td>
145 <para style="Title"> </para>
146@@ -71,7 +71,7 @@
147 <font color="white"> </font>
148 </para>
149
150- <blockTable colWidths="112.0,250.0,410.0" style="DocInfo">
151+ <blockTable colWidths="112.0,350.0,310.0" style="DocInfo">
152 <tr>
153 <td>
154 <para style="TextInfoBold">Report date : </para>
155
156=== modified file 'bin/addons/consumption_calculation/report/product_likely_expire_xls.mako'
157--- bin/addons/consumption_calculation/report/product_likely_expire_xls.mako 2018-09-24 11:52:57 +0000
158+++ bin/addons/consumption_calculation/report/product_likely_expire_xls.mako 2019-06-04 08:28:17 +0000
159@@ -84,7 +84,7 @@
160 <Row>
161 <Cell ss:StyleID="header"><Data ss:Type="String">${_('Location')}</Data></Cell>
162 <Cell ss:StyleID="header"><Data ss:Type="String">${_('Period')}</Data></Cell>
163-<Cell ss:StyleID="header" ss:MergeAcross="2"><Data ss:Type="String">${_('Consumption')}</Data></Cell>
164+<Cell ss:StyleID="header" ss:MergeAcross="4"><Data ss:Type="String">${_('Consumption')}</Data></Cell>
165 <%
166 cols = n_header_colspan - 2
167 if cols < 0:
168@@ -97,7 +97,7 @@
169 <Row>
170 <Cell ss:StyleID="line" ><Data ss:Type="String">${(o.location_id and objects[0].location_id.name or '')|x}</Data></Cell>
171 <Cell ss:StyleID="line" ><Data ss:Type="String">${(getReportPeriod(o) or '')|x}</Data></Cell>
172-<Cell ss:StyleID="line" ss:MergeAcross="2"><Data ss:Type="String">${(getReportConsumptionType(o) or '')|x}</Data></Cell>
173+<Cell ss:StyleID="line" ss:MergeAcross="4"><Data ss:Type="String">${(getReportConsumptionType(o) or '')|x}</Data></Cell>
174 % for n in range(cols):
175 <Cell ss:StyleID="line"><Data ss:Type="String"></Data></Cell>
176 % endfor
177@@ -199,7 +199,7 @@
178 <Cell ss:StyleID="line" ><Data ss:Type="String">${il.item_id.line_id.product_id.default_code or ''|x}</Data></Cell>
179 <Cell ss:StyleID="line" ><Data ss:Type="String">${il.item_id.line_id.product_id.name or ''|x}</Data></Cell>
180 <Cell ss:StyleID="line" ><Data ss:Type="String">${il.lot_id.name}</Data></Cell>
181-<Cell ss:StyleID="line" ><Data ss:Type="String">${(formatLang(il.expired_date, date=True) or '')}</Data></Cell>
182+<Cell ss:StyleID="line" ><Data ss:Type="String">${(toUstr(formatLang(il.expired_date, date=True)) or '')}</Data></Cell>
183 <Cell ss:StyleID="line" ><Data ss:Type="String">${il.location_id.name}</Data></Cell>
184 <Cell ss:StyleID="line_number" ><Data ss:Type="Number">${il.available_qty or 0.}</Data></Cell>
185 <Cell ss:StyleID="line_number" ><Data ss:Type="Number">${il.expired_qty or 0.}</Data></Cell>

Subscribers

People subscribed via source and target branches