Left: | ||
Right: |
OLD | NEW |
---|---|
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 | 8 |
9 STATES = { | 9 STATES = { |
10 'readonly': "state in ('cancel', 'done')", | 10 'readonly': "state in ('cancel', 'done')", |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1250 class AssignShipmentOut(Wizard): | 1250 class AssignShipmentOut(Wizard): |
1251 'Assign Shipment Out' | 1251 'Assign Shipment Out' |
1252 _name = 'stock.shipment.out.assign' | 1252 _name = 'stock.shipment.out.assign' |
1253 states = { | 1253 states = { |
1254 'init': { | 1254 'init': { |
1255 'result': { | 1255 'result': { |
1256 'type': 'choice', | 1256 'type': 'choice', |
1257 'next_state': '_choice', | 1257 'next_state': '_choice', |
1258 }, | 1258 }, |
1259 }, | 1259 }, |
1260 'notify': { | |
ced
2010/01/15 23:23:25
I think it should be named, assign_failed
| |
1261 'actions': ['_moves'], | |
1262 'result': { | |
1263 'type': 'form', | |
1264 'object': 'stock.shipment.out.assign.ask_force', | |
ced
2010/01/15 23:23:25
You must use an other object
| |
1265 'state': [ | |
1266 ('end', 'Ok', 'tryton-ok', True), | |
1267 ], | |
1268 }, | |
1269 }, | |
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.
| |
1260 'ask_force': { | 1270 'ask_force': { |
1261 'actions': ['_moves'], | 1271 'actions': ['_moves'], |
1262 'result': { | 1272 'result': { |
1263 'type': 'form', | 1273 'type': 'form', |
1264 'object': 'stock.shipment.out.assign.ask_force', | 1274 'object': 'stock.shipment.out.assign.ask_force', |
1265 'state': [ | 1275 'state': [ |
1266 ('force', 'Force Assign', 'tryton-go-next'), | 1276 ('force', 'Force Assign', 'tryton-go-next'), |
1267 ('end', 'Ok', 'tryton-ok', True), | 1277 ('end', 'Ok', 'tryton-ok', True), |
1268 ], | 1278 ], |
1269 }, | 1279 }, |
1270 }, | 1280 }, |
1271 'force': { | 1281 'force': { |
1272 'result': { | 1282 'result': { |
1273 'type': 'action', | 1283 'type': 'action', |
1274 'action': '_force', | 1284 'action': '_force', |
1275 'state': 'end', | 1285 'state': 'end', |
1276 }, | 1286 }, |
1277 }, | 1287 }, |
1278 } | 1288 } |
1279 | 1289 |
1280 def _choice(self, cursor, user, data, context=None): | 1290 def _choice(self, cursor, user, data, context=None): |
1281 shipment_out_obj = self.pool.get('stock.shipment.out') | 1291 shipment_out_obj = self.pool.get('stock.shipment.out') |
1292 user_obj = self.pool.get('res.user') | |
1282 | 1293 |
1283 shipment_out_obj.workflow_trigger_validate(cursor, user, data['id'], | 1294 shipment_out_obj.workflow_trigger_validate(cursor, user, data['id'], |
1284 'assign', context=context) | 1295 'assign', context=context) |
1285 shipment = shipment_out_obj.browse(cursor, user, data['id'], | 1296 shipment = shipment_out_obj.browse(cursor, user, data['id'], |
1286 context=context) | 1297 context=context) |
1287 if not [x.id for x in shipment.inventory_moves if x.state == 'draft']: | 1298 if not [x.id for x in shipment.inventory_moves if x.state == 'draft']: |
1288 return 'end' | 1299 return 'end' |
1289 else: | 1300 else: |
1290 return 'ask_force' | 1301 users = user_obj.browse(cursor, user, [user], context=context) |
ced
2010/01/15 23:23:25
It will be better to search on group with users =
| |
1302 if users: | |
1303 for group in users[0].groups: | |
1304 if group.name == 'Stock Force Assignment': | |
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' | |
1306 return 'notify' | |
1291 | 1307 |
1292 def _moves(self, cursor, user, data, context=None): | 1308 def _moves(self, cursor, user, data, context=None): |
1293 shipment_out_obj = self.pool.get('stock.shipment.out') | 1309 shipment_out_obj = self.pool.get('stock.shipment.out') |
1294 shipment = shipment_out_obj.browse(cursor, user, data['id'], | 1310 shipment = shipment_out_obj.browse(cursor, user, data['id'], |
1295 context=context) | 1311 context=context) |
1296 return {'inventory_moves': [x.id for x in shipment.inventory_moves | 1312 return {'inventory_moves': [x.id for x in shipment.inventory_moves |
1297 if x.state == 'draft']} | 1313 if x.state == 'draft']} |
1298 | 1314 |
1299 def _force(self, cursor, user, data, context=None): | 1315 def _force(self, cursor, user, data, context=None): |
1300 shipment_out_obj = self.pool.get('stock.shipment.out') | 1316 shipment_out_obj = self.pool.get('stock.shipment.out') |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 'to_location_ids' : to_location_ids} | 1905 'to_location_ids' : to_location_ids} |
1890 | 1906 |
1891 | 1907 |
1892 def get_compare_key(self, move, compare_context): | 1908 def get_compare_key(self, move, compare_context): |
1893 from_location_ids = compare_context['from_location_ids'] | 1909 from_location_ids = compare_context['from_location_ids'] |
1894 to_location_ids = compare_context['to_location_ids'] | 1910 to_location_ids = compare_context['to_location_ids'] |
1895 return [from_location_ids.index(move.from_location.id), | 1911 return [from_location_ids.index(move.from_location.id), |
1896 to_location_ids.index(move.to_location.id)] | 1912 to_location_ids.index(move.to_location.id)] |
1897 | 1913 |
1898 InteralShipmentReport() | 1914 InteralShipmentReport() |
OLD | NEW |