Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #This file is part of Tryton. The COPYRIGHT file at the top level of | 1 #This file is part of Tryton. The COPYRIGHT file at the top level of |
2 #this repository contains the full copyright notices and license terms. | 2 #this repository contains the full copyright notices and license terms. |
3 "Shipment" | 3 "Shipment" |
4 from trytond.model import ModelWorkflow, ModelView, ModelSQL, fields | 4 from trytond.model import ModelWorkflow, ModelView, ModelSQL, fields |
5 from trytond.modules.company import CompanyReport | 5 from trytond.modules.company import CompanyReport |
6 from trytond.wizard import Wizard | 6 from trytond.wizard import Wizard |
7 from trytond.backend import TableHandler | 7 from trytond.backend import TableHandler |
8 from trytond.pyson import Eval, Not, Equal, If, Or, And, Bool, In | |
8 | 9 |
9 STATES = { | 10 STATES = { |
10 'readonly': "state in ('cancel', 'done')", | 11 'readonly': "state in ('cancel', 'done')", |
11 } | 12 } |
12 | 13 |
13 | 14 |
14 class ShipmentIn(ModelWorkflow, ModelSQL, ModelView): | 15 class ShipmentIn(ModelWorkflow, ModelSQL, ModelView): |
15 "Supplier Shipment" | 16 "Supplier Shipment" |
16 _name = 'stock.shipment.in' | 17 _name = 'stock.shipment.in' |
17 _description = __doc__ | 18 _description = __doc__ |
18 _rec_name = 'code' | 19 _rec_name = 'code' |
19 | 20 |
20 effective_date = fields.Date('Effective Date', readonly=True) | 21 effective_date = fields.Date('Effective Date', readonly=True) |
21 planned_date = fields.Date( | 22 planned_date = fields.Date('Planned Date', states={ |
22 'Planned Date', states={'readonly': "state != 'draft'",}) | 23 'readonly': Not(Equal(Eval('state'), 'draft')), |
23 reference = fields.Char( | 24 }) |
24 "Reference", size=None, select=1, | 25 reference = fields.Char("Reference", size=None, select=1, |
25 states={'readonly': "state != 'draft'",}) | 26 states={ |
27 'readonly': Not(Equal(Eval('state'), 'draft')), | |
28 }) | |
26 supplier = fields.Many2One('party.party', 'Supplier', | 29 supplier = fields.Many2One('party.party', 'Supplier', |
27 states={ | 30 states={ |
28 'readonly': "(state != 'draft' or bool(incoming_moves)) " \ | 31 'readonly': And(Or(Not(Equal(Eval('state'), 'draft')), |
29 "and bool(supplier)", | 32 Bool(Eval('incoming_moves'))), Bool(Eval('supplier'))), |
30 }, on_change=['supplier'], required=True) | 33 }, on_change=['supplier'], required=True) |
31 contact_address = fields.Many2One('party.address', 'Contact Address', | 34 contact_address = fields.Many2One('party.address', 'Contact Address', |
32 states={ | 35 states={ |
33 'readonly': "state != 'draft'", | 36 'readonly': Not(Equal(Eval('state'), 'draft')), |
34 }, domain=["('party', '=', supplier)"]) | 37 }, domain=[('party', '=', Eval('supplier'))]) |
35 warehouse = fields.Many2One('stock.location', "Warehouse", | 38 warehouse = fields.Many2One('stock.location', "Warehouse", |
36 required=True, domain=[('type', '=', 'warehouse')], | 39 required=True, domain=[('type', '=', 'warehouse')], |
37 states={ | 40 states={ |
38 'readonly': "state in ('cancel', 'done') or " \ | 41 'readonly': Or(In(Eval('state'), ['cancel', 'done']), |
39 "bool(incoming_moves)", | 42 Bool(Eval('incoming_moves'))), |
40 }) | 43 }) |
41 incoming_moves = fields.Function('get_incoming_moves', type='one2many', | 44 incoming_moves = fields.Function('get_incoming_moves', type='one2many', |
42 relation='stock.move', string='Incoming Moves', | 45 relation='stock.move', string='Incoming Moves', |
43 fnct_inv='set_incoming_moves', add_remove="[" \ | 46 fnct_inv='set_incoming_moves', add_remove=[ |
44 "('shipment_in', '=', False),"\ | 47 ('shipment_in', '=', False), |
45 "('from_location.type', '=', 'supplier'),"\ | 48 ('from_location.type', '=', 'supplier'), |
46 "('state', '=', 'draft'),"\ | 49 ('state', '=', 'draft'), |
47 "('to_location_warehouse', '=', warehouse),"\ | 50 ('to_location_warehouse', '=', Eval('warehouse')), |
48 "]", | 51 ], |
49 states={ | 52 states={ |
50 'readonly': "state in ('received', 'done', 'cancel') "\ | 53 'readonly': Or(In(Eval('state'), |
51 "or not bool(warehouse)", | 54 ['received', 'done', 'cancel']), |
52 }, context="{'warehouse': warehouse, 'type': 'incoming'," \ | 55 Not(Bool(Eval('warehouse')))), |
53 "'supplier': supplier}") | 56 }, context={ |
57 'warehouse': Eval('warehouse'), | |
58 'type': 'incoming', | |
59 'supplier': Eval('supplier'), | |
60 }) | |
54 inventory_moves = fields.Function('get_inventory_moves', type='one2many', | 61 inventory_moves = fields.Function('get_inventory_moves', type='one2many', |
55 relation='stock.move', string='Inventory Moves', | 62 relation='stock.move', string='Inventory Moves', |
56 fnct_inv='set_inventory_moves', | 63 fnct_inv='set_inventory_moves', |
57 states={ | 64 states={ |
58 'readonly': "state in ('draft', 'done', 'cancel')", | 65 'readonly': In(Eval('state'), ['draft', 'done', 'cancel']), |
59 }, context="{'warehouse': warehouse, 'type': 'inventory_in'}") | 66 }, context={ |
67 'warehouse': Eval('warehouse'), | |
68 'type': 'inventory_in', | |
69 }) | |
60 moves = fields.One2Many('stock.move', 'shipment_in', 'Moves', | 70 moves = fields.One2Many('stock.move', 'shipment_in', 'Moves', |
61 readonly=True) | 71 readonly=True) |
62 code = fields.Char("Code", size=None, select=1, readonly=True) | 72 code = fields.Char("Code", size=None, select=1, readonly=True) |
63 state = fields.Selection([ | 73 state = fields.Selection([ |
64 ('draft', 'Draft'), | 74 ('draft', 'Draft'), |
65 ('done', 'Done'), | 75 ('done', 'Done'), |
66 ('cancel', 'Canceled'), | 76 ('cancel', 'Canceled'), |
67 ('received', 'Received'), | 77 ('received', 'Received'), |
68 ], 'State', readonly=True) | 78 ], 'State', readonly=True) |
69 | 79 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 shipment.warehouse.input_location.id: | 173 shipment.warehouse.input_location.id: |
164 self.raise_user_error(cursor, | 174 self.raise_user_error(cursor, |
165 'incoming_move_input_dest', context=context) | 175 'incoming_move_input_dest', context=context) |
166 elif act[0] == 'write': | 176 elif act[0] == 'write': |
167 if 'to_location' in act[2]: | 177 if 'to_location' in act[2]: |
168 if act[2]['to_location'] != \ | 178 if act[2]['to_location'] != \ |
169 shipment.warehouse.input_location.id: | 179 shipment.warehouse.input_location.id: |
170 self.raise_user_error(cursor, | 180 self.raise_user_error(cursor, |
171 'incoming_move_input_dest', context=context) | 181 'incoming_move_input_dest', context=context) |
172 elif act[0] == 'add': | 182 elif act[0] == 'add': |
173 move_ids.append(act[1]) | 183 if isinstance(act[1], (int, long)): |
184 move_ids.append(act[1]) | |
185 else: | |
186 move_ids.extend(act[1]) | |
174 elif act[0] == 'set': | 187 elif act[0] == 'set': |
175 move_ids.extend(act[1]) | 188 move_ids.extend(act[1]) |
176 | 189 |
177 moves = move_obj.browse(cursor, user, move_ids, context=context) | 190 moves = move_obj.browse(cursor, user, move_ids, context=context) |
178 for move in moves: | 191 for move in moves: |
179 if move.to_location.id != \ | 192 if move.to_location.id != \ |
180 shipment.warehouse.input_location.id: | 193 shipment.warehouse.input_location.id: |
181 self.raise_user_error(cursor, | 194 self.raise_user_error(cursor, |
182 'incoming_move_input_dest', context=context) | 195 'incoming_move_input_dest', context=context) |
183 | 196 |
(...skipping 26 matching lines...) Expand all Loading... | |
210 shipment.warehouse.input_location.id: | 223 shipment.warehouse.input_location.id: |
211 self.raise_user_error(cursor, | 224 self.raise_user_error(cursor, |
212 'inventory_move_input_source', context=context) | 225 'inventory_move_input_source', context=context) |
213 elif act[0] == 'write': | 226 elif act[0] == 'write': |
214 if 'from_location' in act[2]: | 227 if 'from_location' in act[2]: |
215 if act[2]['from_location'] != \ | 228 if act[2]['from_location'] != \ |
216 shipment.warehouse.input_location.id: | 229 shipment.warehouse.input_location.id: |
217 self.raise_user_error(cursor, | 230 self.raise_user_error(cursor, |
218 'inventory_move_input_source', context=context) | 231 'inventory_move_input_source', context=context) |
219 elif act[0] == 'add': | 232 elif act[0] == 'add': |
220 move_ids.append(act[1]) | 233 if isinstance(act[1], (int, long)): |
234 move_ids.append(act[1]) | |
235 else: | |
236 move_ids.extend(act[1]) | |
221 elif act[0] == 'set': | 237 elif act[0] == 'set': |
222 move_ids.extend(act[1]) | 238 move_ids.extend(act[1]) |
223 | 239 |
224 moves = move_obj.browse(cursor, user, move_ids, context=context) | 240 moves = move_obj.browse(cursor, user, move_ids, context=context) |
225 for move in moves: | 241 for move in moves: |
226 if move.from_location.id != \ | 242 if move.from_location.id != \ |
227 shipment.warehouse.input_location.id: | 243 shipment.warehouse.input_location.id: |
228 self.raise_user_error(cursor, | 244 self.raise_user_error(cursor, |
229 'inventory_move_input_source', context=context) | 245 'inventory_move_input_source', context=context) |
230 | 246 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 ShipmentIn() | 351 ShipmentIn() |
336 | 352 |
337 | 353 |
338 class ShipmentInReturn(ModelWorkflow, ModelSQL, ModelView): | 354 class ShipmentInReturn(ModelWorkflow, ModelSQL, ModelView): |
339 "Supplier Return Shipment" | 355 "Supplier Return Shipment" |
340 _name = 'stock.shipment.in.return' | 356 _name = 'stock.shipment.in.return' |
341 _description = __doc__ | 357 _description = __doc__ |
342 _rec_name = 'code' | 358 _rec_name = 'code' |
343 | 359 |
344 effective_date =fields.Date('Effective Date', readonly=True) | 360 effective_date =fields.Date('Effective Date', readonly=True) |
345 planned_date = fields.Date( | 361 planned_date = fields.Date('Planned Date', |
346 'Planned Date', states={'readonly': "state != 'draft'",}) | 362 states={ |
363 'readonly': Not(Equal(Eval('state'), 'draft')), | |
364 }) | |
347 code = fields.Char("Code", size=None, select=1, readonly=True) | 365 code = fields.Char("Code", size=None, select=1, readonly=True) |
348 reference = fields.Char( | 366 reference = fields.Char("Reference", size=None, select=1, |
349 "Reference", size=None, select=1, | 367 states={ |
350 states={'readonly': "state != 'draft'",}) | 368 'readonly': Not(Equal(Eval('state'), 'draft')), |
351 from_location = fields.Many2One( | 369 }) |
352 'stock.location', "From Location", required=True, | 370 from_location = fields.Many2One('stock.location', "From Location", |
353 states={ 'readonly': "state != 'draft' or bool(moves)", }, | 371 required=True, states={ |
354 domain=[('type', '=', 'storage')]) | 372 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
373 Bool(Eval('moves'))), | |
374 }, domain=[('type', '=', 'storage')]) | |
355 to_location = fields.Many2One('stock.location', "To Location", | 375 to_location = fields.Many2One('stock.location', "To Location", |
356 required=True, states={ | 376 required=True, states={ |
357 'readonly': "state != 'draft' or bool(moves)", | 377 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
378 Bool(Eval('moves'))), | |
358 }, domain=[('type', '=', 'supplier')]) | 379 }, domain=[('type', '=', 'supplier')]) |
359 moves = fields.One2Many( | 380 moves = fields.One2Many('stock.move', 'shipment_in_return', 'Moves', |
360 'stock.move', 'shipment_in_return', 'Moves', | 381 states={ |
361 states={'readonly': "state != 'draft' or "\ | 382 'readonly': And(Or(Not(Equal(Eval('state'), 'draft')), |
362 "not(bool(from_location) and bool (to_location))"}, | 383 Not(Bool(Eval('from_location')))), |
363 context="{'from_location': from_location," | 384 Bool(Eval('to_location'))), |
364 "'to_location': to_location," | 385 }, |
365 "'planned_date': planned_date}", | 386 context={ |
366 ) | 387 'from_location': Eval('from_location'), |
388 'to_location': Eval('to_location'), | |
389 'planned_date': Eval('planned_date'), | |
390 }) | |
367 state = fields.Selection([ | 391 state = fields.Selection([ |
368 ('draft', 'Draft'), | 392 ('draft', 'Draft'), |
369 ('cancel', 'Canceled'), | 393 ('cancel', 'Canceled'), |
370 ('assigned', 'Assigned'), | 394 ('assigned', 'Assigned'), |
371 ('waiting', 'Waiting'), | 395 ('waiting', 'Waiting'), |
372 ('done', 'Done'), | 396 ('done', 'Done'), |
373 ], 'State', readonly=True) | 397 ], 'State', readonly=True) |
374 | 398 |
375 def default_state(self, cursor, user, context=None): | 399 def default_state(self, cursor, user, context=None): |
376 return 'draft' | 400 return 'draft' |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 | 542 |
519 class ShipmentOut(ModelWorkflow, ModelSQL, ModelView): | 543 class ShipmentOut(ModelWorkflow, ModelSQL, ModelView): |
520 "Customer Shipment" | 544 "Customer Shipment" |
521 _name = 'stock.shipment.out' | 545 _name = 'stock.shipment.out' |
522 _description = __doc__ | 546 _description = __doc__ |
523 _rec_name = 'code' | 547 _rec_name = 'code' |
524 | 548 |
525 effective_date = fields.Date('Effective Date', readonly=True) | 549 effective_date = fields.Date('Effective Date', readonly=True) |
526 planned_date = fields.Date('Planned Date', | 550 planned_date = fields.Date('Planned Date', |
527 states={ | 551 states={ |
528 'readonly': "state != 'draft'", | 552 'readonly': Not(Equal(Eval('state'), 'draft')), |
529 }) | 553 }) |
530 customer = fields.Many2One('party.party', 'Customer', required=True, | 554 customer = fields.Many2One('party.party', 'Customer', required=True, |
531 states={ | 555 states={ |
532 'readonly': "state != 'draft' or bool(outgoing_moves)", | 556 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
557 Bool(Eval('outgoing_moves'))), | |
533 }, on_change=['customer']) | 558 }, on_change=['customer']) |
534 delivery_address = fields.Many2One('party.address', | 559 delivery_address = fields.Many2One('party.address', |
535 'Delivery Address', required=True, | 560 'Delivery Address', required=True, |
536 states={ | 561 states={ |
537 'readonly': "state != 'draft'", | 562 'readonly': Not(Equal(Eval('state'), 'draft')), |
538 }, domain=["('party', '=', customer)"]) | 563 }, domain=[('party', '=', Eval('customer'))]) |
539 reference = fields.Char("Reference", size=None, select=1, | 564 reference = fields.Char("Reference", size=None, select=1, |
540 states={ | 565 states={ |
541 'readonly': "state != 'draft'", | 566 'readonly': Not(Equal(Eval('state'), 'draft')), |
542 }) | 567 }) |
543 warehouse = fields.Many2One('stock.location', "Warehouse", required=True, | 568 warehouse = fields.Many2One('stock.location', "Warehouse", required=True, |
544 states={ | 569 states={ |
545 'readonly': "state != 'draft' or bool(outgoing_moves)", | 570 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
571 Bool(Eval('outgoing_moves'))), | |
546 }, domain=[('type', '=', 'warehouse')]) | 572 }, domain=[('type', '=', 'warehouse')]) |
547 outgoing_moves = fields.Function('get_outgoing_moves', type='one2many', | 573 outgoing_moves = fields.Function('get_outgoing_moves', type='one2many', |
548 relation='stock.move', string='Outgoing Moves', | 574 relation='stock.move', string='Outgoing Moves', |
549 fnct_inv='set_outgoing_moves', | 575 fnct_inv='set_outgoing_moves', |
550 states={ | 576 states={ |
551 'readonly':"state != 'draft' or not bool(warehouse)", | 577 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
552 }, context="{'warehouse': warehouse, 'type': 'outgoing'," \ | 578 Not(Bool(Eval('warehouse')))), |
553 "'customer': customer}") | 579 }, context={ |
580 'warehouse': Eval('warehouse'), | |
581 'type': 'outgoing', | |
582 'customer': Eval('customer'), | |
583 }) | |
554 inventory_moves = fields.Function('get_inventory_moves', type='one2many', | 584 inventory_moves = fields.Function('get_inventory_moves', type='one2many', |
555 relation='stock.move', string='Inventory Moves', | 585 relation='stock.move', string='Inventory Moves', |
556 fnct_inv='set_inventory_moves', | 586 fnct_inv='set_inventory_moves', |
557 states={ | 587 states={ |
558 'readonly':"state in ('draft', 'packed', 'done')", | 588 'readonly': In(Eval('state'), ['draft', 'packed', 'done']), |
559 }, context="{'warehouse': warehouse, 'type': 'inventory_out',}") | 589 }, context={ |
590 'warehouse': Eval('warehouse'), | |
591 'type': 'inventory_out', | |
592 }) | |
560 moves = fields.One2Many('stock.move', 'shipment_out', 'Moves', | 593 moves = fields.One2Many('stock.move', 'shipment_out', 'Moves', |
561 readonly=True) | 594 readonly=True) |
562 code = fields.Char("Code", size=None, select=1, readonly=True) | 595 code = fields.Char("Code", size=None, select=1, readonly=True) |
563 state = fields.Selection([ | 596 state = fields.Selection([ |
564 ('draft', 'Draft'), | 597 ('draft', 'Draft'), |
565 ('done', 'Done'), | 598 ('done', 'Done'), |
566 ('cancel', 'Canceled'), | 599 ('cancel', 'Canceled'), |
567 ('assigned', 'Assigned'), | 600 ('assigned', 'Assigned'), |
568 ('packed', 'Packed'), | 601 ('packed', 'Packed'), |
569 ('waiting', 'Waiting'), | 602 ('waiting', 'Waiting'), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 shipment.warehouse.output_location.id: | 684 shipment.warehouse.output_location.id: |
652 self.raise_user_error(cursor, | 685 self.raise_user_error(cursor, |
653 'outgoing_move_output_source', context=context) | 686 'outgoing_move_output_source', context=context) |
654 elif act[0] == 'write': | 687 elif act[0] == 'write': |
655 if 'from_location' in act[2]: | 688 if 'from_location' in act[2]: |
656 if act[2]['from_location'] != \ | 689 if act[2]['from_location'] != \ |
657 shipment.warehouse.output_location.id: | 690 shipment.warehouse.output_location.id: |
658 self.raise_user_error(cursor, | 691 self.raise_user_error(cursor, |
659 'outgoing_move_output_source', context=context) | 692 'outgoing_move_output_source', context=context) |
660 elif act[0] == 'add': | 693 elif act[0] == 'add': |
661 move_ids.append(act[1]) | 694 if isinstance(act[1], (int, long)): |
695 move_ids.append(act[1]) | |
696 else: | |
697 move_ids.extend(act[1]) | |
662 elif act[0] == 'set': | 698 elif act[0] == 'set': |
663 move_ids.extend(act[1]) | 699 move_ids.extend(act[1]) |
664 | 700 |
665 moves = move_obj.browse(cursor, user, move_ids, context=context) | 701 moves = move_obj.browse(cursor, user, move_ids, context=context) |
666 for move in moves: | 702 for move in moves: |
667 if move.from_location.id != \ | 703 if move.from_location.id != \ |
668 shipment.warehouse.output_location.id: | 704 shipment.warehouse.output_location.id: |
669 self.raise_user_error(cursor, | 705 self.raise_user_error(cursor, |
670 'outgoing_move_output_source', context=context) | 706 'outgoing_move_output_source', context=context) |
671 self.write(cursor, user, shipment_id, { | 707 self.write(cursor, user, shipment_id, { |
(...skipping 26 matching lines...) Expand all Loading... | |
698 shipment.warehouse.output_location.id: | 734 shipment.warehouse.output_location.id: |
699 self.raise_user_error(cursor, | 735 self.raise_user_error(cursor, |
700 'inventory_move_output_dest', context=context) | 736 'inventory_move_output_dest', context=context) |
701 elif act[0] == 'write': | 737 elif act[0] == 'write': |
702 if 'to_location' in act[2]: | 738 if 'to_location' in act[2]: |
703 if act[2]['to_location'] != \ | 739 if act[2]['to_location'] != \ |
704 shipment.warehouse.output_location.id: | 740 shipment.warehouse.output_location.id: |
705 self.raise_user_error(cursor, | 741 self.raise_user_error(cursor, |
706 'inventory_move_output_dest', context=context) | 742 'inventory_move_output_dest', context=context) |
707 elif act[0] == 'add': | 743 elif act[0] == 'add': |
708 move_ids.append(act[1]) | 744 if isinstance(act[1], (int, long)): |
745 move_ids.append(act[1]) | |
746 else: | |
747 move_ids.extend(act[1]) | |
709 elif act[0] == 'set': | 748 elif act[0] == 'set': |
710 move_ids.extend(act[1]) | 749 move_ids.extend(act[1]) |
711 | 750 |
712 moves = move_obj.browse(cursor, user, move_ids, context=context) | 751 moves = move_obj.browse(cursor, user, move_ids, context=context) |
713 for move in moves: | 752 for move in moves: |
714 if move.to_location.id != \ | 753 if move.to_location.id != \ |
715 shipment.warehouse.output_location.id: | 754 shipment.warehouse.output_location.id: |
716 self.raise_user_error(cursor, | 755 self.raise_user_error(cursor, |
717 'inventory_move_output_dest', context=context) | 756 'inventory_move_output_dest', context=context) |
718 self.write(cursor, user, shipment_id, { | 757 self.write(cursor, user, shipment_id, { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
932 | 971 |
933 class ShipmentOutReturn(ModelWorkflow, ModelSQL, ModelView): | 972 class ShipmentOutReturn(ModelWorkflow, ModelSQL, ModelView): |
934 "Customer Return Shipment" | 973 "Customer Return Shipment" |
935 _name = 'stock.shipment.out.return' | 974 _name = 'stock.shipment.out.return' |
936 _description = __doc__ | 975 _description = __doc__ |
937 _rec_name = 'code' | 976 _rec_name = 'code' |
938 | 977 |
939 effective_date = fields.Date('Effective Date', readonly=True) | 978 effective_date = fields.Date('Effective Date', readonly=True) |
940 planned_date = fields.Date('Planned Date', | 979 planned_date = fields.Date('Planned Date', |
941 states={ | 980 states={ |
942 'readonly': "state != 'draft'", | 981 'readonly': Not(Equal(Eval('state'), 'draft')), |
943 }) | 982 }) |
944 customer = fields.Many2One('party.party', 'Customer', required=True, | 983 customer = fields.Many2One('party.party', 'Customer', required=True, |
945 states={ | 984 states={ |
946 'readonly': "state != 'draft' or bool(incoming_moves)", | 985 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
986 Bool(Eval('incoming_moves'))), | |
947 }, on_change=['customer']) | 987 }, on_change=['customer']) |
948 delivery_address = fields.Many2One('party.address', | 988 delivery_address = fields.Many2One('party.address', |
949 'Delivery Address', required=True, | 989 'Delivery Address', required=True, |
950 states={ | 990 states={ |
951 'readonly': "state != 'draft'", | 991 'readonly': Not(Equal(Eval('state'), 'draft')), |
952 }, domain=["('party', '=', customer)"]) | 992 }, domain=[('party', '=', Eval('customer'))]) |
953 reference = fields.Char("Reference", size=None, select=1, | 993 reference = fields.Char("Reference", size=None, select=1, |
954 states={ | 994 states={ |
955 'readonly': "state != 'draft'", | 995 'readonly': Not(Equal(Eval('state'), 'draft')), |
956 }) | 996 }) |
957 warehouse = fields.Many2One('stock.location', "Warehouse", required=True, | 997 warehouse = fields.Many2One('stock.location', "Warehouse", required=True, |
958 states={ | 998 states={ |
959 'readonly': "state != 'draft' or bool(incoming_moves)", | 999 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
1000 Bool(Eval('incoming_moves'))), | |
960 }, domain=[('type', '=', 'warehouse')]) | 1001 }, domain=[('type', '=', 'warehouse')]) |
961 incoming_moves = fields.Function('get_incoming_moves', type='one2many', | 1002 incoming_moves = fields.Function('get_incoming_moves', type='one2many', |
962 relation='stock.move', string='Incoming Moves', | 1003 relation='stock.move', string='Incoming Moves', |
963 fnct_inv='set_incoming_moves', | 1004 fnct_inv='set_incoming_moves', |
964 states={ | 1005 states={ |
965 'readonly':"state != 'draft'", | 1006 'readonly': Not(Equal(Eval('state'), 'draft')), |
966 }, context="{'warehouse': warehouse, 'type': 'incoming'," \ | 1007 }, context={ |
967 "'customer': customer}") | 1008 'warehouse': Eval('warehouse'), |
1009 'type': 'incoming', | |
1010 'customer': Eval('customer'), | |
1011 }) | |
968 inventory_moves = fields.Function('get_inventory_moves', type='one2many', | 1012 inventory_moves = fields.Function('get_inventory_moves', type='one2many', |
969 relation='stock.move', string='Inventory Moves', | 1013 relation='stock.move', string='Inventory Moves', |
970 fnct_inv='set_inventory_moves', | 1014 fnct_inv='set_inventory_moves', |
971 states={ | 1015 states={ |
972 'readonly':"state in ('draft', 'cancel', 'done')", | 1016 'readonly': In(Eval('state'), ['draft', 'cancel', 'done']), |
973 }, context="{'warehouse': warehouse, 'type': 'inventory_out',}") | 1017 }, context={ |
1018 'warehouse': Eval('warehouse'), | |
1019 'type': 'inventory_out', | |
1020 }) | |
974 moves = fields.One2Many('stock.move', 'shipment_out_return', 'Moves', | 1021 moves = fields.One2Many('stock.move', 'shipment_out_return', 'Moves', |
975 readonly=True) | 1022 readonly=True) |
976 code = fields.Char("Code", size=None, select=1, readonly=True) | 1023 code = fields.Char("Code", size=None, select=1, readonly=True) |
977 state = fields.Selection([ | 1024 state = fields.Selection([ |
978 ('draft', 'Draft'), | 1025 ('draft', 'Draft'), |
979 ('done', 'Done'), | 1026 ('done', 'Done'), |
980 ('cancel', 'Canceled'), | 1027 ('cancel', 'Canceled'), |
981 ('received', 'Received'), | 1028 ('received', 'Received'), |
982 ], 'State', readonly=True) | 1029 ], 'State', readonly=True) |
983 | 1030 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 shipment.warehouse.input_location.id: | 1114 shipment.warehouse.input_location.id: |
1068 self.raise_user_error(cursor, | 1115 self.raise_user_error(cursor, |
1069 'incoming_move_input_dest', context=context) | 1116 'incoming_move_input_dest', context=context) |
1070 elif act[0] == 'write': | 1117 elif act[0] == 'write': |
1071 if 'to_location' in act[2]: | 1118 if 'to_location' in act[2]: |
1072 if act[2]['to_location'] != \ | 1119 if act[2]['to_location'] != \ |
1073 shipment.warehouse.input_location.id: | 1120 shipment.warehouse.input_location.id: |
1074 self.raise_user_error(cursor, | 1121 self.raise_user_error(cursor, |
1075 'incoming_move_input_dest', context=context) | 1122 'incoming_move_input_dest', context=context) |
1076 elif act[0] == 'add': | 1123 elif act[0] == 'add': |
1077 move_ids.append(act[1]) | 1124 if isinstance(act[1], (int, long)): |
1125 move_ids.append(act[1]) | |
1126 else: | |
1127 move_ids.extend(act[1]) | |
1078 elif act[0] == 'set': | 1128 elif act[0] == 'set': |
1079 move_ids.extend(act[1]) | 1129 move_ids.extend(act[1]) |
1080 | 1130 |
1081 moves = move_obj.browse(cursor, user, move_ids, context=context) | 1131 moves = move_obj.browse(cursor, user, move_ids, context=context) |
1082 for move in moves: | 1132 for move in moves: |
1083 if move.to_location.id != \ | 1133 if move.to_location.id != \ |
1084 shipment.warehouse.input_location.id: | 1134 shipment.warehouse.input_location.id: |
1085 self.raise_user_error(cursor, | 1135 self.raise_user_error(cursor, |
1086 'incoming_move_input_dest', context=context) | 1136 'incoming_move_input_dest', context=context) |
1087 self.write(cursor, user, shipment_id, { | 1137 self.write(cursor, user, shipment_id, { |
(...skipping 26 matching lines...) Expand all Loading... | |
1114 shipment.warehouse.input_location.id: | 1164 shipment.warehouse.input_location.id: |
1115 self.raise_user_error(cursor, | 1165 self.raise_user_error(cursor, |
1116 'inventory_move_input_source', context=context) | 1166 'inventory_move_input_source', context=context) |
1117 elif act[0] == 'write': | 1167 elif act[0] == 'write': |
1118 if 'from_location' in act[2]: | 1168 if 'from_location' in act[2]: |
1119 if act[2]['from_location'] != \ | 1169 if act[2]['from_location'] != \ |
1120 shipment.warehouse.input_location.id: | 1170 shipment.warehouse.input_location.id: |
1121 self.raise_user_error(cursor, | 1171 self.raise_user_error(cursor, |
1122 'inventory_move_input_source', context=context) | 1172 'inventory_move_input_source', context=context) |
1123 elif act[0] == 'add': | 1173 elif act[0] == 'add': |
1124 move_ids.append(act[1]) | 1174 if isinstance(act[1], (int, long)): |
1175 move_ids.append(act[1]) | |
1176 else: | |
1177 move_ids.extend(act[1]) | |
1125 elif act[0] == 'set': | 1178 elif act[0] == 'set': |
1126 move_ids.extend(act[1]) | 1179 move_ids.extend(act[1]) |
1127 | 1180 |
1128 moves = move_obj.browse(cursor, user, move_ids, context=context) | 1181 moves = move_obj.browse(cursor, user, move_ids, context=context) |
1129 for move in moves: | 1182 for move in moves: |
1130 if move.from_location.id != \ | 1183 if move.from_location.id != \ |
1131 shipment.warehouse.input_location.id: | 1184 shipment.warehouse.input_location.id: |
1132 self.raise_user_error(cursor, | 1185 self.raise_user_error(cursor, |
1133 'inventory_move_input_source', context=context) | 1186 'inventory_move_input_source', context=context) |
1134 self.write(cursor, user, shipment_id, { | 1187 self.write(cursor, user, shipment_id, { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1229 vals = self._get_inventory_moves(cursor, user, incoming_move, | 1282 vals = self._get_inventory_moves(cursor, user, incoming_move, |
1230 context=context) | 1283 context=context) |
1231 if vals: | 1284 if vals: |
1232 self.write(cursor, user, shipment.id, { | 1285 self.write(cursor, user, shipment.id, { |
1233 'inventory_moves': [('create', vals)] | 1286 'inventory_moves': [('create', vals)] |
1234 }, context=context) | 1287 }, context=context) |
1235 | 1288 |
1236 ShipmentOutReturn() | 1289 ShipmentOutReturn() |
1237 | 1290 |
1238 | 1291 |
1239 class AssignShipmentOutAskForce(ModelView): | 1292 class AssignShipmentOutAssignFailed(ModelView): |
1240 'Assign Shipment Out Ask Force' | 1293 'Assign Shipment Out Assign Failed' |
1241 _name = 'stock.shipment.out.assign.ask_force' | 1294 _name = 'stock.shipment.out.assign.assign_failed' |
1242 _description = __doc__ | 1295 _description = __doc__ |
1243 | 1296 |
1244 inventory_moves = fields.Many2Many('stock.move', None, None, | 1297 inventory_moves = fields.Many2Many('stock.move', None, None, |
1245 'Inventory Moves', readonly=True) | 1298 'Inventory Moves', readonly=True) |
1246 | 1299 |
1247 AssignShipmentOutAskForce() | 1300 AssignShipmentOutAssignFailed() |
1248 | 1301 |
1249 | 1302 |
1250 class AssignShipmentOut(Wizard): | 1303 class AssignShipmentOut(Wizard): |
1251 'Assign Shipment Out' | 1304 'Assign Shipment Out' |
1252 _name = 'stock.shipment.out.assign' | 1305 _name = 'stock.shipment.out.assign' |
1253 states = { | 1306 states = { |
1254 'init': { | 1307 'init': { |
1255 'result': { | 1308 'result': { |
1256 'type': 'choice', | 1309 'type': 'choice', |
1257 'next_state': '_choice', | 1310 'next_state': '_choice', |
1258 }, | 1311 }, |
1259 }, | 1312 }, |
1260 'notify': { | 1313 'assign_failed': { |
ced
2010/01/15 23:23:25
I think it should be named, assign_failed
| |
1261 'actions': ['_moves'], | 1314 'actions': ['_moves'], |
1262 'result': { | 1315 'result': { |
1263 'type': 'form', | 1316 'type': 'form', |
1264 'object': 'stock.shipment.out.assign.ask_force', | 1317 'object': 'stock.shipment.out.assign.assign_failed', |
ced
2010/01/15 23:23:25
You must use an other object
| |
1265 'state': [ | 1318 'state': [ |
1266 ('end', 'Ok', 'tryton-ok', True), | 1319 ('end', 'Ok', 'tryton-ok', True), |
1267 ], | 1320 ], |
1268 }, | 1321 }, |
1269 }, | 1322 }, |
Ian Wilson
2010/01/15 19:27:33
There seemed no way to just hide the button in a d
udono
2010/01/15 20:08:06
I think its the right way you go.
| |
1270 'ask_force': { | 1323 'ask_force': { |
1271 'actions': ['_moves'], | 1324 'actions': ['_moves'], |
1272 'result': { | 1325 'result': { |
1273 'type': 'form', | 1326 'type': 'form', |
1274 'object': 'stock.shipment.out.assign.ask_force', | 1327 'object': 'stock.shipment.out.assign.assign_failed', |
1275 'state': [ | 1328 'state': [ |
1276 ('force', 'Force Assign', 'tryton-go-next'), | 1329 ('force', 'Force Assign', 'tryton-go-next'), |
1277 ('end', 'Ok', 'tryton-ok', True), | 1330 ('end', 'Ok', 'tryton-ok', True), |
1278 ], | 1331 ], |
1279 }, | 1332 }, |
1280 }, | 1333 }, |
1281 'force': { | 1334 'force': { |
1282 'result': { | 1335 'result': { |
1283 'type': 'action', | 1336 'type': 'action', |
1284 'action': '_force', | 1337 'action': '_force', |
1285 'state': 'end', | 1338 'state': 'end', |
1286 }, | 1339 }, |
1287 }, | 1340 }, |
1288 } | 1341 } |
1289 | 1342 |
1290 def _choice(self, cursor, user, data, context=None): | 1343 def _choice(self, cursor, user, data, context=None): |
1291 shipment_out_obj = self.pool.get('stock.shipment.out') | 1344 shipment_out_obj = self.pool.get('stock.shipment.out') |
1292 user_obj = self.pool.get('res.user') | 1345 user_group_obj = self.pool.get('res.user-res.group') |
1346 model_data_obj = self.pool.get('ir.model.data') | |
1347 transition_obj = self.pool.get('workflow.transition') | |
1293 | 1348 |
1294 shipment_out_obj.workflow_trigger_validate(cursor, user, data['id'], | 1349 shipment_out_obj.workflow_trigger_validate(cursor, user, data['id'], |
1295 'assign', context=context) | 1350 'assign', context=context) |
1296 shipment = shipment_out_obj.browse(cursor, user, data['id'], | 1351 shipment = shipment_out_obj.browse(cursor, user, data['id'], |
1297 context=context) | 1352 context=context) |
1298 if not [x.id for x in shipment.inventory_moves if x.state == 'draft']: | 1353 if not [x.id for x in shipment.inventory_moves if x.state == 'draft']: |
1299 return 'end' | 1354 return 'end' |
1300 else: | 1355 else: |
1301 users = user_obj.browse(cursor, user, [user], context=context) | 1356 trans_id = model_data_obj.get_id(cursor, user, 'stock', |
ced
2010/01/15 23:23:25
It will be better to search on group with users =
| |
1302 if users: | 1357 'shipmentout_trans_waiting_assigned_force', context=context) |
1303 for group in users[0].groups: | 1358 trans = transition_obj.read(cursor, user, trans_id, context=context) |
1304 if group.name == 'Stock Force Assignment': | 1359 user_in_group = user_group_obj.search(cursor, user, [ |
Ian Wilson
2010/01/15 19:27:33
Is there a better way to check if a user belongs t
udono
2010/01/15 20:08:06
I don't know a better way.
ced
2010/01/15 23:23:25
You must use ir.model.data to get the id.
But I th
Ian Wilson
2010/01/16 02:39:39
I think I understand all the comments except for t
ced
2010/01/16 09:12:33
Yes but don't forget that there is also a wizard s
| |
1305 return 'ask_force' | 1360 ('uid', '=', user), |
1306 return 'notify' | 1361 ('gid', '=', trans['group']), |
1362 ], limit=1, context=context) | |
1363 if user_in_group: | |
1364 return 'ask_force' | |
1365 return 'assign_failed' | |
1307 | 1366 |
1308 def _moves(self, cursor, user, data, context=None): | 1367 def _moves(self, cursor, user, data, context=None): |
1309 shipment_out_obj = self.pool.get('stock.shipment.out') | 1368 shipment_out_obj = self.pool.get('stock.shipment.out') |
1310 shipment = shipment_out_obj.browse(cursor, user, data['id'], | 1369 shipment = shipment_out_obj.browse(cursor, user, data['id'], |
1311 context=context) | 1370 context=context) |
1312 return {'inventory_moves': [x.id for x in shipment.inventory_moves | 1371 return {'inventory_moves': [x.id for x in shipment.inventory_moves |
1313 if x.state == 'draft']} | 1372 if x.state == 'draft']} |
1314 | 1373 |
1315 def _force(self, cursor, user, data, context=None): | 1374 def _force(self, cursor, user, data, context=None): |
1316 shipment_out_obj = self.pool.get('stock.shipment.out') | 1375 shipment_out_obj = self.pool.get('stock.shipment.out') |
1317 | 1376 |
1318 shipment_out_obj.workflow_trigger_validate(cursor, user, data['id'], | 1377 shipment_out_obj.workflow_trigger_validate(cursor, user, data['id'], |
1319 'force_assign', context=context) | 1378 'force_assign', context=context) |
1320 return {} | 1379 return {} |
1321 | 1380 |
1322 AssignShipmentOut() | 1381 AssignShipmentOut() |
1323 | 1382 |
1324 | 1383 |
1325 class ShipmentInternal(ModelWorkflow, ModelSQL, ModelView): | 1384 class ShipmentInternal(ModelWorkflow, ModelSQL, ModelView): |
1326 "Internal Shipment" | 1385 "Internal Shipment" |
1327 _name = 'stock.shipment.internal' | 1386 _name = 'stock.shipment.internal' |
1328 _description = __doc__ | 1387 _description = __doc__ |
1329 _rec_name = 'code' | 1388 _rec_name = 'code' |
1330 | 1389 |
1331 effective_date =fields.Date('Effective Date', readonly=True) | 1390 effective_date =fields.Date('Effective Date', readonly=True) |
1332 planned_date = fields.Date( | 1391 planned_date = fields.Date('Planned Date', |
1333 'Planned Date', states={'readonly': "state != 'draft'",}) | 1392 states={ |
1393 'readonly': Not(Equal(Eval('state'), 'draft')), | |
1394 }) | |
1334 code = fields.Char("Code", size=None, select=1, readonly=True) | 1395 code = fields.Char("Code", size=None, select=1, readonly=True) |
1335 reference = fields.Char( | 1396 reference = fields.Char("Reference", size=None, select=1, |
1336 "Reference", size=None, select=1, | 1397 states={ |
1337 states={'readonly': "state != 'draft'",}) | 1398 'readonly': Not(Equal(Eval('state'), 'draft')), |
1338 from_location = fields.Many2One( | 1399 }) |
1339 'stock.location', "From Location", required=True, | 1400 from_location = fields.Many2One('stock.location', "From Location", |
1340 states={ 'readonly': "state != 'draft' or bool(moves)", }, | 1401 required=True, states={ |
1341 domain=["('type', 'not in', " \ | 1402 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
1342 "('supplier', 'customer', 'warehouse', 'view'))"]) | 1403 Bool(Eval('moves'))), |
1404 }, | |
1405 domain=[ | |
1406 ('type', 'not in', | |
1407 ['supplier', 'customer', 'warehouse', 'view']), | |
1408 ]) | |
1343 to_location = fields.Many2One('stock.location', "To Location", | 1409 to_location = fields.Many2One('stock.location', "To Location", |
1344 required=True, states={ | 1410 required=True, states={ |
1345 'readonly': "state != 'draft' or bool(moves)", | 1411 'readonly': Or(Not(Equal(Eval('state'), 'draft')), |
1346 }, domain=["('type', 'not in', " \ | 1412 Bool(Eval('moves'))), |
1347 "('supplier', 'customer', 'warehouse', 'view'))"]) | 1413 }, domain=[ |
1348 moves = fields.One2Many( | 1414 ('type', 'not in', |
1349 'stock.move', 'shipment_internal', 'Moves', | 1415 ['supplier', 'customer', 'warehouse', 'view']), |
1350 states={'readonly': "state != 'draft' or "\ | 1416 ]) |
1351 "not(bool(from_location) and bool (to_location))"}, | 1417 moves = fields.One2Many('stock.move', 'shipment_internal', 'Moves', |
1352 context="{'from_location': from_location," | 1418 states={ |
1353 "'to_location': to_location," | 1419 'readonly': And(Or(Not(Equal(Eval('state'), 'draft')), |
1354 "'planned_date': planned_date}", | 1420 Not(Bool(Eval('from_location')))), |
1355 ) | 1421 Bool(Eval('to_location'))), |
1422 }, | |
1423 context={ | |
1424 'from_location': Eval('from_location'), | |
1425 'to_location': Eval('to_location'), | |
1426 'planned_date': Eval('planned_date'), | |
1427 }) | |
1356 state = fields.Selection([ | 1428 state = fields.Selection([ |
1357 ('draft', 'Draft'), | 1429 ('draft', 'Draft'), |
1358 ('cancel', 'Canceled'), | 1430 ('cancel', 'Canceled'), |
1359 ('assigned', 'Assigned'), | 1431 ('assigned', 'Assigned'), |
1360 ('waiting', 'Waiting'), | 1432 ('waiting', 'Waiting'), |
1361 ('done', 'Done'), | 1433 ('done', 'Done'), |
1362 ], 'State', readonly=True) | 1434 ], 'State', readonly=True) |
1363 | 1435 |
1364 def init(self, cursor, module_name): | 1436 def init(self, cursor, module_name): |
1365 # Migration from 1.2: packing renamed into shipment | 1437 # Migration from 1.2: packing renamed into shipment |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1470 ShipmentInternal() | 1542 ShipmentInternal() |
1471 | 1543 |
1472 | 1544 |
1473 class Address(ModelSQL, ModelView): | 1545 class Address(ModelSQL, ModelView): |
1474 _name = 'party.address' | 1546 _name = 'party.address' |
1475 delivery = fields.Boolean('Delivery') | 1547 delivery = fields.Boolean('Delivery') |
1476 | 1548 |
1477 Address() | 1549 Address() |
1478 | 1550 |
1479 | 1551 |
1480 class AssignShipmentInternalAskForce(ModelView): | 1552 class AssignShipmentInternalAssignFailed(ModelView): |
1481 'Assign Shipment Internal Ask Force' | 1553 'Assign Shipment Internal Assign Failed' |
1482 _name = 'stock.shipment.internal.assign.ask_force' | 1554 _name = 'stock.shipment.internal.assign.assign_failed' |
1483 _description = __doc__ | 1555 _description = __doc__ |
1484 | 1556 |
1485 moves = fields.Many2Many('stock.move', None, None, 'Moves', | 1557 moves = fields.Many2Many('stock.move', None, None, 'Moves', |
1486 readonly=True) | 1558 readonly=True) |
1487 | 1559 |
1488 AssignShipmentInternalAskForce() | 1560 AssignShipmentInternalAssignFailed() |
1489 | 1561 |
1490 | 1562 |
1491 class AssignShipmentInternal(Wizard): | 1563 class AssignShipmentInternal(Wizard): |
1492 'Assign Shipment Internal' | 1564 'Assign Shipment Internal' |
1493 _name = 'stock.shipment.internal.assign' | 1565 _name = 'stock.shipment.internal.assign' |
1494 states = { | 1566 states = { |
1495 'init': { | 1567 'init': { |
1496 'result': { | 1568 'result': { |
1497 'type': 'choice', | 1569 'type': 'choice', |
1498 'next_state': '_choice', | 1570 'next_state': '_choice', |
1499 }, | 1571 }, |
1500 }, | 1572 }, |
1573 'assign_failed': { | |
1574 'actions': ['_moves'], | |
1575 'result': { | |
1576 'type': 'form', | |
1577 'object': 'stock.shipment.internal.assign.assign_failed', | |
1578 'state': [ | |
1579 ('end', 'Ok', 'tryton-ok', True), | |
1580 ], | |
1581 }, | |
1582 }, | |
1501 'ask_force': { | 1583 'ask_force': { |
1502 'actions': ['_moves'], | 1584 'actions': ['_moves'], |
1503 'result': { | 1585 'result': { |
1504 'type': 'form', | 1586 'type': 'form', |
1505 'object': 'stock.shipment.internal.assign.ask_force', | 1587 'object': 'stock.shipment.internal.assign.assign_failed', |
1506 'state': [ | 1588 'state': [ |
1507 ('force', 'Force Assign', 'tryton-go-next'), | 1589 ('force', 'Force Assign', 'tryton-go-next'), |
1508 ('end', 'Ok', 'tryton-ok', True), | 1590 ('end', 'Ok', 'tryton-ok', True), |
1509 ], | 1591 ], |
1510 }, | 1592 }, |
1511 }, | 1593 }, |
1512 'force': { | 1594 'force': { |
1513 'result': { | 1595 'result': { |
1514 'type': 'action', | 1596 'type': 'action', |
1515 'action': '_force', | 1597 'action': '_force', |
1516 'state': 'end', | 1598 'state': 'end', |
1517 }, | 1599 }, |
1518 }, | 1600 }, |
1519 } | 1601 } |
1520 | 1602 |
1521 def _choice(self, cursor, user, data, context=None): | 1603 def _choice(self, cursor, user, data, context=None): |
1522 shipment_internal_obj = self.pool.get('stock.shipment.internal') | 1604 shipment_internal_obj = self.pool.get('stock.shipment.internal') |
1605 user_group_obj = self.pool.get('res.user-res.group') | |
1606 model_data_obj = self.pool.get('ir.model.data') | |
1607 transition_obj = self.pool.get('workflow.transition') | |
1523 | 1608 |
1524 shipment_internal_obj.workflow_trigger_validate(cursor, user, | 1609 shipment_internal_obj.workflow_trigger_validate(cursor, user, |
1525 data['id'], 'assign', context=context) | 1610 data['id'], 'assign', context=context) |
1526 shipment = shipment_internal_obj.browse(cursor, user, data['id'], | 1611 shipment = shipment_internal_obj.browse(cursor, user, data['id'], |
1527 context=context) | 1612 context=context) |
1528 if not [x.id for x in shipment.moves if x.state == 'draft']: | 1613 if not [x.id for x in shipment.moves if x.state == 'draft']: |
1529 return 'end' | 1614 return 'end' |
1530 else: | 1615 else: |
1531 return 'ask_force' | 1616 trans_id = model_data_obj.get_id(cursor, user, 'stock', |
1617 'shipmentinternal_trans_waiting_assigned_force', | |
1618 context=context) | |
1619 trans = transition_obj.read(cursor, user, trans_id, | |
1620 context=context) | |
1621 user_in_group = user_group_obj.search(cursor, user, [ | |
1622 ('uid', '=', user), | |
1623 ('gid', '=', trans['group']), | |
1624 ], limit=1, context=context) | |
1625 if user_in_group: | |
1626 return 'ask_force' | |
1627 return 'assign_failed' | |
1532 | 1628 |
1533 def _moves(self, cursor, user, data, context=None): | 1629 def _moves(self, cursor, user, data, context=None): |
1534 shipment_internal_obj = self.pool.get('stock.shipment.internal') | 1630 shipment_internal_obj = self.pool.get('stock.shipment.internal') |
1535 shipment = shipment_internal_obj.browse(cursor, user, data['id'], | 1631 shipment = shipment_internal_obj.browse(cursor, user, data['id'], |
1536 context=context) | 1632 context=context) |
1537 return {'moves': [x.id for x in shipment.moves if x.state == 'draft']} | 1633 return {'moves': [x.id for x in shipment.moves if x.state == 'draft']} |
1538 | 1634 |
1539 def _force(self, cursor, user, data, context=None): | 1635 def _force(self, cursor, user, data, context=None): |
1540 shipment_internal_obj = self.pool.get('stock.shipment.internal') | 1636 shipment_internal_obj = self.pool.get('stock.shipment.internal') |
1541 | 1637 |
1542 shipment_internal_obj.workflow_trigger_validate(cursor, user, | 1638 shipment_internal_obj.workflow_trigger_validate(cursor, user, |
1543 data['id'], 'force_assign', context=context) | 1639 data['id'], 'force_assign', context=context) |
1544 return {} | 1640 return {} |
1545 | 1641 |
1546 AssignShipmentInternal() | 1642 AssignShipmentInternal() |
1547 | 1643 |
1548 | 1644 |
1549 class AssignShipmentInReturnAskForce(ModelView): | 1645 class AssignShipmentInReturnAssignFailed(ModelView): |
1550 'Assign Supplier Return Shipment Ask Force' | 1646 'Assign Supplier Return Shipment Assign Failed' |
1551 _name = 'stock.shipment.in.return.assign.ask_force' | 1647 _name = 'stock.shipment.in.return.assign.assign_failed' |
1552 _description = __doc__ | 1648 _description = __doc__ |
1553 | 1649 |
1554 moves = fields.Many2Many('stock.move', None, None, 'Moves', | 1650 moves = fields.Many2Many('stock.move', None, None, 'Moves', |
1555 readonly=True) | 1651 readonly=True) |
1556 | 1652 |
1557 AssignShipmentInReturnAskForce() | 1653 AssignShipmentInReturnAssignFailed() |
1558 | 1654 |
1559 | 1655 |
1560 class AssignShipmentInReturn(Wizard): | 1656 class AssignShipmentInReturn(Wizard): |
1561 'Assign Supplier Return Shipment' | 1657 'Assign Supplier Return Shipment' |
1562 _name = 'stock.shipment.in.return.assign' | 1658 _name = 'stock.shipment.in.return.assign' |
1563 states = { | 1659 states = { |
1564 'init': { | 1660 'init': { |
1565 'result': { | 1661 'result': { |
1566 'type': 'choice', | 1662 'type': 'choice', |
1567 'next_state': '_choice', | 1663 'next_state': '_choice', |
1568 }, | 1664 }, |
1569 }, | 1665 }, |
1666 'assign_failed': { | |
1667 'actions': ['_moves'], | |
1668 'result': { | |
1669 'type': 'form', | |
1670 'object': 'stock.shipment.in.return.assign.assign_failed', | |
1671 'state': [ | |
1672 ('end', 'Ok', 'tryton-ok', True), | |
1673 ], | |
1674 }, | |
1675 }, | |
1570 'ask_force': { | 1676 'ask_force': { |
1571 'actions': ['_moves'], | 1677 'actions': ['_moves'], |
1572 'result': { | 1678 'result': { |
1573 'type': 'form', | 1679 'type': 'form', |
1574 'object': 'stock.shipment.in.return.assign.ask_force', | 1680 'object': 'stock.shipment.in.return.assign.assign_failed', |
1575 'state': [ | 1681 'state': [ |
1576 ('force', 'Force Assign', 'tryton-go-next'), | 1682 ('force', 'Force Assign', 'tryton-go-next'), |
1577 ('end', 'Ok', 'tryton-ok', True), | 1683 ('end', 'Ok', 'tryton-ok', True), |
1578 ], | 1684 ], |
1579 }, | 1685 }, |
1580 }, | 1686 }, |
1581 'force': { | 1687 'force': { |
1582 'result': { | 1688 'result': { |
1583 'type': 'action', | 1689 'type': 'action', |
1584 'action': '_force', | 1690 'action': '_force', |
1585 'state': 'end', | 1691 'state': 'end', |
1586 }, | 1692 }, |
1587 }, | 1693 }, |
1588 } | 1694 } |
1589 | 1695 |
1590 def _choice(self, cursor, user, data, context=None): | 1696 def _choice(self, cursor, user, data, context=None): |
1591 shipment_internal_obj = self.pool.get('stock.shipment.in.return') | 1697 shipment_internal_obj = self.pool.get('stock.shipment.in.return') |
1698 user_group_obj = self.pool.get('res.user-res.group') | |
1699 model_data_obj = self.pool.get('ir.model.data') | |
1700 transition_obj = self.pool.get('workflow.transition') | |
1592 | 1701 |
1593 shipment_internal_obj.workflow_trigger_validate(cursor, user, | 1702 shipment_internal_obj.workflow_trigger_validate(cursor, user, |
1594 data['id'], 'assign', context=context) | 1703 data['id'], 'assign', context=context) |
1595 shipment = shipment_internal_obj.browse(cursor, user, data['id'], | 1704 shipment = shipment_internal_obj.browse(cursor, user, data['id'], |
1596 context=context) | 1705 context=context) |
1597 if not [x.id for x in shipment.moves if x.state == 'draft']: | 1706 if not [x.id for x in shipment.moves if x.state == 'draft']: |
1598 return 'end' | 1707 return 'end' |
1599 else: | 1708 else: |
1600 return 'ask_force' | 1709 trans_id = model_data_obj.get_id(cursor, user, 'stock', |
1710 'shipment_in_return_trans_waiting_assigned_force', | |
1711 context=context) | |
1712 trans = transition_obj.read(cursor, user, trans_id, context=context) | |
1713 user_in_group = user_group_obj.search(cursor, user, [ | |
1714 ('uid', '=', user), | |
1715 ('gid', '=', trans['group']), | |
1716 ], limit=1, context=context) | |
1717 if user_in_group: | |
1718 return 'ask_force' | |
1719 return 'assign_failed' | |
1601 | 1720 |
1602 def _moves(self, cursor, user, data, context=None): | 1721 def _moves(self, cursor, user, data, context=None): |
1603 shipment_internal_obj = self.pool.get('stock.shipment.in.return') | 1722 shipment_internal_obj = self.pool.get('stock.shipment.in.return') |
1604 shipment = shipment_internal_obj.browse(cursor, user, data['id'], | 1723 shipment = shipment_internal_obj.browse(cursor, user, data['id'], |
1605 context=context) | 1724 context=context) |
1606 return {'moves': [x.id for x in shipment.moves if x.state == 'draft']} | 1725 return {'moves': [x.id for x in shipment.moves if x.state == 'draft']} |
1607 | 1726 |
1608 def _force(self, cursor, user, data, context=None): | 1727 def _force(self, cursor, user, data, context=None): |
1609 shipment_internal_obj = self.pool.get('stock.shipment.in.return') | 1728 shipment_internal_obj = self.pool.get('stock.shipment.in.return') |
1610 | 1729 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1667 shipment_out_return_obj.create( | 1786 shipment_out_return_obj.create( |
1668 cursor, user, | 1787 cursor, user, |
1669 {'customer': shipment_out.customer.id, | 1788 {'customer': shipment_out.customer.id, |
1670 'delivery_address': shipment_out.delivery_address.id, | 1789 'delivery_address': shipment_out.delivery_address.id, |
1671 'warehouse': shipment_out.warehouse.id, | 1790 'warehouse': shipment_out.warehouse.id, |
1672 'incoming_moves': incoming_moves, | 1791 'incoming_moves': incoming_moves, |
1673 }, | 1792 }, |
1674 context=context) | 1793 context=context) |
1675 ) | 1794 ) |
1676 | 1795 |
1677 model_data_ids = model_data_obj.search(cursor, user, [ | 1796 act_window_id = model_data_obj.get_id(cursor, user, 'stock', |
1678 ('fs_id', '=', 'act_shipment_out_return_form'), | 1797 'act_shipment_out_return_form', context=context) |
1679 ('module', '=', 'stock'), | 1798 res = act_window_obj.read(cursor, user, act_window_id, context=context) |
1680 ('inherit', '=', False), | |
1681 ], limit=1, context=context) | |
1682 model_data = model_data_obj.browse(cursor, user, model_data_ids[0], | |
1683 context=context) | |
1684 res = act_window_obj.read(cursor, user, model_data.db_id, context=contex t) | |
1685 res['res_id'] = shipment_out_return_ids | 1799 res['res_id'] = shipment_out_return_ids |
1686 if len(shipment_out_return_ids) == 1: | 1800 if len(shipment_out_return_ids) == 1: |
1687 res['views'].reverse() | 1801 res['views'].reverse() |
1688 | 1802 |
1689 return res | 1803 return res |
1690 | 1804 |
1691 CreateShipmentOutReturn() | 1805 CreateShipmentOutReturn() |
1692 | 1806 |
1693 | 1807 |
1694 class DeliveryNote(CompanyReport): | 1808 class DeliveryNote(CompanyReport): |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1905 'to_location_ids' : to_location_ids} | 2019 'to_location_ids' : to_location_ids} |
1906 | 2020 |
1907 | 2021 |
1908 def get_compare_key(self, move, compare_context): | 2022 def get_compare_key(self, move, compare_context): |
1909 from_location_ids = compare_context['from_location_ids'] | 2023 from_location_ids = compare_context['from_location_ids'] |
1910 to_location_ids = compare_context['to_location_ids'] | 2024 to_location_ids = compare_context['to_location_ids'] |
1911 return [from_location_ids.index(move.from_location.id), | 2025 return [from_location_ids.index(move.from_location.id), |
1912 to_location_ids.index(move.to_location.id)] | 2026 to_location_ids.index(move.to_location.id)] |
1913 | 2027 |
1914 InteralShipmentReport() | 2028 InteralShipmentReport() |
LEFT | RIGHT |