merge coverage purchase

bzr revid: fp@tinyerp.com-20111113160732-7ic5t0igzh0jw2pm
This commit is contained in:
Fabien Pinckaers 2011-11-13 17:07:32 +01:00
commit ecc200a14f
21 changed files with 402 additions and 812 deletions

View File

@ -470,14 +470,6 @@ class procurement_order(osv.osv):
wf_service.trg_trigger(uid, 'procurement.order', id, cr)
return res
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
''' Runs through scheduler.
@param use_new_cursor: False or the dbname
'''
self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
use_new_cursor=use_new_cursor, context=context)
procurement_order()
class StockPicking(osv.osv):

View File

@ -31,6 +31,14 @@ import pooler
class procurement_order(osv.osv):
_inherit = 'procurement.order'
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
''' Runs through scheduler.
@param use_new_cursor: False or the dbname
'''
self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
use_new_cursor=use_new_cursor, context=context)
def _procure_confirm(self, cr, uid, ids=None, use_new_cursor=False, context=None):
'''
Call the scheduler to check the procurement order

View File

@ -60,15 +60,19 @@ Dashboard for purchase management that includes:
'board_purchase_view.xml',
],
'test': [
'test/purchase_from_order.yml',
'test/purchase_from_manual.yml',
'test/purchase_from_picking.yml',
'purchase_unit_test.xml',
'test/procurement_buy.yml',
'test/purchase_report.yml',
'test/purchase_order_cancel_draft.yml'
],
'demo': ['purchase_demo.xml'],
'test/process/cancel_order.yml',
'test/process/rfq2order2done.yml',
'test/process/generate_invoice_from_reception.yml',
'test/process/run_scheduler.yml',
'test/process/merge_order.yml',
'test/ui/print_report.yml',
'test/ui/onchange_events.yml',
'test/ui/duplicate_order.yml',
'test/ui/delete_order.yml',
],
'demo': [
'purchase_demo.xml',
],
'installable': True,
'active': False,
'certificate': '0057234283549',

View File

@ -253,31 +253,32 @@ class purchase_order(osv.osv):
def button_dummy(self, cr, uid, ids, context=None):
return True
def onchange_dest_address_id(self, cr, uid, ids, adr_id):
if not adr_id:
def onchange_dest_address_id(self, cr, uid, ids, address_id):
if not address_id:
return {}
address = self.pool.get('res.partner.address')
values = {'warehouse_id': False}
part_id = self.pool.get('res.partner.address').browse(cr, uid, adr_id).partner_id
if part_id:
loc_id = part_id.property_stock_customer.id
values.update({'location_id': loc_id})
supplier = address.browse(cr, uid, address_id).partner_id
if supplier:
location_id = supplier.property_stock_customer.id
values.update({'location_id': location_id})
return {'value':values}
def onchange_warehouse_id(self, cr, uid, ids, warehouse_id):
if not warehouse_id:
return {}
res = self.pool.get('stock.warehouse').read(cr, uid, [warehouse_id], ['lot_input_id'])[0]['lot_input_id'][0]
return {'value':{'location_id': res, 'dest_address_id': False}}
warehouse = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id)
return {'value':{'location_id': warehouse.lot_input_id.id, 'dest_address_id': False}}
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
def onchange_partner_id(self, cr, uid, ids, partner_id):
partner = self.pool.get('res.partner')
if not partner_id:
return {'value':{'partner_address_id': False, 'fiscal_position': False}}
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default'])
part = self.pool.get('res.partner').browse(cr, uid, part)
pricelist = part.property_product_pricelist_purchase.id
fiscal_position = part.property_account_position and part.property_account_position.id or False
return {'value':{'partner_address_id': addr['default'], 'pricelist_id': pricelist, 'fiscal_position': fiscal_position}}
supplier_address = partner.address_get(cr, uid, [partner_id], ['default'])
supplier = partner.browse(cr, uid, partner_id)
pricelist = supplier.property_product_pricelist_purchase.id
fiscal_position = supplier.property_account_position and supplier.property_account_position.id or False
return {'value':{'partner_address_id': supplier_address['default'], 'pricelist_id': pricelist, 'fiscal_position': fiscal_position}}
def wkf_approve_order(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'approved', 'date_approve': time.strftime('%Y-%m-%d')})
@ -299,7 +300,7 @@ class purchase_order(osv.osv):
for id in ids:
self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
return True
# Dead code:
def wkf_warn_buyer(self, cr, uid, ids):
self.write(cr, uid, ids, {'state' : 'wait', 'validator' : uid})
request = pooler.get_pool(cr.dbname).get('res.request')
@ -344,6 +345,9 @@ class purchase_order(osv.osv):
self.log(cr, uid, id, message)
return True
#TOFIX
# - implement hook method on create invoice and invoice line
# - doc string
def action_invoice_create(self, cr, uid, ids, *args):
res = False
@ -539,6 +543,7 @@ class purchase_order(osv.osv):
@return: new purchase order id
"""
#TOFIX: merged order line should be unlink
wf_service = netsvc.LocalService("workflow")
def make_key(br, fields):
list_key = []
@ -694,6 +699,11 @@ class purchase_order_line(osv.osv):
default.update({'state':'draft', 'move_ids':[],'invoiced':0,'invoice_lines':[]})
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
#TOFIX:
# - name of method should "onchange_product_id"
# - docstring
# - merge 'product_uom_change' method
# - split into small internal methods for clearity
def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=False, fiscal_position=False, date_planned=False,
name=False, price_unit=False, notes=False, context={}):
@ -767,6 +777,8 @@ class purchase_order_line(osv.osv):
res['domain'] = domain
return res
#TOFIX:
# - merge into 'product_id_change' method
def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order=False, fiscal_position=False, date_planned=False,
name=False, price_unit=False, notes=False, context={}):
@ -891,23 +903,4 @@ class procurement_order(osv.osv):
return res
procurement_order()
class stock_invoice_onshipping(osv.osv_memory):
_inherit = "stock.invoice.onshipping"
def create_invoice(self, cr, uid, ids, context=None):
if context is None:
context = {}
res = super(stock_invoice_onshipping,self).create_invoice(cr, uid, ids, context=context)
purchase_obj = self.pool.get('purchase.order')
picking_obj = self.pool.get('stock.picking')
for pick_id in res:
pick = picking_obj.browse(cr, uid, pick_id, context=context)
if pick.purchase_id:
purchase_obj.write(cr, uid, [pick.purchase_id.id], {
'invoice_ids': [(4, res[pick_id])]}, context=context)
return res
stock_invoice_onshipping()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -12,6 +12,7 @@
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="pricelist_id" ref="purchase.list0"/>
<field name="partner_id" ref="base.res_partner_asus"/>
<field name="invoice_method">order</field>
<field name="partner_address_id" ref="base.res_partner_address_tang"/>
</record>
@ -19,6 +20,7 @@
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="pricelist_id" ref="purchase.list0"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field name="invoice_method">picking</field>
<field name="partner_address_id" ref="base.res_partner_address_zen"/>
</record>
@ -49,6 +51,13 @@
<field name="partner_id" ref="base.res_partner_vickingdirect0"/>
<field name="partner_address_id" ref="base.res_partner_address_brussels0"/>
</record>
<record id="order_purchase7" model="purchase.order">
<field name="location_id" ref="stock.stock_location_stock"/>
<field name="pricelist_id" ref="purchase.list0"/>
<field name="partner_id" ref="base.res_partner_desertic_hispafuentes"/>
<field name="partner_address_id" ref="base.res_partner_address_3000"/>
</record>
<!--Resource: purchase.order.line-->
<record id="line1_purchase" model="purchase.order.line">
@ -57,7 +66,7 @@
<field name="name">New server config + material</field>
<field model="product.product" name="product_id" search="[]"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">150</field>
<field name="price_unit">150.50</field>
<field name="product_qty">5</field>
</record>
@ -67,7 +76,7 @@
<field name="name">[PC1] Basic PC</field>
<field name="product_id" ref="product.product_product_pc1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">450</field>
<field name="price_unit">450.20</field>
<field name="product_qty">2</field>
</record>
@ -101,6 +110,26 @@
<field name="product_qty">5</field>
</record>
<record id="line71_purchase" model="purchase.order.line">
<field name="order_id" ref="order_purchase7"/>
<field name="date_planned" eval="time.strftime('%Y/%m/%d')"/>
<field name="name">Onsite Senior Intervention</field>
<field name="product_id" ref="product.product_product_0"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">900</field>
<field name="product_qty">5</field>
</record>
<record id="line72_purchase" model="purchase.order.line">
<field name="order_id" ref="order_purchase7"/>
<field name="date_planned" eval="time.strftime('%Y/%m/%d')"/>
<field name="name">Onsite Intervention</field>
<field name="product_id" ref="product.product_product_1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">100</field>
<field name="product_qty">15</field>
</record>
<record id="line6_purchase" model="purchase.order.line">
<field name="order_id" ref="order_purchase4"/>
<field name="date_planned" eval="time.strftime('%Y/%m/%d')"/>

View File

@ -1,97 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Resource: purchase.order -->
<record model="purchase.order" id="test_purchase_1">
<field name="name">Test purchase</field>
<field name="dest_address_id" search="[]" model="res.partner.address"/>
<field name="pricelist_id" ref="list0"/>
<field name="partner_id" search="[]" model="res.partner"/>
<field name="partner_address_id" search="[]" model="res.partner.address"/>
<field name="location_id" ref="stock.stock_location_stock"/>
</record>
<record model="purchase.order.line" id="test_purchase_1_line_1">
<field name="order_id" ref="test_purchase_1"/>
<field name="name">[PC1] Basic PC</field>
<field name="date_planned" eval="time.strftime('%Y-%m-%d', time.localtime(time.time() + 2 * 86400))" />
<field name="product_id" ref="product.product_product_pc1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">450</field>
<field name="product_qty">2</field>
</record>
<record model="purchase.order.line" id="test_purchase_1_line_3">
<field name="order_id" ref="test_purchase_1"/>
<field name="name">[MB1] Mainboard ASUStek A7N8X</field>
<field name="date_planned" eval="time.strftime('%Y-%m-%d', time.localtime(time.time() + 2 * 86400))" />
<field name="product_id" ref="product.product_product_mb1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">88</field>
<field name="product_qty">3</field>
</record>
<assert model="purchase.order" id="test_purchase_1" string="The amount of Test purchase is correctly computed">
<test expr="sum([l.price_subtotal for l in order_line]) == amount_untaxed" />
</assert>
<workflow model="purchase.order" ref="test_purchase_1" action="purchase_confirm" />
<assert model="purchase.order" id="test_purchase_1" string="Test purchase is now in progress">
<test expr="state">approved</test>
</assert>
<!-- Treat generated invoice -->
<assert model="purchase.order" id="test_purchase_1" string="Test purchase has now a corresponding invoice" severity="fatal">
<test expr="bool(invoice_ids)" />
</assert>
<assert model="purchase.order" id="test_purchase_1" string="Test purchase's invoice has the same amount and is currently a draft">
<test expr="invoice_ids[0].state">draft</test>
</assert>
<workflow model="account.invoice" action="invoice_open">
<value model="purchase.order" eval="obj(ref('test_purchase_1')).invoice_ids[0].id" />
</workflow>
<function model="account.invoice" name="pay_and_reconcile">
<value model="purchase.order" eval="[obj(ref('test_purchase_1')).invoice_ids[0].id]" />
<value eval="1164" />
<value eval="ref('account.cash')"/>
<value eval="ref('account.period_' + str(int(time.strftime('%m'))))" />
<value eval="ref('account.bank_journal')" />
<value eval="ref('account.cash')"/>
<value eval="ref('account.period_' + str(int(time.strftime('%m'))))" />
<value eval="ref('account.bank_journal')" />
</function>
<assert model="purchase.order" id="test_purchase_1" string="Test purchase's invoice is now paid" severity="error">
<test expr="invoice_ids[0].state">paid</test>
</assert>
<!-- Treat generated picking -->
<assert model="purchase.order" id="test_purchase_1" string="Test purchase has now a corresponding picking" severity="fatal">
<test expr="len(picking_ids) == 1" />
</assert>
<assert model="purchase.order" id="test_purchase_1" string="Test purchase's picking will be sent to the good address" severity="error">
<test expr="picking_ids[0].address_id == partner_address_id" />
</assert>
<!-- Do the same as in wizard_partial_picking lines 143-144 -->
<function model="stock.picking" name="action_move">
<value model="purchase.order" eval="[obj(ref('test_purchase_1')).picking_ids[0].id]" />
</function>
<workflow model="stock.picking" action="button_done">
<value model="purchase.order" eval="obj(ref('test_purchase_1')).picking_ids[0].id" />
</workflow>
<assert model="purchase.order" id="test_purchase_1" string="Test purchase's picking is now done" severity="error">
<test expr="picking_ids[0].state">done</test>
</assert>
<assert model="purchase.order" id="test_purchase_1" string="Test purchase is now completed" severity="fatal">
<test expr="state">done</test>
</assert>
</data>
</openerp>

View File

@ -121,7 +121,7 @@ class stock_picking(osv.osv):
def _invoice_hook(self, cursor, user, picking, invoice_id):
purchase_obj = self.pool.get('purchase.order')
if picking.purchase_id:
purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoice_id': invoice_id,})
purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoice_ids': [(4, invoice_id)]})
return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id)
class stock_partial_picking(osv.osv_memory):

View File

@ -0,0 +1,59 @@
-
In order to test the cancel flow, I start it from canceling confirmed purchase order.
-
I confirm the purchase order.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase1}
-
I check the "Approved" status after confirmed RFQ.
-
!assert {model: purchase.order, id: order_purchase1}:
- state == 'approved'
-
First I cancel receptions related to this order if order shipped.
-
!python {model: purchase.order}: |
order = self.browse(cr, uid, ref("order_purchase1"))
self.pool.get('stock.picking').action_cancel(cr, uid, [picking.id for picking in order.picking_ids])
-
I check order status in "Shipping Exception".
-
!python {model: purchase.order}: |
order = self.browse(cr, uid, ref("order_purchase1"))
assert order.state == "except_picking", "order should be in Ship Exception state after cancel shipment"
-
Now I am able to cancel purchase order.
-
!python {model: purchase.order}: |
self.action_cancel(cr, uid, [ref("order_purchase1")])
-
I check that order is cancelled.
-
!assert {model: purchase.order, id: order_purchase1}:
- state == 'cancel'
-
After cancel the order, I check that it's related invoice cancelled.
-
!python {model: purchase.order}: |
order = self.browse(cr, uid, ref("order_purchase1"))
assert order.invoice_ids[0].state == "cancel", "order's related invoice should be cancelled"
-
Now again set cancelled order to draft.
-
!python {model: purchase.order}: |
self.action_cancel_draft(cr, uid, [ref("order_purchase1")])
-
Now I again to cancel draft order.
-
!python {model: purchase.order}: |
self.action_cancel(cr, uid, [ref("order_purchase1")])
-
I check that order is cancelled.
-
!assert {model: purchase.order, id: order_purchase1}:
- state == 'cancel'
-
Now again set cancelled order to draft.
-
!python {model: purchase.order}: |
self.action_cancel_draft(cr, uid, [ref("order_purchase1")])

View File

@ -0,0 +1,24 @@
-
I confirm another order where invoice control is 'Based on receptions'.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase2}
-
I check that the invoice of order.
-
!python {model: purchase.order}: |
purchase_order = self.browse(cr, uid, ref("order_purchase2"))
assert len(purchase_order.invoice_ids) == 0, "Invoice should not be generated on order confirmation."
-
Now I create an invoice for order on reception.
-
!python {model: stock.picking}: |
pick_ids = self.search(cr, uid, [('purchase_id','=',ref('order_purchase2'))])
self.action_invoice_create(cr, uid, pick_ids, ref('account.expenses_journal'))
-
I check that the invoice of order.
-
!python {model: purchase.order}: |
purchase_order = self.browse(cr, uid, ref("order_purchase2"))
assert len(purchase_order.invoice_ids) == 1, "Invoice should be generated."

View File

@ -0,0 +1,42 @@
-
In order to merge RFQ, I merge two RFQ which has same supplier and check new merged order.
-
!python {model: purchase.order}: |
new_id = self.do_merge(cr, uid, [ref('order_purchase3'), ref('order_purchase7')])
order3 = self.browse(cr, uid, ref('order_purchase3'))
order7 = self.browse(cr, uid, ref('order_purchase7'))
total_qty = sum([x.product_qty for x in order3.order_line] + [x.product_qty for x in order7.order_line])
assert order3.state == 'cancel', "Merged order should be canceled"
assert order7.state == 'cancel', "Merged order should be canceled"
def merged_data(lines):
product_id =[]
product_uom = []
res = {}
for line in lines:
product_id.append(line.product_id.id)
product_uom.append(line.product_uom.id)
res.update({'product_ids': product_id,'product_uom':product_uom})
return res
for order in self.browse(cr, uid, new_id.keys()):
total_new_qty = [x.product_qty for x in order.order_line]
total_new_qty = sum(total_new_qty)
assert total_new_qty == total_qty,"product quantities are not correspond"
assert order.partner_id == order3.partner_id ,"partner is not correspond"
assert order.partner_address_id == order3.partner_address_id ,"Partner address is not correspond"
assert order.warehouse_id == order3.warehouse_id or order7.warehouse_id,"Warehouse is not correspond"
assert order.state == 'draft',"New created order state should be in draft"
assert order.pricelist_id == order3.pricelist_id,"Price list is not correspond"
assert order.date_order == order3.date_order ,"Date of order is not correspond"
assert order.location_id == order3.location_id ,"Location is not correspond"
n_product_data = merged_data(order.order_line)
o_product_data= merged_data(order3.order_line)
o_pro_data = merged_data(order7.order_line)
assert n_product_data == o_product_data or o_pro_data,"product data are not correspond"

View File

@ -0,0 +1,103 @@
-
In order to test the purchase order flow, I compute the total of the listed products.
"Basic PC" product price is 450.20 and ordered 2 'PCE'
"New server config + material" product price is 150.50 and ordered 5 'PCE'
So, Total should be [(450.20*2)+(150.50*5)] = 1652.90
-
I check the total untaxed amount of the RFQ is correctly computed
-
!assert {model: purchase.order, id: order_purchase1, string: The amount of RFQ is not correctly computed}:
- sum([l.price_subtotal for l in order_line]) == amount_untaxed
-
I confirm the RFQ.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: order_purchase1}
-
I check the "Approved" status after confirmed RFQ.
-
!assert {model: purchase.order, id: order_purchase1}:
- state == 'approved'
-
I check that the invoice details which is generated after confirmed RFQ.
-
!python {model: purchase.order}: |
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
assert len(purchase_order.invoice_ids) >= 1, "Invoice is not generated more or less than one"
for invoice in purchase_order.invoice_ids:
assert invoice.state == "draft" or "cancel", "Invoice state should be draft"
assert invoice.partner_id == purchase_order.partner_id, "Supplier is not correspond with purchase order"
assert invoice.reference == purchase_order.partner_ref or purchase_order.name,"Invoice reference is not correspond with purchase order"
assert invoice.account_id == purchase_order.partner_id.property_account_payable ,"Invoice account is not correspond with purchase order"
assert invoice.type == 'in_invoice',"Invoice type is not correspond with purchase order"
assert invoice.currency_id == purchase_order.pricelist_id.currency_id ,"Invoice currency is not correspond with purchase order"
assert invoice.address_invoice_id == purchase_order.partner_address_id ,"Invoice address is not correspond with purchase order"
assert invoice.address_contact_id == purchase_order.partner_address_id ,"Invoice contact details are not correspond with purchase order"
assert invoice.origin == purchase_order.name,"Invoice origin is not correspond with purchase order"
assert invoice.company_id == purchase_order.company_id ,"Invoice company is not correspond with purchase order"
assert invoice.name == purchase_order.name, "Invoice name is not correspond with purchase order"
assert invoice.amount_untaxed == purchase_order.amount_untaxed, "Invoice untaxed amount is not correspond with purchase order"
assert invoice.amount_tax == purchase_order.amount_tax, "Invoice tax amount is not correspond with purchase order"
assert invoice.amount_total == purchase_order.amount_total, "Invoice total amount is not correspond with purchase order"
assert len(invoice.invoice_line) == len(purchase_order.order_line), "Lines of Invoice and Purchase Order are not correspond"
for index in range(0,len(invoice.invoice_line)):
assert invoice.invoice_line[index].product_id == purchase_order.order_line[index].product_id or False,"Product is not correspond"
assert invoice.invoice_line[index].name == purchase_order.order_line[index].name, "Product description is not correspond"
assert invoice.invoice_line[index].price_unit == purchase_order.order_line[index].price_unit or 0.0, "Unit price is not correspond"
assert invoice.invoice_line[index].quantity == purchase_order.order_line[index].product_qty,"Quantity is not correspond"
assert invoice.invoice_line[index].uos_id == purchase_order.order_line[index].product_uom or False,"UOM is not correspond"
assert len(invoice.invoice_line[index].invoice_line_tax_id) == len(purchase_order.order_line[index].taxes_id), "Taxes are not correspond"
for tax in range(0,len(invoice.invoice_line[index].invoice_line_tax_id)):
assert invoice.invoice_line[index].invoice_line_tax_id[tax] == purchase_order.order_line[index].taxes_id[tax], "Tax is not correspond"
-
I check that Reception details after confirmed RFQ.
-
!python {model: purchase.order}: |
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
assert len(purchase_order.picking_ids) >= 1, "Reception should be one"
for picking in purchase_order.picking_ids:
assert picking.state == "assigned" or "cancel", "Reception state should be in assigned state"
assert picking.address_id == purchase_order.dest_address_id or purchase_order.partner_address_id ,"Delivery Address of Reception is not correspond"
if purchase_order.invoice_method == 'picking':
assert picking.invoice_state == '2binvoiced',"Invoice state should be 'To be Invoiced' on Reception."
elif purchase_order.invoice_method == 'picking':
assert picking.invoice_state == 'invoiced',"Invoice state should be 'Invoiced' on Reception."
else:
assert picking.invoice_state == 'none',"Invoice state should Not be applicable on Reception."
assert picking.company_id == purchase_order.company_id ,"Company is not correspond with purchase order"
for index in range(0,len(picking.move_lines)):
assert picking.move_lines[index].product_id == purchase_order.order_line[index].product_id, "Product is not correspond"
assert picking.move_lines[index].location_dest_id == purchase_order.location_id, "Destination Location is not correspond"
assert picking.move_lines[index].product_uom == purchase_order.order_line[index].product_uom, "UOM is not correspond"
assert picking.move_lines[index].product_qty == purchase_order.order_line[index].product_qty, "Quantity is not correspond"
assert picking.move_lines[index].product_uos_qty == purchase_order.order_line[index].product_qty,"UOS Quantity is not correspond"
assert picking.move_lines[index].product_uos == purchase_order.order_line[index].product_uom ,"UOS is not correspond"
assert picking.move_lines[index].price_unit == purchase_order.order_line[index].price_unit ,"Price unit is not correspond"
-
Reception is ready for process so now done the reception.
-
!python {model: stock.partial.picking}: |
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("order_purchase1")).picking_ids
partial_id = self.create(cr, uid, {},context={'active_model': 'stock.picking','active_ids': [pick_ids[1].id]})
self.do_partial(cr, uid, [partial_id])
-
I check that purchase order is shipped.
-
!python {model: purchase.order}: |
assert self.browse(cr, uid, ref("order_purchase1")).shipped == True,"Purchase order should be delivered"
-
I Validate Invoice of Purchase Order.
-
!python {model: purchase.order}: |
import netsvc
invoice_ids = [x.id for x in self.browse(cr, uid, ref("order_purchase1")).invoice_ids]
wf_service = netsvc.LocalService("workflow")
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_open', cr)
-
I check that purchase order is invoiced.
-
!python {model: purchase.order}: |
assert self.browse(cr, uid, ref("order_purchase1")).invoiced == True,"Purchase Order should be invoiced"

View File

@ -0,0 +1,31 @@
-
In order to test the scheduler to generate RFQ.
-
I create procurement order.
-
!record {model: procurement.order, id: procurement_order_testcase0}:
company_id: base.main_company
date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
location_id: stock.stock_location_stock
name: Test scheduler for RFQ
procure_method: make_to_order
product_id: product.product_product_woodlintelm0
product_qty: 15.0
product_uom: product.product_uom_unit
-
I confirm on procurement order.
-
!workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
-
I run the scheduler.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
I check Generated RFQ.
-
!python {model: procurement.order}: |
procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
assert procurement.purchase_id, 'RFQ should be generated!'

View File

@ -1,114 +0,0 @@
-
In order to test the procurement with product type buy in OpenERP, I will create product
and then I will create procurement for this product.
-
I create product.
-
!record {model: product.product, id: product_product_cddrive0}:
categ_id: product.product_category_3
cost_method: standard
mes_type: fixed
name: CD drive
procure_method: make_to_order
supply_method: buy
type: product
seller_delay: '1'
standard_price: 100.0
supply_method: buy
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
seller_delay: '1'
seller_ids:
- delay: 1
name: base.res_partner_asus
min_qty: 2.0
qty: 5.0
-
I create procurement order.
-
!record {model: procurement.order, id: procurement_order_testcase0}:
company_id: base.main_company
date_planned: !eval time.strftime('%Y-%m-%d %H:%M:%S')
location_id: stock.stock_location_stock
name: Test Case
priority: '1'
procure_method: make_to_order
product_id: product_product_cddrive0
product_qty: 5.0
product_uom: product.product_uom_unit
product_uos: product.product_uom_unit
product_uos_qty: 0.0
state: draft
-
I confirm on procurement order.
-
!workflow {model: procurement.order, action: button_confirm, ref: procurement_order_testcase0}
-
I run the scheduler.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
-
I check that purchase order is generated.
-
!python {model: procurement.order}: |
from tools.translate import _
proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
assert(proc_ids.purchase_id), _('Purchase Order is not Created!')
-
I check the state is running.
-
!python {model: procurement.order}: |
from tools.translate import _
proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
assert(proc_ids.state == 'running'), _('Exception')
-
I confirm and Approve the purchase order.
-
!python {model: purchase.order}: |
procurement_obj = self.pool.get('procurement.order')
proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'purchase.order',proc_ids.purchase_id.id,'purchase_confirm', cr)
-
I receive the order of the supplier ASUStek from the Incoming Shipments menu.
-
!python {model: stock.picking }: |
import time
procurement_obj = self.pool.get('procurement.order')
proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
picking_ids = self.search(cr, uid, [('purchase_id', '=', proc_ids.purchase_id.id),('type','=','in')])
pickings = self.browse(cr, uid, picking_ids)
for picking in pickings:
move = picking.move_lines[0]
partial_datas = {
'partner_id': picking.address_id.partner_id.id,
'address_id': picking.address_id.id,
'delivery_date' : time.strftime('%Y-%m-%d')
}
partial_datas['move%s'%(move.id)]= {
'product_id': move.product_id,
'product_qty': move.product_qty,
'product_uom': move.product_uom.id,
}
self.do_partial(cr, uid, [picking.id], partial_datas)
-
I confirm the Reservation.
-
!python {model: stock.move }: |
procurement_obj = self.pool.get('procurement.order')
proc_ids = procurement_obj.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
self.action_done(cr,uid,[proc_ids.move_id.id])
-
I check the state is Done.
-
!python {model: procurement.order}: |
from tools.translate import _
proc_ids = self.browse(cr, uid, [ref('procurement_order_testcase0')])[0]
assert(proc_ids.state == 'done'), _('Order is not in done state')

View File

@ -1,133 +0,0 @@
-
In order to test the purchase flow,I start by creating a new product 'iPod'
-
!record {model: product.product, id: product_product_ipod0}:
categ_id: 'product.product_category_3'
cost_method: standard
mes_type: fixed
name: iPod
price_margin: 2.0
procure_method: make_to_stock
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
seller_delay: '1'
standard_price: 100.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
In order to test the purchase flow,I create a new record where "invoice_method" is From Manual
-
I create purchase order for iPod.
-
!record {model: purchase.order, id: purchase_order_po1}:
company_id: base.main_company
date_order: !eval time.strftime('%Y-%m-%d')
invoice_method: manual
location_id: stock.stock_location_stock
order_line:
- date_planned: !eval time.strftime('%Y-%m-%d')
name: iPod
price_unit: 100.0
product_id: 'product_product_ipod0'
product_qty: 10.0
product_uom: product.product_uom_unit
state: draft
partner_address_id: base.res_partner_address_7
partner_id: base.res_partner_4
pricelist_id: purchase.list0
-
Initially purchase order is in the draft state
-
!assert {model: purchase.order, id: purchase_order_po1}:
- state == 'draft'
-
I confirm the purchase order.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po1}
-
I check that the order which was initially in the draft state has transit to confirm state.
-
!assert {model: purchase.order, id: purchase_order_po1}:
- state == 'approved'
-
I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line
-
!python {model: purchase.order}: |
from tools.translate import _
pur_order_obj=self.browse(cr, uid, ref("purchase_order_po1"))
pur_line=self.pool.get( 'purchase.order.line')
search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ])
assert search_ids, _('Purchase order line is not created!')
-
To check that wizard "Create Invoices" gets opened
-
I create purchase order line invoice entry.
-
!record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}:
{}
-
I create invoice for products in the purchase order.
-
!python {model: purchase.order.line_invoice}: |
pur_obj=self.pool.get('purchase.order')
ids = []
pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po1"))
for line in pur_id1.order_line:
ids.append(line.id)
self.makeInvoices(cr, uid, [1], context={'active_ids': ids})
-
I check that invoice gets created.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_order_obj=self.browse(cr, uid, ref("purchase_order_po1"))
pur_line=self.pool.get( 'purchase.order.line')
search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ])
assert search_ids, _('Invoice is not created!')
-
I check that a record gets created in the Pending Invoices.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_id1=self.browse(cr, uid, ref("purchase_order_po1"))
account_obj = self.pool.get('account.invoice')
ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
assert ids, _('Pending Invoice is not created!')
-
I check that the order which was initially in the confirmed state has transit to approved state.
-
!assert {model: purchase.order, id: purchase_order_po1}:
- state == 'approved'
-
I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved.
-
!python {model: purchase.order}: |
pur_id=self.browse(cr, uid, ref("purchase_order_po1"))
assert(pur_id.date_approve)
-
I check that an entry gets created in the stock pickings.
-
!python {model: purchase.order}: |
pur_id=self.browse(cr, uid, ref("purchase_order_po1"))
assert(pur_id.picking_ids)
-
I check that an entry gets created in the stock moves.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_id1=self.browse(cr, uid, ref("purchase_order_po1"))
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
pick_id = picking_obj.browse(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)])
assert search_id, _('No Incoming Product!')
-
I check that Traceability moves are created.

View File

@ -1,146 +0,0 @@
-
In order to test the purchase flow,I start by creating a new product 'iPod'
-
!record {model: product.product, id: product_product_ipod0}:
categ_id: 'product.product_category_3'
cost_method: standard
mes_type: fixed
name: iPod
price_margin: 2.0
procure_method: make_to_stock
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
seller_delay: '1'
standard_price: 100.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
In order to test the purchase flow,I create a new record where "invoice_method" is From Order.
-
I create purchase order for iPod.
-
!record {model: purchase.order, id: purchase_order_po0}:
company_id: base.main_company
date_order: !eval time.strftime('%Y-%m-%d')
invoice_method: order
location_id: stock.stock_location_stock
order_line:
- date_planned: !eval time.strftime('%Y-%m-%d')
name: iPod
price_unit: 100.0
product_id: 'product_product_ipod0'
product_qty: 10.0
product_uom: product.product_uom_unit
state: draft
partner_address_id: base.res_partner_address_7
partner_id: base.res_partner_4
pricelist_id: purchase.list0
-
Initially purchase order is in the draft state.
-
!assert {model: purchase.order, id: purchase_order_po0}:
- state == 'draft'
-
I confirm the purchase order for iPod.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po0}
-
I changed Expected Date to Next Day.
-
!python {model: purchase.order}: |
import datetime
next_day = (datetime.date.today()+datetime.timedelta(days=1))
self.write(cr, uid, [ref("purchase_order_po0")], {'minimum_planned_date': next_day})
-
I check that the order which was initially in the draft state has transit to confirm state.
-
!assert {model: purchase.order, id: purchase_order_po0}:
- state == 'approved'
-
I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0"))
pur_line=self.pool.get( 'purchase.order.line')
search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ])
assert search_ids, _('Purchase order line is not created!')
-
To check that wizard "Create Invoices" gets called.
-
I create purchase order line invoice entry.
-
!record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}:
{}
-
I create invoice for products in the purchase order.
-
!python {model: purchase.order.line_invoice}: |
pur_obj=self.pool.get('purchase.order')
ids = []
pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po0"))
for line in pur_id1.order_line:
ids.append(line.id)
self.makeInvoices(cr, uid, [1], context={'active_ids': ids})
-
I check that invoice gets created.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_order_obj=self.browse(cr, uid, ref("purchase_order_po0"))
pur_line=self.pool.get( 'purchase.order.line')
search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ])
assert search_ids, _('Invoice is not created!')
-
I check that a record gets created in the Pending Invoices.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_id1=self.browse(cr, uid, ref("purchase_order_po0"))
account_obj = self.pool.get('account.invoice')
ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
assert ids, _('Pending Invoice is not created!')
-
I check that the order which was initially in the confirmed state has transit to approved state.
-
!assert {model: purchase.order, id: purchase_order_po0}:
- state == 'approved'
-
I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved.
-
!python {model: purchase.order}: |
pur_id=self.browse(cr, uid, ref("purchase_order_po0"))
assert(pur_id.date_approve)
-
I check that an entry gets created in the pickings.
-
!python {model: purchase.order}: |
pur_id=self.browse(cr, uid, ref("purchase_order_po0"))
assert(pur_id.picking_ids)
-
I check that an entry gets created in the stock moves.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_id1=self.browse(cr, uid, ref("purchase_order_po0"))
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
pick_id = picking_obj.browse(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)])
assert search_id, _('No Incoming Product!')
-
I check that Traceability moves are created.
-
I check that an invoice_ids field of Delivery&Invoices gets bind with the value.
-
!python {model: purchase.order}: |
pur_id2=self.browse(cr, uid, ref("purchase_order_po0"))
assert(pur_id2.invoice_ids)

View File

@ -1,147 +0,0 @@
-
In order to test the purchase flow,I start by creating a new product 'iPod'
-
!record {model: product.product, id: product_product_ipod0}:
categ_id: 'product.product_category_3'
cost_method: standard
mes_type: fixed
name: iPod
price_margin: 2.0
procure_method: make_to_stock
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
seller_delay: '1'
standard_price: 100.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
-
In order to test the purchase flow,I create a new record where "invoice_method" is From Picking
-
I create purchase order for iPod.
-
!record {model: purchase.order, id: purchase_order_po2}:
company_id: base.main_company
date_order: !eval time.strftime('%Y-%m-%d')
invoice_method: picking
location_id: stock.stock_location_stock
order_line:
- date_planned: !eval time.strftime('%Y-%m-%d')
name: iPod
price_unit: 100.0
product_id: 'product_product_ipod0'
product_qty: 10.0
product_uom: product.product_uom_unit
state: draft
partner_address_id: base.res_partner_address_7
partner_id: base.res_partner_4
pricelist_id: purchase.list0
-
Initially purchase order is in the draft state.
-
!assert {model: purchase.order, id: purchase_order_po2}:
- state == 'draft'
-
I confirm the purchase order for iPod.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_po2}
-
I check that the order which was initially in the draft state has transit to confirm state.
-
!assert {model: purchase.order, id: purchase_order_po2}:
- state == 'approved'
-
I check that an entry gets created in the "Lines to Invoice" of Invoice Control on the basis of purchase order line.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_order_obj=self.browse(cr, uid, ref("purchase_order_po2"))
pur_line=self.pool.get( 'purchase.order.line')
search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name) ])
assert search_ids, _('Purchase order line is not created!')
-
To check that wizard "Create Invoices" gets opened.
-
I create purchase order line invoice entry.
-
!record {model: purchase.order.line_invoice, id: purchase_order_line_invoice_0}:
{}
-
I create invoice for products in the purchase order.
-
!python {model: purchase.order.line_invoice}: |
pur_obj=self.pool.get('purchase.order')
ids = []
pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po2"))
for line in pur_id1.order_line:
ids.append(line.id)
self.makeInvoices(cr, uid, [1], context={'active_ids': ids})
-
I check that invoice gets created.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_order_obj=self.browse(cr, uid, ref("purchase_order_po2"))
pur_line=self.pool.get( 'purchase.order.line')
search_ids=pur_line.search(cr, uid, [('order_id', '=', pur_order_obj.name),('invoiced', '=', '1') ])
assert search_ids, _('Invoice is not created!')
-
I check that a record gets created in the Pending Invoices.
-
!python {model: purchase.order}: |
from tools.translate import _
pur_id1=self.browse(cr, uid, ref("purchase_order_po2"))
account_obj = self.pool.get('account.invoice')
ids = account_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
assert ids, _('Pending Invoice is not created!')
-
I check that the order which was initially in the confirmed state has transit to approved state.
-
!assert {model: purchase.order, id: purchase_order_po2}:
- state == 'approved'
-
I check that date_approve field of Delivery&Invoices gets bind with the date on which it has been approved.
-
!python {model: purchase.order}: |
pur_id=self.browse(cr, uid, ref("purchase_order_po2"))
assert(pur_id.date_approve)
-
I check that an entry gets created in the stock.picking.
-
!python {model: purchase.order}: |
pur_id=self.browse(cr, uid, ref("purchase_order_po2"))
assert(pur_id.picking_ids)
-
I check that an entry gets created related to stock move.
-
!python {model: purchase.order}: |
pur_id1=self.browse(cr, uid, ref("purchase_order_po2"))
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('origin', '=', pur_id1.name)])
pick_id = picking_obj.browse(cr, uid, ids)[0]
move_obj = self.pool.get('stock.move')
search_id = move_obj.search(cr, uid, [('picking_id', '=', pick_id.name)])
assert search_id, 'No Incoming Product!'
-
Then I create an invoice from picking by clicking on "Create Invoice" wizard
-
!python {model: stock.invoice.onshipping}: |
import time
pur_obj=self.pool.get('purchase.order')
pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po2"))
pick_ids = [x.id for x in pur_id1.picking_ids]
id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.expenses_journal')},
{'active_ids': pick_ids, 'active_model': 'stock.picking'})
self.create_invoice(cr, uid, [id], {"active_ids": pick_ids, "active_id": pick_ids[0]})
-
I check that an invoice_ids field of Delivery&Invoices gets bind with the value.
-
!python {model: purchase.order}: |
pur_id2=self.browse(cr, uid, ref("purchase_order_po2"))
assert(pur_id2.invoice_ids)

View File

@ -1,114 +0,0 @@
-
In order to test to Cancel purchase order from Approved State,I start by creating a new product 'Pen Drive1'
-
!record {model: product.product, id: product_product_pendrive1}:
categ_id: 'product.product_category_3'
cost_method: standard
mes_type: fixed
name: Pen Drive
price_margin: 1.0
procure_method: make_to_order
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
standard_price: 500.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
I create first purchase order for Pen Drive1 where "invoice_method" is From Order.
-
!record {model: purchase.order, id: purchase_order_pendrive1}:
company_id: base.main_company
date_order: !eval time.strftime('%Y-%m-%d')
invoice_method: order
location_id: stock.stock_location_stock
order_line:
- date_planned: !eval time.strftime('%Y-%m-%d')
name: Pen Drive
price_unit: 500.0
product_id: 'product_product_pendrive1'
product_qty: 10.0
product_uom: product.product_uom_unit
partner_address_id: base.res_partner_address_7
partner_id: base.res_partner_4
pricelist_id: purchase.list0
-
Initially purchase order is in the draft state.
-
!assert {model: purchase.order, id: purchase_order_pendrive1}:
- state == 'draft'
-
I confirm the purchase order for Pen Drive1.
-
!workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_pendrive1}
-
I check that the order which was initially in the draft state has transmit to confirm state.
-
!assert {model: purchase.order, id: purchase_order_pendrive1}:
- state == 'approved'
-
I have to first cancel Picking of Approved Purchase order .
-
!python {model: stock.picking}: |
search_ids=self.search(cr, uid, [('purchase_id', '=', ref("purchase_order_pendrive1"))])
self.action_cancel(cr, uid, search_ids)
-
Now I have to cancel confirm purchase order for Pen Drive1.
-
!python {model: purchase.order}: |
self.action_cancel(cr, uid, [ref("purchase_order_pendrive1")])
-
I check that the order which was in approved state has transmit to cancel state.
-
!assert {model: purchase.order, id: purchase_order_pendrive1}:
- state == 'cancel'
-
Now again set purchase order for Pen Drive1 to draft state.
-
!python {model: purchase.order}: |
self.action_cancel_draft(cr, uid, [ref("purchase_order_pendrive1")])
-
I check that the First purchase order is in draft state.
-
!assert {model: purchase.order, id: purchase_order_pendrive1}:
- state == 'draft'
-
I test for Copy and Delete Perchase order in Draft state.
-
!python {model: purchase.order}: |
copy_id = self.copy(cr, uid, ref("purchase_order_pendrive1"))
self.unlink(cr, uid, [copy_id])
-
I create Second purchase order for Pen Drive1 where "invoice_method" is From Order.
-
!record {model: purchase.order, id: purchase_order_pendrive2}:
company_id: base.main_company
date_order: !eval time.strftime('%Y-%m-%d')
invoice_method: order
location_id: stock.stock_location_stock
order_line:
- date_planned: !eval time.strftime('%Y-%m-%d')
name: Pen Drive
price_unit: 500.0
product_id: 'product_product_pendrive1'
product_qty: 10.0
product_uom: product.product_uom_unit
partner_address_id: base.res_partner_address_7
partner_id: base.res_partner_4
pricelist_id: purchase.list0
-
Initially Second purchase order is in the draft state.
-
!assert {model: purchase.order, id: purchase_order_pendrive2}:
- state == 'draft'
-
I have merged first and second purchase order which are in draft state, belong to the same supplier,have same stock location, same pricelist.
-
!python {model: purchase.order.group}: |
ids = [ref("purchase_order_pendrive1"),ref("purchase_order_pendrive2")]
self.fields_view_get(cr, uid, context={'active_ids': ids})
self.merge_orders(cr, uid, [1], context={'active_ids': ids})

View File

@ -0,0 +1,22 @@
-
In order to test to delete process on purchase order.
-
I try to delete confirmed order and check Error Message.
-
!python {model: purchase.order}: |
try:
self.unlink(cr, uid, [ref("order_purchase1")])
except Exception,e:
print e
-
I delete draft order.
-
!python {model: purchase.order}: |
self.unlink(cr, uid, [ref("order_purchase5")])
-
I delete cancelled order.
-
!python {model: purchase.order}: |
self.unlink(cr, uid, [ref("order_purchase7")])

View File

@ -0,0 +1,8 @@
-
In order to test the duplicate order and check duplicate details.
-
I duplicate order.
-
!python {model: purchase.order}: |
context.update({'active_id':ref('order_purchase1')})
self.copy(cr, uid, ref('order_purchase1'), context)

View File

@ -0,0 +1,26 @@
-
In order to test the onchange events of order.
-
I call onchange event to change the warehouse of order.
-
!python {model: purchase.order}: |
self.onchange_warehouse_id(cr, uid, [ref('order_purchase1')], ref('stock.stock_warehouse_shop1'))
-
I call onchange event to change the supplier of order.
-
!python {model: purchase.order}: |
self.onchange_partner_id(cr, uid, ref('order_purchase1'), ref('base.res_partner_3'))
-
I call onchange event to change the supplier address of order.
-
!python {model: purchase.order}: |
self.onchange_dest_address_id(cr, uid, [ref('order_purchase1')], ref('base.res_partner_address_8'))
-
I call onchange event to change the product of order line.
-
!python {model: purchase.order.line}: |
self.product_id_change(cr, uid, [ref('line1_purchase')], ref('purchase.list0'), ref('product.product_product_pc3'), 400, ref('product.product_uom_unit'), ref('base.res_partner_3'))

View File

@ -1,16 +1,16 @@
-
In order to test the PDF reports defined on a Purchase Order, we will print a Request Quotation report
-
In order to test the PDF reports defined on a Purchase Order, I print a Request Quotation report
-
!python {model: purchase.order}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.purchase.quotation').create(cr, uid, [ref('purchase.order_purchase1'),ref('purchase.order_purchase2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'purchase-request_quotation'+format), 'wb+').write(data)
-
In order to test the PDF reports defined on a Purchase Order, we will print Purchase Order report
-
I print Purchase Order report
-
!python {model: purchase.order}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.purchase.order').create(cr, uid, [ref('purchase.order_purchase1'),ref('purchase.order_purchase2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'purchase-purchase_order_report'+format), 'wb+').write(data)
file(os.path.join(tools.config['test_report_directory'], 'purchase-purchase_order_report'+format), 'wb+').write(data)