Merge lp:~unifield-team/unifield-wm/us-895 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2759
Proposed branch: lp:~unifield-team/unifield-wm/us-895
Merge into: lp:unifield-wm
Diff against target: 260 lines (+88/-13)
5 files modified
consumption_calculation/weekly_forecast_report_view.xml (+1/-1)
msf_doc_import/initial_stock_inventory.py (+29/-3)
msf_doc_import/view/initial_stock_inventory_line_view.xml (+1/-0)
specific_rules/specific_rules.py (+46/-9)
specific_rules/stock.py (+11/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/us-895
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+285319@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 'consumption_calculation/weekly_forecast_report_view.xml'
2--- consumption_calculation/weekly_forecast_report_view.xml 2016-01-13 15:37:34 +0000
3+++ consumption_calculation/weekly_forecast_report_view.xml 2016-02-08 10:52:24 +0000
4@@ -124,7 +124,7 @@
5 </record>
6
7 <record id="action_weekly_forecast_report" model="ir.actions.act_window">
8- <field name="name">Periodical forecast reports</field>
9+ <field name="name">Periodical forecast report</field>
10 <field name="res_model">weekly.forecast.report</field>
11 <field name="view_type">form</field>
12 <field name="view_mode">tree,form</field>
13
14=== modified file 'msf_doc_import/initial_stock_inventory.py'
15--- msf_doc_import/initial_stock_inventory.py 2016-01-29 15:50:16 +0000
16+++ msf_doc_import/initial_stock_inventory.py 2016-02-08 10:52:24 +0000
17@@ -47,7 +47,7 @@
18 'file_to_import': fields.binary(string='File to import', filters='*.xml',
19 help="""You can use the template of the export for the format that you need to use. \n The file should be in XML Spreadsheet 2003 format.
20 \n The columns should be in this order : Product Code*, Product Description*, Location*, Batch, Expiry Date, Quantity"""),
21- 'import_error_ok':fields.function(_get_import_error, method=True, type="boolean", string="Error in Import", store=True),
22+ 'import_error_ok':fields.function(_get_import_error, method=True, type="boolean", string="Error in Import", store=False),
23 }
24
25 def _check_active_product(self, cr, uid, ids, context=None):
26@@ -221,6 +221,7 @@
27 'life_date': expiry,
28 'name': batch_name,
29 }, context=context)
30+ to_correct_ok = False
31 elif product.batch_management and not batch_name:
32 batch = False
33 to_correct_ok = True
34@@ -388,6 +389,7 @@
35
36 _columns = {
37 'batch_name': fields.char(size=128, string='Batch name'),
38+ 'inv_expiry_date': fields.date(string='Invisible expiry date'),
39 'to_correct_ok': fields.boolean('To correct'),
40 'comment': fields.text('Comment', readonly=True),
41 'inactive_product': fields.function(_get_inactive_product, method=True, type='boolean', string='Product is inactive', store=False, multi='inactive'),
42@@ -421,6 +423,9 @@
43 if 'location_not_found' in vals:
44 del vals['location_not_found']
45
46+ if not vals.get('expiry_date') and vals.get('inv_expiry_date'):
47+ vals['expiry_date'] = vals.get('inv_expiry_date')
48+
49 batch = vals.get('prod_lot_id')
50 expiry = vals.get('expiry_date')
51 batch_name = vals.get('batch_name')
52@@ -479,6 +484,7 @@
53 if hidden_batch_management_mandatory and batch and not expiry:
54 expiry = pl_obj.read(cr, uid, batch, ['life_date'], context=context)['life_date']
55 comment += _('Please check Expiry Date is correct!.\n')
56+ vals['to_correct_ok'] = True
57
58 if not comment:
59 if vals.get('comment'):
60@@ -934,6 +940,15 @@
61 comment += _('Incorrectly formatted expiry date. Batch not created.\n')
62 else:
63 comment += _('Batch is missing.\n')
64+ elif hidden_batch_management_mandatory and batch and expiry:
65+ batch_ids = pl_obj.search(cr, uid, [
66+ ('product_id', '=', product.id),
67+ ('life_date', '=', expiry),
68+ ('name', '!=', batch),
69+ ], context=context)
70+ if batch_ids:
71+ comment += _('Other batch exists for this expiry date')
72+ just_warn = True
73
74 if not product.batch_management and hidden_perishable_mandatory:
75 if expiry and batch:
76@@ -948,6 +963,16 @@
77 else:
78 batch = False
79 vals['prodlot_name'] = False
80+ if expiry and not batch:
81+ batch_ids = pl_obj.search(cr, uid, [
82+ ('product_id', '=', product.id),
83+ ('life_date', '=', expiry),
84+ ], context=context)
85+ if batch_ids:
86+ batch = False
87+ vals['prodlot_name'] = False
88+ comment += _('Other batch exists for this expiry date')
89+ just_warn = True
90 # if expiry and not batch:
91 # comment += _('Expiry date will be created (with its internal batch).\n')
92 # just_warn = True
93@@ -968,11 +993,12 @@
94 if hidden_batch_management_mandatory and batch and expiry:
95 pl_ids = pl_obj.search(cr, uid, [('name', '=', batch), ('product_id', '=', vals.get('product_id'))], context=context)
96 if pl_ids and pl_obj.read(cr, uid, pl_ids[0], ['life_date'], context=context)['life_date'] != expiry:
97- comment += _('Expiry date and batch not consistent.\n')
98+ comment += _('Please check expiry date is correct.\n')
99 vals.update({
100 'prod_lot_id': False,
101 'prodlot_name': '',
102 'expiry_date': False,
103+ 'to_correct_ok': True,
104 })
105
106 if not comment:
107@@ -983,7 +1009,7 @@
108 if just_warn:
109 vals.update({'comment': comment, 'to_correct_ok': False})
110 else:
111- vals.update({'comment': comment, 'to_correct_ok': False})
112+ vals.update({'comment': comment, 'to_correct_ok': True})
113
114
115 res = super(initial_stock_inventory_line, self).create(cr, uid, vals, context=context)
116
117=== modified file 'msf_doc_import/view/initial_stock_inventory_line_view.xml'
118--- msf_doc_import/view/initial_stock_inventory_line_view.xml 2013-11-18 15:25:54 +0000
119+++ msf_doc_import/view/initial_stock_inventory_line_view.xml 2016-02-08 10:52:24 +0000
120@@ -44,6 +44,7 @@
121 <field name="to_correct_ok" invisible="1" />
122 <field name="inactive_product" invisible="1" />
123 <field name="inactive_error" attrs="{'invisible': [('to_correct_ok', '=', False), ('inactive_product', '=,' False)]}" />
124+ <field name="inv_expiry_date" invisible="1" />
125 </xpath>
126 <xpath expr="/form/notebook/page/field[@name='inventory_line_id']/tree" position="attributes" >
127 <attribute name="colors">red:to_correct_ok ==True or has_problem == True or inactive_product == True</attribute>
128
129=== modified file 'specific_rules/specific_rules.py'
130--- specific_rules/specific_rules.py 2016-01-04 13:16:43 +0000
131+++ specific_rules/specific_rules.py 2016-02-08 10:52:24 +0000
132@@ -1433,9 +1433,12 @@
133 %s_line l
134 WHERE
135 l.inventory_id in %%s
136- GROUP BY l.product_id, l.location_id, l.prod_lot_id, l.expiry_date
137+ GROUP BY l.product_id, l.location_id, l.%s, l.expiry_date
138 HAVING count(l.id) > 1
139- ORDER BY count(l.id) DESC""" % self._name.replace('.', '_')
140+ ORDER BY count(l.id) DESC""" % (
141+ self._name.replace('.', '_'),
142+ self._name == 'stock.inventory' and 'prod_lot_id' or 'prodlot_name',
143+ )
144 cr.execute(sql_req, (tuple(ids),))
145 check_res = cr.dictfetchall()
146 if check_res:
147@@ -1462,10 +1465,23 @@
148
149 # treat the needed production lot
150 for obj in self.browse(cr, uid, ids, context=context):
151+ if obj.import_error_ok:
152+ raise osv.except_osv(
153+ _('Error'),
154+ _('Plase fix issue on red lines before confirm the inventory.')
155+ )
156+
157+ if any(l.to_correct_ok for l in obj.inventory_line_id):
158+ raise osv.except_osv(
159+ _('Error'),
160+ _('Please fix issue on red lines before confirm the inventory.')
161+ )
162+
163 for line in obj.inventory_line_id:
164 if self._name == 'initial.stock.inventory' and line.product_qty == 0.00:
165 line.write({'dont_move': True})
166 continue
167+
168 if line.hidden_perishable_mandatory and not line.expiry_date:
169 raise osv.except_osv(_('Error'), _('The product %s is perishable but the line with this product has no expiry date') % product_obj.name_get(cr, uid, [line.product_id.id])[0][1])
170 if line.hidden_batch_management_mandatory and not line.prod_lot_id:
171@@ -1478,8 +1494,16 @@
172 # if perishable product
173 if line.hidden_perishable_mandatory and not line.hidden_batch_management_mandatory:
174 # integrity test
175- assert line.product_id.perishable, 'product is not perishable but line is'
176- assert line.expiry_date, 'expiry date is not set'
177+ if not line.product_id.perishable:
178+ raise osv.except_osv(
179+ _('Error'),
180+ _('Product is not perishable but line is.')
181+ )
182+ if not line.expiry_date:
183+ raise osv.except_osv(
184+ _('Error'),
185+ _('Expiry date is not set'),
186+ )
187 # if no production lot, we create a new one
188 if not line.prod_lot_id:
189 # double check to find the corresponding prodlot
190@@ -1496,8 +1520,13 @@
191 prodlot_id = prodlot_obj.create(cr, uid, vals, context=context)
192 else:
193 prodlot_id = prodlot_ids[0]
194+ prodlot_name = prodlot_obj.read(cr, uid, prodlot_id, ['name'], context=context)['name']
195 # update the line
196- line.write({'prod_lot_id': prodlot_id,},)
197+ line.write({'prod_lot_id': prodlot_id, 'prodlot_name': prodlot_name},)
198+
199+ if line.prod_lot_id and not line.expiry_date:
200+ line.write({'expiry_date': line.prod_lot_id.life_date})
201+
202 line_ids.append(line.id)
203
204 if line_ids:
205@@ -1593,7 +1622,10 @@
206 expiry_date = prodlot_obj.browse(cr, uid, prod_lot_id).life_date
207 else:
208 expiry_date = False
209- result['value']['expiry_date'] = expiry_date
210+ result['value'].update({
211+ 'expiry_date': expiry_date,
212+ 'inv_expiry_date': expiry_date,
213+ })
214 if expiry_date:
215 prod_brw = prod_obj.browse(cr, uid, product)
216 # UFTP-50: got an expiry value,
217@@ -1797,14 +1829,19 @@
218 result[obj.id]['has_problem'] = True
219
220 result[obj.id]['duplicate_line'] = False
221- if self.search(cr, uid, [
222+ src_domain = [
223 ('inventory_id', '=', obj.inventory_id.id),
224 ('location_id', '=', obj.location_id.id),
225 ('product_id', '=', obj.product_id.id),
226- ('prod_lot_id', '=', obj.prod_lot_id and obj.prod_lot_id.id or False),
227 ('expiry_date', '=', obj.expiry_date or False),
228 ('id', '!=', obj.id),
229- ], limit=1, context=context):
230+ ]
231+
232+ if self._name == 'initial.stock.inventory.line':
233+ src_domain.append(('prodlot_name', '=', obj.prodlot_name))
234+ else:
235+ src_domain.append(('prod_lot_id', '=', obj.prod_lot_id and obj.prod_lot_id.id or False))
236+ if self.search(cr, uid, src_domain, limit=1, context=context):
237 result[obj.id]['duplicate_line'] = True
238 return result
239
240
241=== modified file 'specific_rules/stock.py'
242--- specific_rules/stock.py 2016-01-22 15:35:00 +0000
243+++ specific_rules/stock.py 2016-02-08 10:52:24 +0000
244@@ -119,6 +119,17 @@
245
246 self.pool.get('initial.stock.inventory.line').write(cr, uid, [inventory_line.id], {'prod_lot_id': prodlot_id}, context=context)
247
248+ if inventory_line.product_id.perishable and not inventory_line.product_id.batch_management:
249+ if not inventory_line.prodlot_name and inventory_line.expiry_date:
250+ prodlot_ids = prodlot_obj.search(cr, uid, [
251+ ('type', '=', 'internal'),
252+ ('product_id', '=', inventory_line.product_id.id),
253+ ('life_date', '=', inventory_line.expiry_date),
254+ ], context=context)
255+ if prodlot_ids:
256+ self.pool.get('initial.stock.inventory.line').write(cr, uid, [inventory_line.id], {
257+ 'prodlot_name': prodlot_obj.read(cr, uid, prodlot_ids[0], ['name'], context=context)['name'],
258+ }, context=context)
259
260 return super(initial_stock_inventory, self).action_confirm(cr, uid, ids, context=context)
261

Subscribers

People subscribed via source and target branches