Merge lp:~unifield-team/unifield-wm/uf-2179 into lp:unifield-wm

Proposed by jftempo
Status: Merged
Merged at revision: 2732
Proposed branch: lp:~unifield-team/unifield-wm/uf-2179
Merge into: lp:unifield-wm
Diff against target: 37 lines (+16/-4)
1 file modified
specific_rules/stock.py (+16/-4)
To merge this branch: bzr merge lp:~unifield-team/unifield-wm/uf-2179
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+283635@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 'specific_rules/stock.py'
2--- specific_rules/stock.py 2015-11-09 09:46:22 +0000
3+++ specific_rules/stock.py 2016-01-22 15:33:21 +0000
4@@ -244,17 +244,29 @@
5 _inherit = 'stock.inventory.line'
6
7 def _get_error_msg(self, cr, uid, ids, field_name, args, context=None):
8+ prodlot_obj = self.pool.get('stock.production.lot')
9+ dt_obj = self.pool.get('date.tools')
10 res = {}
11
12 for line in self.browse(cr, uid, ids, context=context):
13 res[line.id] = ''
14 if not line.location_id:
15- res[line.id] = 'You must define a stock location'
16+ res[line.id] = _('You must define a stock location')
17 if line.hidden_batch_management_mandatory and not line.prodlot_name:
18- res[line.id] = 'You must define a batch number'
19+ res[line.id] = _('You must define a batch number')
20 elif line.hidden_perishable_mandatory and not line.expiry_date:
21- res[line.id] = 'You must define an expiry date'
22-
23+ res[line.id] = _('You must define an expiry date')
24+ elif line.prodlot_name and line.expiry_date and line.product_id:
25+ prodlot_ids = prodlot_obj.search(cr, uid, [
26+ ('name', '=', line.prodlot_name),
27+ ('product_id', '=', line.product_id.id),
28+ ], context=context)
29+ if prodlot_ids:
30+ prodlot = prodlot_obj.browse(cr, uid, prodlot_ids[0], context=context)
31+ life_date = dt_obj.get_date_formatted(cr, uid, datetime=prodlot.life_date)
32+ if prodlot.life_date != line.expiry_date:
33+ res[line.id] = _('The batch number \'%s\' is already in the system but its expiry date is %s') % (line.prodlot_name, life_date)
34+
35 return res
36
37 _columns = {

Subscribers

People subscribed via source and target branches