[FIX] stock_location: fixed a bug in the procurement order workflow related to chained stock moves and improved yaml test

bzr revid: qdp-launchpad@openerp.com-20130517145820-hpiah33hm8iq9hd3
This commit is contained in:
Quentin (OpenERP)
2013-05-17 16:58:20 +02:00
parent e42186bd60
commit c8d21a6c64
4 changed files with 35 additions and 152 deletions
@@ -66,7 +66,6 @@ class procurement_order(osv.osv):
'invoice_state': line.invoice_state,
})
print "COmpany_id line:", line.company_id
move_id = move_obj.create(cr, uid, {
'name': line.name,
'picking_id': picking_id,
@@ -19,5 +19,12 @@
<field name="act_from" ref="act_move"/>
<field name="act_to" ref="procurement.act_make_done"/>
</record>
<!-- Overwrite the default stop condition of the procurement in order to take into account its new activity
and not skipping the chained stock/move creation -->
<record id="procurement.trans_confirm_mto_make_done" model="workflow.transition">
<field name="condition">not check_produce() and not check_buy() and not check_move()</field>
</record>
</data>
</openerp>
@@ -1,163 +1,39 @@
-
In order to test the product pulled flow , I create ,partner,product,procurement
-
I create a account type Asset.
-
!record {model: account.account.type, id: account_account_type_asset0}:
close_method: balance
code: asset_test
name: Asset For Tests
-
I create a account type income.
-
!record {model: account.account.type, id: account_account_type_income0}:
close_method: unreconciled
code: income_test
name: Income For Tests
-
I create a account type Expense.
-
!record {model: account.account.type, id: account_account_type_expense0}:
close_method: unreconciled
code: expense_test
name: Expense For Tests
-
I create a account type Receivable.
-
!record {model: account.account.type, id: account_account_type_receivable0}:
close_method: unreconciled
code: receivable_test
name: Receivable For Tests
-
I create a account Receivable.
-
!record {model: account.account, id: account_account_receivable0}:
code: 40000_test
company_id: base.main_company
currency_mode: current
name: Receivable For Tests
type: receivable
user_type: account_account_type_receivable0
-
I create a account Payable.
-
!record {model: account.account, id: account_account_payable0}:
code: 440000_test
company_id: base.main_company
currency_mode: current
name: Payable For Tests
type: payable
user_type: account_account_type_expense0
-
I create a Purchase Journal.
-
!record {model: account.journal, id: account_journal_purchasejournal0}:
code: pur_test
company_id: base.main_company
name: Purchase Journal For Tests
sequence_id: account.sequence_purchase_journal
type: purchase
-
I create a Sale Journal.
-
!record {model: account.journal, id: account_journal_salejouran0}:
code: sal_test
company_id: base.main_company
name: Sale Journal For Tests
sequence_id: account.sequence_sale_journal
type: sale
-
I create an Expense Account
-
!record {model: account.account, id: account_account_expenseaccount0}:
code: Expe_test
company_id: base.main_company
currency_mode: current
name: Expense Account For Tests
type: consolidation
user_type: account_account_type_asset0
-
I create Product Sale account.
-
!record {model: account.account, id: account_account_productsale0}:
code: 001_test
company_id: base.main_company
currency_mode: current
name: Product Sale For Tests
type: other
user_type: account_account_type_income0
-
I create Product Product Purchase.
-
!record {model: account.account, id: account_account_productpurchase0}:
code: 0002_test
company_id: base.main_company
currency_mode: current
name: Product Purchase For Tests
type: other
user_type: account_account_type_expense0
-
I create a Supplier.
-
!record {model: res.partner, id: res_partner_shawtrust0}:
name: Shaw Trust
lang: en_US
country_id: base.in
street: St James House, Vicar Lane, Sheffiel
property_account_payable: account_account_payable0
property_account_receivable: account_account_receivable0
-
I create a product category.
-
!record {model: product.category, id: product_category_computer0}:
name: Computer
-
I create a product and define the pulled flow condition for stock move.
I set shipping type Sending Goods. and set Procurement type to move.
In order to test the stock_location module, I create a product and define its pulled flows. If a product is needed either in Chicago Shop or in Birmingham shop, there must be a incomming move from transit location to these shops, and an outgoing move from Stock to the transit location.
-
!record {model: product.product, id: product_product_hpcdwriters01}:
categ_id: product_category_computer0
cost_method: standard
list_price: 1000.0
mes_type: fixed
name: HP CD writers
procure_method: make_to_stock
seller_ids:
- delay: 1
name: res_partner_shawtrust0
min_qty: 5.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
property_account_expense: account_account_productpurchase0
property_account_income: account_account_productsale0
property_account_expense: account.a_expense
property_account_income: account.rev
flow_pull_ids:
- invoice_state: none
location_id: stock.stock_location_shop0
location_src_id: stock.stock_location_shop1
location_src_id: stock.stock_location_intermediatelocation0
name: E001
picking_type: out
procure_method: make_to_stock
picking_type: in
procure_method: make_to_order
type_proc: move
company_id: stock.res_company_1
- invoice_state: none
location_id: stock.stock_location_shop1
location_src_id: stock.stock_location_intermediatelocation0
name: E002
picking_type: out
procure_method: make_to_stock
picking_type: in
procure_method: make_to_order
type_proc: move
company_id: stock.res_company_1
company_id: stock.res_company_2
- invoice_state: none
location_id: stock.stock_location_intermediatelocation0
location_src_id: stock.stock_location_stock
name: E003
type_proc: move
picking_type: out
company_id: base.main_company
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
@@ -187,18 +63,26 @@
-
!python {model: procurement.order.compute.all}: |
proc_obj = self.pool.get('procurement.order')
proc_obj._procure_confirm(cr,uid)
proc_obj._procure_confirm(cr,uid, ids=[ref('procurement_order_test0')])
-
I check the new procurement order has been created .
-
!python {model: procurement.order }: |
from openerp.tools.translate import _
procurement_ids=self.search(cr, uid, [('name','=','E001')])
assert len(procurement_ids), "Procurement order hasn't Created."
procurement_ids = self.search(cr, uid, [('name','=','E001')])
assert len(procurement_ids), "Procurement order hasn't been created."
-
I check the Outgoing Picking is created for source location Birmingham Shop and destination Chicago shop.
I check the Outgoing Picking is created for source location Stock and destination Chicago shop.
-
!python {model: stock.picking }: |
from openerp.tools.translate import _
picking_id = self.search(cr, uid, [('origin','=','Testing pulled flow:E001'),('type','=','out')])
assert len(picking_id), "Picking hasn't Created."
in_picking_id = self.search(cr, uid, [('origin','=','Testing pulled flow:E001'),('type','=','in')])
assert len(in_picking_id), "Picking in hasn't been created."
in_picking = self.browse(cr, uid, in_picking_id[0])
assert in_picking.move_lines[0].location_id.id == ref('stock.stock_location_intermediatelocation0'), "wrong source location for picking in"
assert in_picking.move_lines[0].location_dest_id.id == ref('stock.stock_location_shop0'), "wrong destination location for picking in"
assert in_picking.company_id.id == ref('stock.res_company_1'), "wrong company for picking in"
out_picking_id = self.search(cr, uid, [('origin','like','%E003%'),('type','=','out')])
assert len(out_picking_id), "Picking out hasn't been created."
out_picking = self.browse(cr, uid, out_picking_id[0])
assert out_picking.move_lines[0].location_id.id == ref('stock.stock_location_stock'), "wrong source location for picking out"
assert out_picking.move_lines[0].location_dest_id.id == ref('stock.stock_location_intermediatelocation0'), "wrong destination location for picking out"
assert out_picking.company_id.id == ref('base.main_company'), "wrong company for picking out"
@@ -1,20 +1,14 @@
-
In order to test the product pushed flow , I create account ,partner,product,shipment
Push flow specification indicates which location is chained with which location.
-
I create product category.
-
!record {model: product.category, id: product_category_computer0}:
name: Computer
-
I create Supplier.
-
!record {model: res.partner, id: res_partner_microlinktechnologies0}:
street: Kailash Vaibhav, Parksite
name: Micro Link Technologies
property_account_payable: account_account_payable0
property_account_receivable: account_account_receivable0
property_account_payable: account.a_pay
property_account_receivable: account.a_recv
supplier: true
is_company: true
@@ -35,7 +29,6 @@
Stock Input to Quality test and Quality test -Stock .
-
!record {model: product.product, id: product_product_hpcdwriters01}:
categ_id: product_category_computer0
cost_method: standard
list_price: 1000.0
mes_type: fixed