Merge lp:~unifield-team/unifield-server/us-4027 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4831
Proposed branch: lp:~unifield-team/unifield-server/us-4027
Merge into: lp:unifield-server
Diff against target: 456 lines (+156/-82)
5 files modified
bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py (+50/-51)
bin/addons/msf_supply_doc_export/msf_supply_doc_export.py (+58/-0)
bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xls.mako (+31/-21)
bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xml.mako (+15/-8)
bin/addons/purchase/purchase_order.py (+2/-2)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-4027
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+337539@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/msf_doc_import/wizard/wizard_po_simulation_screen.py'
2--- bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py 2018-03-02 16:53:19 +0000
3+++ bin/addons/msf_doc_import/wizard/wizard_po_simulation_screen.py 2018-03-27 07:15:50 +0000
4@@ -46,7 +46,7 @@
5
6
7 NB_OF_HEADER_LINES = 20
8-NB_LINES_COLUMNS = 19
9+NB_LINES_COLUMNS = 20
10
11
12 PRODUCT_CODE_ID = {}
13@@ -80,8 +80,8 @@
14 HEADER_COLUMNS = [(1, _('Order Reference'), 'mandatory'),
15 (5, _('Supplier Reference'), 'optionnal'),
16 (9, _('Ready To Ship Date'), 'optionnal'),
17- (16, _('Shipment Date'), 'optionnal'),
18- (20, _('Message ESC'), 'optionnal')
19+ (14, _('Shipment Date'), 'optionnal'),
20+ (18, _('Message ESC'), 'optionnal')
21 ]
22
23
24@@ -448,7 +448,7 @@
25 'product_code', 'product_name',
26 'product_qty', 'product_uom',
27 'price_unit', 'currency_id',
28- 'origin', 'comment', 'date_planned',
29+ 'origin', 'stock_take_date','comment', 'date_planned',
30 'confirmed_delivery_date',
31 'nomen_manda_0', 'nomen_manda_1',
32 'nomen_manda_2',
33@@ -687,11 +687,14 @@
34 # Line 6: Details
35 # Nothing to do
36
37- # Line 7: Delivery Requested Date
38- # Nothing to do
39-
40- # Line 8: Transport mode
41- transport_mode = values.get(8, [])[1]
42+ # Line 7: Stock take date
43+ # Nothing to do
44+
45+ # Line 8: Delivery Requested Date
46+ # Nothing to do
47+
48+ # Line 9: Transport mode
49+ transport_mode = values.get(9, [])[1]
50 if transport_mode:
51 transport_select = self.fields_get(cr, uid, ['imp_transport_mode'], context=context)
52 for x in transport_select['imp_transport_mode']['selection']:
53@@ -700,13 +703,13 @@
54 break
55 else:
56 possible_mode = ', '.join(x[1] for x in transport_select['imp_transport_mode']['selection'] if x[1])
57- err_msg = _('Line 8 of the file: The transport mode \'%s\' is not \
58+ err_msg = _('Line 9 of the file: The transport mode \'%s\' is not \
59 a valid transport mode. Valid transport modes: %s') % (transport_mode, possible_mode)
60 values_header_errors.append(err_msg)
61
62
63- # Line 9: RTS Date
64- rts_date = values.get(9, [])[1]
65+ # Line 10: RTS Date
66+ rts_date = values.get(10, [])[1]
67 if rts_date:
68 if type(rts_date) == type(DateTime.now()):
69 rts_date = rts_date.strftime('%Y-%m-%d')
70@@ -716,30 +719,24 @@
71 time.strptime(rts_date, '%Y-%m-%d')
72 header_values['imp_ready_to_ship_date'] = rts_date
73 except:
74- err_msg = _('Line 9 of the file: The date \'%s\' is not \
75+ err_msg = _('Line 10 of the file: The date \'%s\' is not \
76 a valid date. A date must be formatted like \'YYYY-MM-DD\'') % rts_date
77 values_header_errors.append(err_msg)
78
79- # Line 10: Address name
80- # Nothing to do
81-
82- # Line 11: Address street
83- # Nothing to do
84-
85- # Line 12: Address street 2
86- # Nothing to do
87-
88- # Line 13: Zip
89- # Nothing to do
90-
91- # Line 14: City
92- # Nothing to do
93-
94- # Line 15: Country
95- # Nothing to do
96-
97- # Line 16: Shipment date
98- shipment_date = values.get(16, [])[1]
99+ # Line 11: Delivery address name
100+ # Nothing to do
101+
102+ # Line 12: Delivery address
103+ # Nothing to do
104+
105+ # Line 13: Customer address name
106+ # Nothing to do
107+
108+ # Line 14: Customer address
109+ # Nothing to do
110+
111+ # Line 15: Shipment date
112+ shipment_date = values.get(15, [])[1]
113 if shipment_date:
114 if type(shipment_date) == type(DateTime.now()):
115 shipment_date = shipment_date.strftime('%Y-%m-%d')
116@@ -749,25 +746,27 @@
117 time.strptime(shipment_date, '%Y-%m-%d')
118 header_values['imp_shipment_date'] = shipment_date
119 except:
120- err_msg = _('Line 9 of the file: The date \'%s\' is not \
121+ err_msg = _('Line 15 of the file: The date \'%s\' is not \
122 a valid date. A date must be formatted like \'YYYY-MM-DD\'') % shipment_date
123 values_header_errors.append(err_msg)
124
125- # Line 17: Notes
126+ # Line 16: Notes
127 # UFTP-59
128 if wiz.filetype != 'excel':
129- header_values['imp_notes'] = values.get(17, [])[1]
130-
131- # Line 18: Origin
132- # Nothing to do
133-
134- # Line 19: Project Ref.
135- # Nothing to do
136-
137- # Line 20: Message ESC Header
138+ header_values['imp_notes'] = values.get(16, [])[1]
139+
140+ # Line 17: Origin
141+ # Nothing to do
142+
143+ # Line 18: Project Ref.
144+ # Nothing to do
145+
146+ # Line 19: Message ESC Header
147 if wiz.filetype != 'excel':
148- header_values['imp_message_esc'] = values.get(20, [])[1]
149+ header_values['imp_message_esc'] = values.get(19, [])[1]
150
151+ # Line 20: Sourcing group
152+ # Nothing to do
153
154 '''
155 The header values have been imported, start the importation of
156@@ -1351,7 +1350,7 @@
157 errors.append(_('PO line #%s has been confirmed or cancelled and consequently is not editable') % line.in_line_number)
158
159 # Comment
160- write_vals['imp_comment'] = values[14] and values[14].strip()
161+ write_vals['imp_comment'] = values[15] and values[15].strip()
162
163 # External Ref.
164 write_vals['imp_external_ref'] = values[1]
165@@ -1486,7 +1485,7 @@
166 write_vals['type_change'] = 'error'
167
168 # Delivery Requested Date
169- drd_value = values[9]
170+ drd_value = values[10]
171 if drd_value and type(drd_value) == type(DateTime.now()):
172 write_vals['imp_drd'] = drd_value.strftime('%Y-%m-%d')
173 elif drd_value and isinstance(drd_value, str):
174@@ -1503,7 +1502,7 @@
175 write_vals['type_change'] = 'error'
176
177 # Delivery Confirmed Date
178- dcd_value = values[10]
179+ dcd_value = values[11]
180 if dcd_value and type(dcd_value) == type(DateTime.now()):
181 write_vals['imp_dcd'] = dcd_value.strftime('%Y-%m-%d')
182 elif dcd_value and isinstance(dcd_value, str):
183@@ -1520,12 +1519,12 @@
184 write_vals['type_change'] = 'error'
185
186 # Project Ref.
187- write_vals['imp_project_ref'] = values[16]
188+ write_vals['imp_project_ref'] = values[17]
189
190 # Message ESC1
191- write_vals['imp_esc1'] = values[17]
192+ write_vals['imp_esc1'] = values[18]
193 # Message ESC2
194- write_vals['imp_esc2'] = values[18]
195+ write_vals['imp_esc2'] = values[19]
196
197 if line.error_msg:
198 write_vals['type_change'] = 'error'
199
200=== modified file 'bin/addons/msf_supply_doc_export/msf_supply_doc_export.py'
201--- bin/addons/msf_supply_doc_export/msf_supply_doc_export.py 2017-11-06 10:23:04 +0000
202+++ bin/addons/msf_supply_doc_export/msf_supply_doc_export.py 2018-03-27 07:15:50 +0000
203@@ -126,9 +126,15 @@
204 context = {}
205 context['lang'] = 'en_MF'
206 super(validated_purchase_order_report_xls, self).__init__(cr, uid, name, context=context)
207+ self.cr = cr
208+ self.uid = uid
209 self.localcontext.update({
210 'time': time,
211 'maxADLines': self.get_max_ad_lines,
212+ 'getInstanceName': self.getInstanceName,
213+ 'getCustomerAddress': self.getCustomerAddress,
214+ 'getInstanceAddress': self.getInstanceAddress,
215+ 'getContactName': self.getContactName,
216 })
217
218 def set_context(self, objects, data, ids, report_type = None):
219@@ -144,6 +150,29 @@
220
221 return max_ad_lines
222
223+ def getInstanceName(self):
224+ return self.pool.get('res.users').browse(self.cr, self.uid, self.uid).company_id.instance_id.instance
225+
226+ def getInstanceAddress(self):
227+ part_addr_id = self.pool.get('res.partner.address').search(self.cr, self.uid, [('partner_id', '=', self.uid)], limit=1)
228+ part_addr = False
229+ if part_addr_id:
230+ part_addr = self.pool.get('res.partner.address').browse(self.cr, self.uid, part_addr_id)[0]
231+ return part_addr.name if part_addr else ''
232+
233+ def getCustomerAddress(self, customer_id):
234+ part_addr_obj = self.pool.get('res.partner.address')
235+ part_addr_id = part_addr_obj.search(self.cr, self.uid, [('partner_id', '=', customer_id)], limit=1)[0]
236+
237+ return part_addr_obj.browse(self.cr, self.uid, part_addr_id).name
238+
239+ def getContactName(self, addr_id):
240+ res = ''
241+ if addr_id:
242+ res = self.pool.get('res.partner.address').read(self.cr, self.uid, addr_id)['name']
243+ return res
244+
245+
246 SpreadsheetReport('report.validated.purchase.order_xls', 'purchase.order', 'addons/msf_supply_doc_export/report/report_validated_purchase_order_xls.mako', parser=validated_purchase_order_report_xls)
247
248 # VALIDATE PURCHASE ORDER (Pure XML)
249@@ -153,9 +182,15 @@
250 context = {}
251 context['lang'] = 'en_MF'
252 super(parser_validated_purchase_order_report_xml, self).__init__(cr, uid, name, context=context)
253+ self.cr = cr
254+ self.uid = uid
255 self.localcontext.update({
256 'time': time,
257 'maxADLines': self.get_max_ad_lines,
258+ 'getInstanceName': self.getInstanceName,
259+ 'getCustomerAddress': self.getCustomerAddress,
260+ 'getContactName': self.getContactName,
261+ 'getInstanceAddress': self.getInstanceAddress,
262 })
263
264 def set_context(self, objects, data, ids, report_type = None):
265@@ -171,6 +206,29 @@
266
267 return max_ad_lines
268
269+ def getInstanceName(self):
270+ return self.pool.get('res.users').browse(self.cr, self.uid, self.uid).company_id.instance_id.instance
271+
272+ def getCustomerAddress(self, customer_id):
273+ part_addr_obj = self.pool.get('res.partner.address')
274+ part_addr_id = part_addr_obj.search(self.cr, self.uid, [('partner_id', '=', customer_id)], limit=1)[0]
275+
276+ return part_addr_obj.browse(self.cr, self.uid, part_addr_id).name
277+
278+ def getContactName(self, addr_id):
279+ res = ''
280+ if addr_id:
281+ res = self.pool.get('res.partner.address').read(self.cr, self.uid, addr_id)['name']
282+ return res
283+
284+ def getInstanceAddress(self):
285+ part_addr_id = self.pool.get('res.partner.address').search(self.cr, self.uid, [('partner_id', '=', self.uid)], limit=1)
286+ part_addr = False
287+ if part_addr_id:
288+ part_addr = self.pool.get('res.partner.address').browse(self.cr, self.uid, part_addr_id)[0]
289+ return part_addr.name if part_addr else ''
290+
291+
292 class validated_purchase_order_report_xml(WebKitParser):
293 def __init__(self, name, table, rml=False, parser=report_sxw.rml_parse, header='external', store=False):
294 WebKitParser.__init__(self, name, table, rml=rml, parser=parser, header=header, store=store)
295
296=== modified file 'bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xls.mako'
297--- bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xls.mako 2017-11-17 09:11:27 +0000
298+++ bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xls.mako 2018-03-27 07:15:50 +0000
299@@ -103,6 +103,10 @@
300 <Cell ss:StyleID="line" ><Data ss:Type="String">${o.details or ''|x}</Data></Cell>
301 </Row>
302 <Row>
303+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Stock Take Date')}</Data></Cell>
304+ <Cell ss:StyleID="short_date" ><Data ss:Type="DateTime">${o.stock_take_date|n}T00:00:00.000</Data></Cell>
305+ </Row>
306+ <Row>
307 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Delivery Requested Date')}</Data></Cell>
308 % if isDate(o.delivery_requested_date):
309 <Cell ss:StyleID="short_date" ><Data ss:Type="DateTime">${o.delivery_requested_date|n}T00:00:00.000</Data></Cell>
310@@ -123,28 +127,28 @@
311 % endif
312 </Row>
313 <Row>
314- <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Address name')}</Data></Cell>
315+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Delivery address name')}</Data></Cell>
316+ % if o.order_type == 'direct':
317+ <Cell ss:StyleID="line" ><Data ss:Type="String">${getContactName(o.dest_address_id.id) or ''|x}</Data></Cell>
318+ % else:
319 <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_address_id and o.dest_address_id.name or ''|x}</Data></Cell>
320- </Row>
321- <Row>
322- <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Address street')}</Data></Cell>
323- <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_address_id and o.dest_address_id.street or ''|x}</Data></Cell>
324- </Row>
325- <Row>
326- <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Address street 2')}</Data></Cell>
327- <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_address_id and o.dest_address_id.street2 or ''|x}</Data></Cell>
328- </Row>
329- <Row>
330- <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Zip')}</Data></Cell>
331- <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_address_id and o.dest_address_id.zip or ''|x}</Data></Cell>
332- </Row>
333- <Row>
334- <Cell ss:StyleID="header" ><Data ss:Type="String">${_('City')}</Data></Cell>
335- <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_address_id and o.dest_address_id.city or ''|x}</Data></Cell>
336- </Row>
337- <Row>
338- <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Country')}</Data></Cell>
339- <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_address_id and o.dest_address_id.country_id and o.dest_address_id.country_id.name or ''|x}</Data></Cell>
340+ % endif
341+ </Row>
342+ <Row>
343+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Delivery address')}</Data></Cell>
344+ % if o.order_type == 'direct':
345+ <Cell ss:StyleID="line" ><Data ss:Type="String">${o.dest_partner_id and o.dest_partner_id.name or ''|x}</Data></Cell>
346+ % else:
347+ <Cell ss:StyleID="line" ><Data ss:Type="String">${getInstanceName()|x}</Data></Cell>
348+ % endif
349+ </Row>
350+ <Row>
351+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Customer address name')}</Data></Cell>
352+ <Cell ss:StyleID="line" ><Data ss:Type="String">${getInstanceAddress() or ''|x}</Data></Cell>
353+ </Row>
354+ <Row>
355+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Customer address')}</Data></Cell>
356+ <Cell ss:StyleID="line" ><Data ss:Type="String">${getInstanceName()|x}</Data></Cell>
357 </Row>
358 <Row>
359 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Shipment Date')}</Data></Cell>
360@@ -170,6 +174,10 @@
361 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Message ESC Header')}</Data></Cell>
362 <Cell ss:StyleID="line" ><Data ss:Type="String">${o.message_esc or ''|x}</Data></Cell>
363 </Row>
364+ <Row>
365+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Sourcing group')}</Data></Cell>
366+ <Cell ss:StyleID="line" ><Data ss:Type="String">${o.related_sourcing_id and o.related_sourcing_id.name or ''|x}</Data></Cell>
367+ </Row>
368
369 % if need_ad and o.analytic_distribution_id:
370 <Row>
371@@ -219,6 +227,7 @@
372 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Price Unit*')}</Data></Cell>
373 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Currency*')}</Data></Cell>
374 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Origin*')}</Data></Cell>
375+ <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Stock Take Date')}</Data></Cell>
376 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Delivery requested date')}</Data></Cell>
377 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Delivery confirmed date*')}</Data></Cell>
378 <Cell ss:StyleID="header" ><Data ss:Type="String">${_('Nomen Name')}</Data></Cell>
379@@ -256,6 +265,7 @@
380 <Cell ss:StyleID="line" ><Data ss:Type="Number">${(line.price_unit or 0.00)|x}</Data></Cell>
381 <Cell ss:StyleID="line" ><Data ss:Type="String">${(o.pricelist_id.currency_id.name or '')|x}</Data></Cell>
382 <Cell ss:StyleID="line" ><Data ss:Type="String">${(line.origin or '')|x}</Data></Cell>
383+ <Cell ss:StyleID="short_date" ><Data ss:Type="DateTime">${line.stock_take_date|n}T00:00:00.000</Data></Cell>
384 % if isDate(line.date_planned):
385 <Cell ss:StyleID="short_date" ><Data ss:Type="DateTime">${line.date_planned|n}T00:00:00.000</Data></Cell>
386 % elif isDate(o.delivery_requested_date):
387
388=== modified file 'bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xml.mako'
389--- bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xml.mako 2017-11-17 09:15:40 +0000
390+++ bin/addons/msf_supply_doc_export/report/report_validated_purchase_order_xml.mako 2018-03-27 07:15:50 +0000
391@@ -12,6 +12,7 @@
392 % endif
393 <field name="partner_ref">${o.partner_ref or ''|x}</field>
394 <field name="details">${o.details or ''|x}</field>
395+ <field name="stock_take_date">${o.stock_take_date or ''|x}</field>
396 % if o.delivery_requested_date and o.delivery_requested_date not in (False, 'False'):
397 <field name="delivery_requested_date">${o.delivery_requested_date or ''|n}</field>
398 % else:
399@@ -24,14 +25,18 @@
400 <field name="ready_to_ship_date"></field>
401 % endif
402 <field name="dest_address_id" key="name,parent.partner_id">
403- <field name="name">${o.dest_address_id and o.dest_address_id.name or ''|x}</field>
404- <field name="street">${o.dest_address_id and o.dest_address_id.street or ''|x}</field>
405- <field name="street2">${o.dest_address_id and o.dest_address_id.street2 or ''|x}</field>
406- <field name="zip">${o.dest_address_id and o.dest_address_id.zip or ''|x}</field>
407- <field name="city">${o.dest_address_id and o.dest_address_id.city or ''|x}</field>
408- <field name="country_id" key="name">
409- <field name="name">${o.dest_address_id and o.dest_address_id.country_id and o.dest_address_id.country_id.name or ''|x}</field>
410- </field>
411+ % if o.order_type == 'direct':
412+ <field name="delivery_name">${getContactName(o.dest_address_id.id) or ''|x}</field>
413+ % else:
414+ <field name="delivery_name">${o.dest_address_id and o.dest_address_id.name or ''|x}</field>
415+ % endif
416+ % if o.order_type == 'direct':
417+ <field name="delivery_address">${o.dest_partner_id and o.dest_partner_id.name or ''|x}</field>
418+ % else:
419+ <field name="delivery_address">${getInstanceName()|x}</field>
420+ % endif
421+ <field name="customer_name">${getInstanceAddress() or ''|x}</field>
422+ <field name="customer_address">${getInstanceName()|x}</field>
423 </field>
424 % if o.shipment_date and o.shipment_date not in (False, 'False'):
425 <field name="shipment_date">${o.shipment_date|n}</field>
426@@ -42,6 +47,7 @@
427 <field name="origin">${o.origin or ''|x}</field>
428 <field name="project_ref">${o.fnct_project_ref or ''|x}</field>
429 <field name="message_esc">${o.message_esc or ''|x}</field>
430+ <field name="related_sourcing_id">${o.related_sourcing_id and o.related_sourcing_id.name or ''|x}</field>
431 <field name="analytic_distribution_id">
432 % if need_ad and o.analytic_distribution_id:
433 % for ccl in o.analytic_distribution_id.cost_center_lines:
434@@ -71,6 +77,7 @@
435 <field name="name">${l.currency_id and l.currency_id.name or ''|x}</field>
436 </field>
437 <field name="origin">${l.origin or ''|x}</field>
438+ <field name="stock_take_date">${l.stock_take_date or ''|x}</field>
439 % if l.date_planned and l.date_planned not in (False, 'False'):
440 <field name="date_planned">${l.date_planned|n}</field>
441 % else:
442
443=== modified file 'bin/addons/purchase/purchase_order.py'
444--- bin/addons/purchase/purchase_order.py 2018-02-22 14:23:17 +0000
445+++ bin/addons/purchase/purchase_order.py 2018-03-27 07:15:50 +0000
446@@ -646,8 +646,8 @@
447 'customer_ref': fields.function(_get_customer_ref, fnct_search=_src_customer_ref, method=True, string='Customer Ref.', type='text', store=False),
448 'line_count': fields.function(_get_line_count, method=True, type='integer', string="Line count", store=False),
449
450- 'date_approve':fields.date('Date Approved', readonly=1, select=True, help="Date on which purchase order has been approved"),
451- 'dest_address_id':fields.many2one('res.partner.address', 'Destination Address',
452+ 'date_approve': fields.date('Date Approved', readonly=1, select=True, help="Date on which purchase order has been approved"),
453+ 'dest_address_id': fields.many2one('res.partner.address', 'Destination Address',
454 help="Put an address if you want to deliver directly from the supplier to the customer." \
455 "In this case, it will remove the warehouse link and set the customer location."
456 ),

Subscribers

People subscribed via source and target branches

to all changes: