Merge lp:~unifield-team/unifield-wm/uf-2191 into lp:unifield-wm
- uf-2191
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 1854 |
Proposed branch: | lp:~unifield-team/unifield-wm/uf-2191 |
Merge into: | lp:unifield-wm |
Diff against target: |
130 lines (+48/-8) 2 files modified
kit/kit_creation.py (+44/-6) kit/kit_creation_view.xml (+4/-2) |
To merge this branch: | bzr merge lp:~unifield-team/unifield-wm/uf-2191 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Dev Team | Pending | ||
Review via email: mp+196100@code.launchpad.net |
Commit message
Description of the change
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 'kit/kit_creation.py' | |||
2 | --- kit/kit_creation.py 2013-10-07 14:53:32 +0000 | |||
3 | +++ kit/kit_creation.py 2013-11-21 13:07:00 +0000 | |||
4 | @@ -473,10 +473,11 @@ | |||
5 | 473 | data = {} | 473 | data = {} |
6 | 474 | # moves consolidated | 474 | # moves consolidated |
7 | 475 | move_list = [] | 475 | move_list = [] |
8 | 476 | move_manual = [] | ||
9 | 476 | 477 | ||
10 | 477 | for move in obj.consumed_ids_kit_creation: | 478 | for move in obj.consumed_ids_kit_creation: |
11 | 478 | # the stock move should not be canceled, but... we recycle them in case. | 479 | # the stock move should not be canceled, but... we recycle them in case. |
13 | 479 | if move.state in ['confirmed', 'cancel']: | 480 | if move.state in ['confirmed', 'cancel'] and not move.kol_lot_manual: |
14 | 480 | move_list.append(move.id) | 481 | move_list.append(move.id) |
15 | 481 | # consolidate the moves qty | 482 | # consolidate the moves qty |
16 | 482 | qty = data.setdefault(move.product_id.id, {}).setdefault('uoms', {}).setdefault(move.product_uom.id, {}).setdefault('qty', 0.0) | 483 | qty = data.setdefault(move.product_id.id, {}).setdefault('uoms', {}).setdefault(move.product_uom.id, {}).setdefault('qty', 0.0) |
17 | @@ -489,8 +490,10 @@ | |||
18 | 489 | data.setdefault(move.product_id.id, {}).setdefault('uoms', {})[move.product_uom.id]['qty'] = qty | 490 | data.setdefault(move.product_id.id, {}).setdefault('uoms', {})[move.product_uom.id]['qty'] = qty |
19 | 490 | # save object for efficiency | 491 | # save object for efficiency |
20 | 491 | data.setdefault(move.product_id.id, {}).setdefault('object', move.product_id) | 492 | data.setdefault(move.product_id.id, {}).setdefault('object', move.product_id) |
21 | 493 | elif move.kol_lot_manual: | ||
22 | 494 | move_manual.append(move.id) | ||
23 | 492 | 495 | ||
25 | 493 | return data, move_list | 496 | return data, move_list, move_manual |
26 | 494 | 497 | ||
27 | 495 | def consolidate_lines(self, cr, uid, ids, context=None): | 498 | def consolidate_lines(self, cr, uid, ids, context=None): |
28 | 496 | ''' | 499 | ''' |
29 | @@ -510,7 +513,7 @@ | |||
30 | 510 | 513 | ||
31 | 511 | for obj in self.browse(cr, uid, ids, context=context): | 514 | for obj in self.browse(cr, uid, ids, context=context): |
32 | 512 | # consolidate data | 515 | # consolidate data |
34 | 513 | data, move_list = self._consolidate_data(cr, uid, obj.id, context=context) | 516 | data, move_list, move_manual = self._consolidate_data(cr, uid, obj.id, context=context) |
35 | 514 | # delete stock moves | 517 | # delete stock moves |
36 | 515 | move_obj.unlink(cr, uid, move_list, context=dict(context, call_unlink=True)) | 518 | move_obj.unlink(cr, uid, move_list, context=dict(context, call_unlink=True)) |
37 | 516 | # default location | 519 | # default location |
38 | @@ -561,16 +564,41 @@ | |||
39 | 561 | loc_obj = self.pool.get('stock.location') | 564 | loc_obj = self.pool.get('stock.location') |
40 | 562 | prodlot_obj = self.pool.get('stock.production.lot') | 565 | prodlot_obj = self.pool.get('stock.production.lot') |
41 | 563 | data_tools_obj = self.pool.get('data.tools') | 566 | data_tools_obj = self.pool.get('data.tools') |
42 | 567 | uom_obj = self.pool.get('product.uom') | ||
43 | 564 | # load data into the context | 568 | # load data into the context |
44 | 565 | data_tools_obj.load_common_data(cr, uid, ids, context=context) | 569 | data_tools_obj.load_common_data(cr, uid, ids, context=context) |
45 | 566 | 570 | ||
46 | 567 | for obj in self.browse(cr, uid, ids, context=context): | 571 | for obj in self.browse(cr, uid, ids, context=context): |
47 | 568 | # consolidate data | 572 | # consolidate data |
49 | 569 | data, move_list = self._consolidate_data(cr, uid, obj.id, context=context) | 573 | data, move_list, move_manual = self._consolidate_data(cr, uid, obj.id, context=context) |
50 | 574 | # default location | ||
51 | 575 | default_location_id = obj.default_location_src_id_kit_creation.id | ||
52 | 576 | |||
53 | 577 | # Check availability of manual moves | ||
54 | 578 | for move in move_obj.browse(cr, uid, move_manual, context=context): | ||
55 | 579 | if move.state != 'confirmed' or not move.prodlot_id: | ||
56 | 580 | continue | ||
57 | 581 | |||
58 | 582 | location_ids = loc_obj.search(cr, uid, [('location_id', 'child_of', move.location_id.id)], context=context) | ||
59 | 583 | needed_qty = move.product_qty | ||
60 | 584 | for loc in location_ids: | ||
61 | 585 | available_qty = prodlot_obj.browse(cr, uid, move.prodlot_id.id, context=dict(context, location_id=loc)).stock_virtual | ||
62 | 586 | diff_qty = available_qty - uom_obj._compute_qty(cr, uid, move.product_uom.id, needed_qty, move.product_id.uom_id.id) | ||
63 | 587 | if diff_qty >= 0: | ||
64 | 588 | move_obj.write(cr, uid, [move.id], {'state': 'assigned'}, context=context) | ||
65 | 589 | break | ||
66 | 590 | else: | ||
67 | 591 | if available_qty: | ||
68 | 592 | move_obj.copy(cr, uid, move.id, {'product_qty': available_qty, 'state': 'assigned'}, context=context) | ||
69 | 593 | needed_qty -= available_qty | ||
70 | 594 | move_obj.write(cr, uid, [move.id], {'product_qty': needed_qty}, context=context) | ||
71 | 595 | else: | ||
72 | 596 | move_obj.write(cr, uid, [move.id], {'prodlot_id': False, 'kol_lot_manual': False}, context=context) | ||
73 | 597 | |||
74 | 598 | data, move_list, move_manual = self._consolidate_data(cr, uid, obj.id, context=context) | ||
75 | 570 | # delete stock moves | 599 | # delete stock moves |
76 | 571 | move_obj.unlink(cr, uid, move_list, context=dict(context, call_unlink=True)) | 600 | move_obj.unlink(cr, uid, move_list, context=dict(context, call_unlink=True)) |
79 | 572 | # default location | 601 | |
78 | 573 | default_location_id = obj.default_location_src_id_kit_creation.id | ||
80 | 574 | # create consolidated stock moves | 602 | # create consolidated stock moves |
81 | 575 | for product_id in data.keys(): | 603 | for product_id in data.keys(): |
82 | 576 | for uom_id in data[product_id]['uoms'].keys(): | 604 | for uom_id in data[product_id]['uoms'].keys(): |
83 | @@ -1250,6 +1278,7 @@ | |||
84 | 1250 | 'hidden_creation_state': fields.function(_vals_get_kit_creation, method=True, type='selection', selection=KIT_CREATION_STATE, string='Hidden Creation State', multi='get_vals_kit_creation', store=False, readonly=True), | 1278 | 'hidden_creation_state': fields.function(_vals_get_kit_creation, method=True, type='selection', selection=KIT_CREATION_STATE, string='Hidden Creation State', multi='get_vals_kit_creation', store=False, readonly=True), |
85 | 1251 | 'assigned_qty_stock_move': fields.function(_vals_get_kit_creation, method=True, type='float', string='Assigned Qty', multi='get_vals_kit_creation', store=False, readonly=True), | 1279 | 'assigned_qty_stock_move': fields.function(_vals_get_kit_creation, method=True, type='float', string='Assigned Qty', multi='get_vals_kit_creation', store=False, readonly=True), |
86 | 1252 | 'hidden_creation_qty_stock_move': fields.function(_vals_get_kit_creation, method=True, type='integer', string='Hidden Creation Qty', multi='get_vals_kit_creation', store=False, readonly=True), | 1280 | 'hidden_creation_qty_stock_move': fields.function(_vals_get_kit_creation, method=True, type='integer', string='Hidden Creation Qty', multi='get_vals_kit_creation', store=False, readonly=True), |
87 | 1281 | 'kol_lot_manual': fields.boolean(string='The batch is set manually'), | ||
88 | 1253 | } | 1282 | } |
89 | 1254 | 1283 | ||
90 | 1255 | _defaults = {'to_consume_id_stock_move': False, | 1284 | _defaults = {'to_consume_id_stock_move': False, |
91 | @@ -1273,6 +1302,15 @@ | |||
92 | 1273 | # open the selected wizard | 1302 | # open the selected wizard |
93 | 1274 | res = wiz_obj.open_wizard(cr, uid, ids, name=name, model=model, step=step, context=dict(context)) | 1303 | res = wiz_obj.open_wizard(cr, uid, ids, name=name, model=model, step=step, context=dict(context)) |
94 | 1275 | return res | 1304 | return res |
95 | 1305 | |||
96 | 1306 | def kol_prodlot_change(self, cr, uid, ids, prodlot_id, context=None): | ||
97 | 1307 | ''' | ||
98 | 1308 | Set a new attribute on stock move if the prodolt is change manually in the Kit order creation | ||
99 | 1309 | ''' | ||
100 | 1310 | if prodlot_id: | ||
101 | 1311 | return {'value': {'kol_lot_manual': True}} | ||
102 | 1312 | |||
103 | 1313 | return {'value': {'kol_lot_manual': False}} | ||
104 | 1276 | 1314 | ||
105 | 1277 | def automatic_assignment(self, cr, uid, ids, context=None): | 1315 | def automatic_assignment(self, cr, uid, ids, context=None): |
106 | 1278 | ''' | 1316 | ''' |
107 | 1279 | 1317 | ||
108 | === modified file 'kit/kit_creation_view.xml' | |||
109 | --- kit/kit_creation_view.xml 2013-10-07 14:53:32 +0000 | |||
110 | +++ kit/kit_creation_view.xml 2013-11-21 13:07:00 +0000 | |||
111 | @@ -77,7 +77,8 @@ | |||
112 | 77 | attrs="{'readonly': ['|', ('hidden_state', '!=', 'confirmed'), ('hidden_asset_check', '=', False)]}" /> | 77 | attrs="{'readonly': ['|', ('hidden_state', '!=', 'confirmed'), ('hidden_asset_check', '=', False)]}" /> |
113 | 78 | <field name="prodlot_id" | 78 | <field name="prodlot_id" |
114 | 79 | context="{'location_id':location_id, 'product_id':product_id, 'hidden_perishable_mandatory': hidden_perishable_mandatory, | 79 | context="{'location_id':location_id, 'product_id':product_id, 'hidden_perishable_mandatory': hidden_perishable_mandatory, |
116 | 80 | 'search_default_real': True}" | 80 | 'search_default_real': True}" |
117 | 81 | on_change="kol_prodlot_change(prodlot_id)" | ||
118 | 81 | domain="[('product_id', '=', product_id),('check_type','=', True)]" | 82 | domain="[('product_id', '=', product_id),('check_type','=', True)]" |
119 | 82 | attrs="{'readonly': ['|', ('hidden_state', '!=', 'confirmed'), ('hidden_exp_check', '=', False)], | 83 | attrs="{'readonly': ['|', ('hidden_state', '!=', 'confirmed'), ('hidden_exp_check', '=', False)], |
120 | 83 | 'required': [('hidden_exp_check', '=', True)]}" /> | 84 | 'required': [('hidden_exp_check', '=', True)]}" /> |
121 | @@ -88,7 +89,8 @@ | |||
122 | 88 | domain="[('usage', '=', 'internal')]" /> | 89 | domain="[('usage', '=', 'internal')]" /> |
123 | 89 | <field name="state" /> | 90 | <field name="state" /> |
124 | 90 | <field name="lot_check" /> | 91 | <field name="lot_check" /> |
126 | 91 | <field name="exp_check" /> | 92 | <field name="exp_check" /> |
127 | 93 | <field name="kol_lot_manual" invisible="True" /> | ||
128 | 92 | <field name="hidden_perishable_mandatory" invisible="True" /> | 94 | <field name="hidden_perishable_mandatory" invisible="True" /> |
129 | 93 | <field name="hidden_exp_check" invisible="True" /> | 95 | <field name="hidden_exp_check" invisible="True" /> |
130 | 94 | <field name="hidden_state" invisible="True" /> | 96 | <field name="hidden_state" invisible="True" /> |