~unifield-team/unifield-wm/us-826

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-
   Creating a service location
-
  !record {model: stock.location, id: location_service}:
    name: Test Service
    location_category: other
    usage: view
    service_location: True
- 
  Creating a res.partner record
- 
  !record {model: res.partner, id: res_partner_a0}:
    credit_limit: 0.0
    debit_limit: 0.0
    name: A
    supplier: true
    
- 
  Creating a res.partner.address record
- 
  !record {model: res.partner.address, id: res_partner_address_0}:
    partner_id: res_partner_a0
    street: A

-
  Creating a product.product record service with reception
- 
  !record {model: product.product, id: product_service_p0}:
    default_code: P0
    name: product 0 test
    type: service
    
- 
  Creating a product.product record service with reception
- 
  !record {model: product.product, id: product_service_recep_p1}:
    default_code: P0
    name: product 0 test
    type: service_recep
    
- 
  Creating a product.product record stockable
- 
  !record {model: product.product, id: product_stockable_p2}:
    default_code: P1
    name: product 1 test
    type: product
  
    
- 
  1. I create a stock move, and then change the source location
  with Service Location. An exception should be raised.
  
  Creating a stock.move record
- 
  !record {model: stock.move, id: stock_move_1}:
    name: test stock move
    product_id: product_stockable_p2
    product_uom: product.product_uom_unit
    location_dest_id: stock.stock_location_stock
    location_id: stock.stock_location_stock

-
  Change the source location to Service location
-
  !python {model: stock.move}: |
    from osv import osv
    service_location = self.pool.get('stock.location').search(cr, uid, [('service_location', '=', True)], context=context)
    assert service_location, 'No Service Location available'
    service_location = service_location[0]
    
    try:
      self.write(cr, uid, ref("stock_move_1"), {'location_id': service_location} ,context=context)
    except osv.except_osv as e:
      # ok the constraint has been raised
      pass
    else:
      assert False, 'The constraint: "You cannot select Service Location as Source Location." has not been triggered.'