test_routes.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from odoo.tests.common import TransactionCase, Form
  2. class TestRoutes(TransactionCase):
  3. def test_allow_rule_creation_for_route_without_company(self):
  4. self.env['res.config.settings'].write({
  5. 'group_stock_adv_location': True,
  6. 'group_stock_multi_locations': True,
  7. })
  8. warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
  9. location_1 = self.env['stock.location'].create({
  10. 'name': 'loc1',
  11. 'location_id': warehouse.id
  12. })
  13. location_2 = self.env['stock.location'].create({
  14. 'name': 'loc2',
  15. 'location_id': warehouse.id
  16. })
  17. receipt_1 = self.env['stock.picking.type'].create({
  18. 'name': 'Receipts from loc1',
  19. 'sequence_code': 'IN1',
  20. 'code': 'incoming',
  21. 'warehouse_id': warehouse.id,
  22. 'default_location_dest_id': location_1.id,
  23. })
  24. receipt_2 = self.env['stock.picking.type'].create({
  25. 'name': 'Receipts from loc2',
  26. 'sequence_code': 'IN2',
  27. 'code': 'incoming',
  28. 'warehouse_id': warehouse.id,
  29. 'default_location_dest_id': location_2.id,
  30. })
  31. route = self.env['stock.route'].create({
  32. 'name': 'Buy',
  33. 'company_id': False
  34. })
  35. with Form(route) as r:
  36. with r.rule_ids.new() as line:
  37. line.name = 'first rule'
  38. line.action = 'buy'
  39. line.picking_type_id = receipt_1
  40. with r.rule_ids.new() as line:
  41. line.name = 'second rule'
  42. line.action = 'buy'
  43. line.picking_type_id = receipt_2