2
In order to test the behaviour of the mission stock report,
3
we will create a mission stock report for an other instance
4
and use the local instance.
6
In order to test the mission stock module, we start by creating a new product category
8
Create a new partner for coordination
10
!record {model: res.partner, id: coord1}:
13
!record {model: product.category, id: product_cat1}:
16
To do this, we need a product
18
!record {model: product.product, id: product1}:
19
categ_id: product_cat1
24
procure_method: make_to_stock
25
property_stock_inventory: stock.location_inventory
26
property_stock_procurement: stock.location_procurement
27
property_stock_production: stock.location_production
32
uom_id: product.product_uom_unit
33
uom_po_id: product.product_uom_unit
38
reviewed_consumption: 45
39
international_status: product_attributes.int_1
41
We create also a new Unifield instance which is not a local instance
43
!record {model: account.analytic.account, id: analytic_account_kenya2}:
49
parent_id: analytic_distribution.analytic_account_project
50
date: !eval "'%s-01-01' %(datetime.now().year + 2)"
52
We create also a new comp. Cost Center
54
!record {model: account.analytic.account, id: analytic_account_mal}:
60
parent_id: analytic_distribution.analytic_account_project
61
date: !eval "'%s-01-01' %(datetime.now().year + 2)"
63
!record {model: msf.instance, id: proj1}:
67
instance: Proj. instance
68
#parent_id: msf_instance.instance_section
70
target_cost_center_ids:
71
- cost_center_id: analytic_account_kenya2
73
is_top_cost_center: True
74
is_po_fo_cost_center: True
79
Activate the local instance
81
!python {model: msf.instance}: |
82
user = self.pool.get('res.users').browse(cr, uid, uid)
83
if user.company_id.instance_id:
84
comp_instance = user.company_id.instance_id.id
86
comp_instance = self.create(cr, uid, {'code': 'Comp Instance', 'name': 'Comp', 'level': 'section', 'move_prefix': 'COMP', 'reconcile_prefix': 'C1'})
87
self.pool.get('account.target.costcenter').create(cr, uid, {'cost_center_id': ref('analytic_account_mal'), 'instance_id': comp_instance, 'is_target': True, 'is_top_cost_center': True, 'is_po_fo_cost_center': True})
88
self.pool.get('res.company').write(cr, uid, [user.company_id.id], {'instance_id': comp_instance})
89
self.write(cr, uid, ref('proj1'), {'parent_id': comp_instance})
90
self.write(cr, uid, comp_instance, {'state': 'active'})
92
Create a mission report for the project instance
94
!record {model: stock.mission.report, id: report_proj}:
99
- product_id: product1
101
internal_val: 9000.00
113
Create some configurable locations
115
!python {model: stock.location.configuration.wizard}: |
116
eprep_id = self.create(cr, uid, {'location_name': 'EPREP',
117
'location_usage': 'eprep',}, context={})
118
is1_id = self.create(cr, uid, {'location_name': 'IS1',
119
'location_usage': 'stock',}, context={})
120
is2_id = self.create(cr, uid, {'location_name': 'IS2',
121
'location_usage': 'stock',}, context={})
122
cu1_id = self.create(cr, uid, {'location_name': 'CU1',
123
'location_usage': 'consumption_unit',
124
'location_type': 'internal'}, context={})
125
cu2_id = self.create(cr, uid, {'location_name': 'CU2',
126
'location_usage': 'consumption_unit',
127
'location_type': 'internal'}, context={})
128
cu3_id = self.create(cr, uid, {'location_name': 'CU3',
129
'location_usage': 'consumption_unit',
130
'location_type': 'customer'}, context={})
131
for to_create in [eprep_id, is1_id, is2_id, cu1_id, cu2_id, cu3_id]:
132
self.confirm_creation(cr, uid, to_create)
134
Create an inventory for the local instance
136
!record {model: stock.inventory, id: local_inv}:
137
name: Local inventory
138
date: !eval time.strftime('%Y-%m-%d')
140
- location_id: msf_cross_docking.stock_location_input
141
product_uom: product.product_uom_unit
144
- location_id: msf_cross_docking.stock_location_cross_docking
145
product_uom: product.product_uom_unit
148
- location_id: stock.stock_location_output
149
product_uom: product.product_uom_unit
152
- location_id: msf_outgoing.stock_location_packing
153
product_uom: product.product_uom_unit
156
- location_id: msf_outgoing.stock_location_dispatch
157
product_uom: product.product_uom_unit
160
- location_id: msf_outgoing.stock_location_distribution
161
product_uom: product.product_uom_unit
164
- location_id: stock.stock_location_stock
165
product_uom: product.product_uom_unit
168
- location_id: msf_config_locations.stock_location_medical
169
product_uom: product.product_uom_unit
172
- location_id: msf_config_locations.stock_location_unalloc_medical
173
product_uom: product.product_uom_unit
176
- location_id: stock_override.stock_location_logistic
177
product_uom: product.product_uom_unit
180
- location_id: msf_config_locations.stock_location_unalloc_logistic
181
product_uom: product.product_uom_unit
184
- location_id: stock_override.stock_location_quarantine_scrap
185
product_uom: product.product_uom_unit
188
- location_id: stock_override.stock_location_quarantine_analyze
189
product_uom: product.product_uom_unit
193
Add some lines in the inventory for configurable locations
195
!python {model: stock.location}: |
196
eprep_id = self.search(cr, uid, [('name', '=', 'EPREP')])
197
assert eprep_id, 'No EPREP location found'
198
is1_id = self.search(cr, uid, [('name', '=', 'IS1')])
199
assert is1_id, 'No IS1 location found'
200
is2_id = self.search(cr, uid, [('name', '=', 'IS2')])
201
assert is2_id, 'No IS2 location found'
202
cu1_id = self.search(cr, uid, [('name', '=', 'CU1')])
203
assert cu1_id, 'No CU1 location found'
204
cu2_id = self.search(cr, uid, [('name', '=', 'CU2')])
205
assert cu2_id, 'No CU2 location found'
206
cu3_id = self.search(cr, uid, [('name', '=', 'CU3')])
207
assert cu3_id, 'No CU3 location found'
209
line_obj = self.pool.get('stock.inventory.line')
210
line_obj.create(cr, uid, {'location_id': eprep_id[0],
211
'inventory_id': ref('local_inv'),
212
'product_uom': ref('product.product_uom_unit'),
213
'product_id': ref('product1'),
214
'reason_type_id': ref('reason_types_moves.reason_type_loss'),
216
line_obj.create(cr, uid, {'location_id': is1_id[0],
217
'inventory_id': ref('local_inv'),
218
'product_uom': ref('product.product_uom_unit'),
219
'product_id': ref('product1'),
220
'reason_type_id': ref('reason_types_moves.reason_type_loss'),
222
line_obj.create(cr, uid, {'location_id': is2_id[0],
223
'inventory_id': ref('local_inv'),
224
'product_uom': ref('product.product_uom_unit'),
225
'product_id': ref('product1'),
226
'reason_type_id': ref('reason_types_moves.reason_type_loss'),
228
line_obj.create(cr, uid, {'location_id': cu1_id[0],
229
'inventory_id': ref('local_inv'),
230
'product_uom': ref('product.product_uom_unit'),
231
'product_id': ref('product1'),
232
'reason_type_id': ref('reason_types_moves.reason_type_loss'),
234
line_obj.create(cr, uid, {'location_id': cu2_id[0],
235
'inventory_id': ref('local_inv'),
236
'product_uom': ref('product.product_uom_unit'),
237
'product_id': ref('product1'),
238
'reason_type_id': ref('reason_types_moves.reason_type_loss'),
241
We confirm the inventory
243
!python {model: stock.inventory}: |
244
self.action_confirm(cr, uid, [ref('local_inv')], context=context)
245
self.action_done(cr, uid, [ref('local_inv')], context=context)