2
Creating a res.partner record
4
!record {model: res.partner, id: res_partner_testsupplier0}:
13
Creating a res.partner.address record
15
!record {model: res.partner.address, id: res_partner_address_0}:
16
partner_id: res_partner_testsupplier0
21
Creating a product.nomenclature record
23
!record {model: product.nomenclature, id: product_nomenclature_test0}:
28
Creating a product.nomenclature record
30
!record {model: product.nomenclature, id: product_nomenclature_test1}:
33
parent_id: product_nomenclature_test0
37
Creating a product.nomenclature record
39
!record {model: product.nomenclature, id: product_nomenclature_test2}:
42
parent_id: product_nomenclature_test1
46
Creating a product.nomenclature record
48
!record {model: product.nomenclature, id: product_nomenclature_test3}:
51
parent_id: product_nomenclature_test2
55
Creating a product.category record
57
!record {model: product.category, id: product_category_test1}:
59
family_id: product_nomenclature_test2
61
Creating a product.product record
63
!record {model: product.product, id: product_product_testproduct0}:
65
categ_id: product.cat0
71
name_template: test product
72
nomen_manda_0: product_nomenclature_test0
73
nomen_manda_1: product_nomenclature_test1
74
nomen_manda_2: product_nomenclature_test2
75
nomen_manda_3: product_nomenclature_test3
76
procure_method: make_to_stock
84
uom_id: product.product_uom_unit
85
uom_po_id: product.product_uom_unit
87
valuation: manual_periodic
93
international_status: product_attributes.int_1
96
Creating a ir.sequence record
98
!record {model: ir.sequence, id: ir_sequence_purchaseorder0}:
107
Creating a ir.sequence.type record
109
!record {model: ir.sequence.type, id: ir_sequence_type_purchaseorder0}:
114
Creating a purchase.order record
116
!record {model: purchase.order, id: purchase_order_po0}:
121
company_id: base.main_company
122
date_order: !eval "'%s-08-29'%(time.strftime('%Y'),)"
123
delivery_requested_date: !eval "'%s-08-31'%(time.strftime('%Y'),)"
124
est_transport_lead_time: 0.0
125
invoice_method: order
126
location_id: stock.stock_location_stock
127
minimum_planned_date: !eval "'%s-08-29'%(time.strftime('%Y'),)"
130
partner_address_id: res_partner_address_0
131
partner_id: res_partner_testsupplier0
132
pricelist_id: purchase.list0
133
sequence_id: ir_sequence_purchaseorder0
137
Creating a purchase.order.line record
139
!record {model: purchase.order.line, id: purchase_order_line_testproduct0}:
140
company_id: base.main_company
141
date_planned: !eval "'%s-08-29'%(time.strftime('%Y'),)"
143
default_name: test product
145
internal_name: test product
148
order_id: purchase_order_po0
149
partner_id: res_partner_testsupplier0
151
product_id: product_product_testproduct0
153
product_uom: product.product_uom_unit
159
!python {model: purchase.order}: |
161
#print self.search(cr, uid, [('name', '=', 'PO test')])
164
We confirm the purchase_order_po0
166
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0}
170
We confirm the purchase_order_po0 (double validation)
172
!workflow {model: purchase.order, action: purchase_approve, ref: purchase_order_po0}
176
Check incoming Creation
178
!python {model: stock.picking}: |
181
pick_ids = self.search(cr, uid, [('purchase_id', '=', ref("purchase_order_po0"))], context=context)
182
assert len(pick_ids) == 1, 'wrong number of IN stock picking'
183
context.update(active_ids=pick_ids)
184
# process incoming shipment with a new expiry date
185
# create wizard objects
186
wizard_obj = self.pool.get('stock.partial.picking')
187
wizard_id = self.action_process(cr, uid, pick_ids, context=context)['res_id']
188
# enter the new expiry date value - memory_out because product cost method is standard price
189
the_date = time.strftime('%Y-%m-%d')
190
the_date = '2022-01-01'
191
for memory_out in wizard_obj.browse(cr, uid, wizard_id, context=context).product_moves_out:
193
memory_out.write({'expiry_date': the_date}, context=context)
195
# validate the processing
197
c.update({'wizard_ids': [wizard_id], 'wizard_id': wizard_id, 'wizard_name': 'name','model': 'stock.partial.picking','step': 'step'})
198
wizard_obj.copy_all(cr,uid,[wizard_id], context=c)
199
wizard_obj.do_partial(cr, uid, [wizard_id], context=context)
200
# check a new production lot has been created with corresponding expiry date
201
prodlot_obj = self.pool.get('stock.production.lot')
202
assert len(prodlot_obj.search(cr, uid, [('life_date', '=', the_date), ('type', '=', 'internal')], context=context)), 'prodlots wrong'
205
We create a inventory control
209
!record {model: stock.inventory, id: stock_inventory0}:
216
!record {model: stock.reason.type, id: stock_reasontype0}:
217
name: testreasontype01
224
!record {model: stock.inventory.line, id: stock_inventory_line0}:
225
location_id: stock.stock_location_stock
226
product_id: product_product_testproduct0
227
reason_type_id: stock_reasontype0
228
product_uom: product.product_uom_unit
229
expiry_date: 2011-10-04
230
inventory_id: stock_inventory0
232
hidden_perishable_mandatory: True
235
Confirm and validate the inventory - check the new production lot
238
!python {model: stock.inventory}: |
239
self.action_confirm(cr, uid, [ref("stock_inventory0")])
240
self.action_done(cr, uid, [ref("stock_inventory0")])
242
# check the new production lot
243
prodlot_obj = self.pool.get('stock.production.lot')
244
ids = prodlot_obj.search(cr, uid, [('product_id', '=', ref("product_product_testproduct0")), ('life_date', '=', '2011-10-04'),])
245
assert len(ids) == 1, 'the number of production lot is wrong - 1 - %s'%len(ids)
248
test new onchange functions
250
product - product_product_testproduct0
251
location_id - stock.stock_location_stock
255
!python {model: stock.inventory.line}: |
257
self.change_lot(cr, uid, [ref("stock_inventory_line0")], ref("stock.stock_location_stock"), ref("product_product_testproduct0"), prod_lot_id=False, uom=False, to_date=False,)
258
# on_change_location_id
259
self.on_change_location_id(cr, uid, [ref("stock_inventory_line0")], ref("stock.stock_location_stock"), ref("product_product_testproduct0"), prod_lot_id=False, uom=False, to_date=False,)
260
# on_change_product_id_specific_rules
261
self.on_change_product_id_specific_rules(cr, uid, [ref("stock_inventory_line0")], ref("stock.stock_location_stock"), ref("product_product_testproduct0"), prod_lot_id=False, uom=False, to_date=False,)
264
Try to create a Min/Max stock rules with an UoM which
265
has a different category than the standard product UoM
267
!python {model: stock.warehouse.orderpoint}: |
269
self.create(cr, uid, {'product_id': ref("product_product_testproduct0"),
270
'location_id': ref("stock.stock_location_stock"),
271
'warehouse_id': ref("stock.warehouse0"),
272
'product_min_qty': 1.00,
273
'product_max_qty': 1.00,
274
'qty_multiple': 1.00,
275
'product_uom': ref("product.product_uom_kgm")})
276
assert False, "No error raised when the Min/Max rule has a non-compatible UoM"