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

Proposed by jftempo
Status: Merged
Merged at revision: 4145
Proposed branch: lp:~unifield-team/unifield-server/us-1937
Merge into: lp:unifield-server
Diff against target: 92 lines (+26/-6)
2 files modified
bin/addons/msf_doc_import/wizard/abstract_wizard_import.py (+11/-3)
bin/addons/msf_doc_import/wizard/wizard_import_batch.py (+15/-3)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-1937
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+314810@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/abstract_wizard_import.py'
2--- bin/addons/msf_doc_import/wizard/abstract_wizard_import.py 2016-08-03 14:52:14 +0000
3+++ bin/addons/msf_doc_import/wizard/abstract_wizard_import.py 2017-01-16 10:08:29 +0000
4@@ -82,7 +82,8 @@
5 d = False
6 for dformat in date_format:
7 try:
8- d = str(DateTime.strptime(date_value, dformat))
9+ d = DateTime.strptime(date_value, dformat)
10+ d = d.strftime('%Y-%m-%d %H:%M:%S')
11 except ValueError:
12 continue
13
14@@ -363,7 +364,14 @@
15
16 file_obj.getNbRows()
17 # iterator on rows
18- return file_obj.getRows(), file_obj.getNbRows()
19+ try:
20+ res = file_obj.getRows(), file_obj.getNbRows()
21+ return res
22+ except TypeError as e:
23+ raise osv.except_osv(
24+ _('Error'),
25+ _('An error occurs during the reading of the file. Please contact an administrator and give him the import file and this error: %s') % e,
26+ )
27
28 def check_headers(self, headers_row, headers_title, context=None):
29 """
30@@ -454,4 +462,4 @@
31
32 return p_ids[0]
33
34-abstract_wizard_import()
35\ No newline at end of file
36+abstract_wizard_import()
37
38=== modified file 'bin/addons/msf_doc_import/wizard/wizard_import_batch.py'
39--- bin/addons/msf_doc_import/wizard/wizard_import_batch.py 2016-09-05 12:33:07 +0000
40+++ bin/addons/msf_doc_import/wizard/wizard_import_batch.py 2017-01-16 10:08:29 +0000
41@@ -24,6 +24,8 @@
42
43 import pooler
44
45+from datetime import datetime
46+
47 from osv import osv
48 from tools.translate import _
49
50@@ -128,6 +130,7 @@
51 prodlot_obj = self.pool.get('stock.production.lot')
52 product_obj = self.pool.get('product.product')
53 sequence_obj = self.pool.get('ir.sequence')
54+ date_tools = self.pool.get('date.tools')
55
56 if context is None:
57 context = {}
58@@ -170,13 +173,13 @@
59 # Product
60 product_id = None
61 try:
62- product_id = self.get_product_by_default_code(cr, uid, get_cell(line_data, 'product_id'),
63+ product_id = self.get_product_by_default_code(cr, uid, get_cell(line_data, 'product_id').strip(),
64 context=context)
65 except UnifieldImportException as e:
66 save_error(e)
67
68 # Batch number type
69- batch_type = get_cell(line_data, 'type')
70+ batch_type = get_cell(line_data, 'type').strip()
71 if batch_type.upper() not in (_('Standard').upper(), _('Internal').upper()):
72 save_error(
73 _('The Type of the batch number should be \'Standard\' or \'Internal\''),
74@@ -192,8 +195,17 @@
75 continue
76
77 # Make consistency checks
78- name = get_cell(line_data, 'name')
79+ name = get_cell(line_data, 'name').strip()
80 life_date = get_cell(line_data, 'life_date')
81+ if life_date and datetime.strptime(life_date, '%Y-%m-%d %H:%M:%S') < datetime(1900, 01, 01, 0, 0, 0):
82+ date_format = date_tools.get_date_format(cr, uid, context=context)
83+ save_error(
84+ _('You cannot create a batch number with an expiry date before %s') % (
85+ datetime(1900, 01, 01, 0, 0, 0).strftime(date_format),
86+ ),
87+ )
88+ continue
89+
90 product_brw = product_obj.read(cr, uid, product_id, ['batch_management', 'perishable'], context=context)
91
92 if not product_brw['batch_management'] and not product_brw['perishable']:

Subscribers

People subscribed via source and target branches

to all changes: