[MERGE] merged cleanup work on sales from dbr branch:

Summary
=======
account/account_invoice.py
* [FIX] warning: 'type' field is not exits in 'account.move'. so removed stuff to set Type in action_move_create() and pay_and_reconsile() method.

mrp/mrp_workflow.xml and procurement/procurement_workflow.xml
* [FIX] bug: procurement is not closed if supply_method is 'procude' without installation of MRP.

sale/sale.py
* [FIX] warning: 'property_ids' field is not exits anymore.
* [FIX] bug: In creation of move line, If UOS is not specified, UOS qty should be assign with UOM Qty
* [REF] ship_recreate: move stuff to re-create shipment into internal function.

sale/sale_demo.xml
* [IMP] modify demo with values.

[REM] 
* advance_invoice.yml [move this into manual_order_policy.yml]
* so_make_invoice.yml [move this into manual_order_policy.yml]
* so_make_line_invoice.yml [move this into manual_order_policy.yml]
* sale_procurement.yml [move this into picking_order_policy.yml]
* sale_report.yml [move this into picking_order_policy.yml]
* invoice_on_ordered_qty.yml 
* invoice_on_shipped_qty.yml 
[IMP]
* manual_order_policy.yml
* picking_order_policy.yml
* postpaid_order_policy.yml
* prepaid_order_policy.yml
* sale_order_demo.yml

[ADD]
* cancel_order.yml
* delete_order.yml

bzr revid: hmo@tinyerp.com-20111201102823-bf6809i0s938hvue
This commit is contained in:
Harry (OpenERP) 2011-12-01 15:58:23 +05:30
commit 61dde65bbe
20 changed files with 336 additions and 2086 deletions

View File

@ -923,7 +923,7 @@ class account_invoice(osv.osv):
'line_id': line,
'journal_id': journal_id,
'date': date,
'type': entry_type,
#'type': entry_type,
'narration':inv.comment
}
period_id = inv.period_id and inv.period_id.id or False
@ -1209,7 +1209,7 @@ class account_invoice(osv.osv):
l2['name'] = name
lines = [(0, 0, l1), (0, 0, l2)]
move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date, 'type': entry_type}
move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date}
move_id = self.pool.get('account.move').create(cr, uid, move, context=context)
line_ids = []

View File

@ -136,7 +136,7 @@
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_produce_make_done" model="workflow.transition">
<record id="procurement.trans_produce_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce"/>
<field name="act_to" ref="procurement.act_make_done"/>
<field name="signal">subflow.done</field>

View File

@ -180,6 +180,10 @@
<field name="act_to" ref="act_cancel"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="trans_produce_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce_check"/>
<field name="act_to" ref="procurement.act_make_done"/>
</record>
<record id="trans_produce_service_make_done" model="workflow.transition">
<field name="act_from" ref="act_produce_service"/>
<field name="act_to" ref="act_make_done"/>

View File

@ -87,18 +87,14 @@ Dashboard for Sales Manager that includes:
],
'demo_xml': ['sale_demo.xml'],
'test': [
'test/edi_sale_order.yml',
'test/data_test.yml',
'test/manual_order_policy.yml',
'test/prepaid_order_policy.yml',
'test/sale_order_demo.yml',
'test/picking_order_policy.yml',
'test/manual_order_policy.yml',
'test/postpaid_order_policy.yml',
'test/advance_invoice.yml',
'test/so_make_line_invoice.yml',
'test/sale_procurement.yml',
'test/invoice_on_ordered_qty.yml',
'test/invoice_on_shipped_qty.yml',
'test/sale_report.yml',
'test/prepaid_order_policy.yml',
'test/cancel_order.yml',
'test/delete_order.yml',
'test/edi_sale_order.yml',
],
'installable': True,
'active': False,

View File

@ -691,7 +691,6 @@ class sale_order(osv.osv):
'location_id': order.shop_id.warehouse_id.lot_stock_id.id,
'procure_method': line.type,
'move_id': move_id,
'property_ids': [(6, 0, [x.id for x in line.property_ids])],
'company_id': order.company_id.id,
}
@ -706,7 +705,7 @@ class sale_order(osv.osv):
'date_expected': date_planned,
'product_qty': line.product_uom_qty,
'product_uom': line.product_uom.id,
'product_uos_qty': line.product_uos_qty,
'product_uos_qty': (line.product_uos and line.product_uos_qty) or line.product_uom_qty,
'product_uos': (line.product_uos and line.product_uos.id)\
or line.product_uom.id,
'product_packaging': line.product_packaging.id,
@ -738,6 +737,28 @@ class sale_order(osv.osv):
'company_id': order.company_id.id,
}
def ship_recreate(self, cr, uid, order, line, move_id, proc_id):
# FIXME: deals with potentially cancelled shipments, seems broken (specially if shipment has production lot)
"""
Define ship_recreate for process after shipping exception
param order: sale order to which the order lines belong
param line: sale order line records to procure
param move_id: the ID of stock move
param proc_id: the ID of procurement
"""
move_obj = self.pool.get('stock.move')
if order.state == 'shipping_except':
for pick in order.picking_ids:
for move in pick.move_lines:
if move.state == 'cancel':
mov_ids = move_obj.search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)])
if mov_ids:
for mov in move_obj.browse(cr, uid, mov_ids):
# FIXME: the following seems broken: what if move_id doesn't exist? What if there are several mov_ids? Shouldn't that be a sum?
move_obj.write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
return True
def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args):
"""Create the required procurements to supply sale order lines, also connecting
the procurements to appropriate stock moves in order to bring the goods to the
@ -760,8 +781,8 @@ class sale_order(osv.osv):
move_obj = self.pool.get('stock.move')
picking_obj = self.pool.get('stock.picking')
procurement_obj = self.pool.get('procurement.order')
proc_ids = []
for line in order_lines:
if line.state == 'done':
continue
@ -781,19 +802,7 @@ class sale_order(osv.osv):
proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))
proc_ids.append(proc_id)
line.write({'procurement_id': proc_id})
# FIXME: deals with potentially cancelled shipments, seems broken, see below
# FIXME: was introduced by revid: mtr@mtr-20101125100355-0a1b7m792t63mssv
if order.state == 'shipping_except':
for pick in order.picking_ids:
for move in pick.move_lines:
if move.state == 'cancel':
mov_ids = move_obj.search(cr, uid, [('state', '=', 'cancel'),('sale_line_id', '=', line.id),('picking_id', '=', pick.id)])
if mov_ids:
for mov in move_obj.browse(cr, uid, mov_ids):
# FIXME: the following seems broken: what if move_id doesn't exist? What if there are several mov_ids? Shouldn't that be a sum?
move_obj.write(cr, uid, [move_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
procurement_obj.write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty})
self.ship_recreate(cr, uid, order, line, move_id, proc_id)
wf_service = netsvc.LocalService("workflow")
if picking_id:

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<data noupdate="0">
<!--Resource: sale.order-->
@ -12,6 +12,9 @@
<field ref="base.res_partner_address_8" name="partner_invoice_id"/>
<field ref="base.res_partner_address_8" name="partner_shipping_id"/>
<field ref="base.res_partner_address_8" name="partner_order_id"/>
<field name="order_policy">picking</field>
<field name="invoice_quantity">procurement<field>
<field name="note">Invoice after delivery</field>
</record>
<!--Resource: sale.order.line-->
@ -19,9 +22,9 @@
<record id="line" model="sale.order.line">
<field name="order_id" ref="order"/>
<field name="name">New server config + material</field>
<field model="product.product" name="product_id" search="[]"/>
<field model="product.uom" name="product_uom" search="[]"/>
<field name="price_unit">123</field>
<field name="product_id" ref="product.product_product_mb1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">123.20</field>
<field name="type">make_to_stock</field>
</record>
@ -30,20 +33,20 @@
<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.50</field>
<field name="product_uom_qty">3</field>
<field name="product_uos_qty">3</field>
<field name="type">make_to_stock</field>
</record>
<record id="line13" model="sale.order.line">
<field name="order_id" ref="order"/>
<field name="name">[PC1] Basic PC</field>
<field name="product_id" ref="product.product_product_pc1"/>
<field name="name">[PC3] Medium PC</field>
<field name="product_id" ref="product.product_product_pc3"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">450</field>
<field name="product_uom_qty">3</field>
<field name="product_uos_qty">3</field>
<field name="price_unit">900</field>
<field name="product_uom_qty">5</field>
<field name="type">make_to_stock</field>
<field name="delay">1</field>
</record>
<record id="line12" model="sale.order.line">
<field name="order_id" ref="order"/>
@ -66,6 +69,9 @@
<field name="partner_invoice_id" ref="base.res_partner_address_9"/>
<field name="partner_shipping_id" ref="base.res_partner_address_9"/>
<field name="partner_order_id" ref="base.res_partner_address_9"/>
<field name="invoice_quantity">order<field>
<field name="order_policy">postpaid</field>
</record>
<!--Resource: sale.order.line-->
@ -99,6 +105,7 @@
<field name="partner_invoice_id" ref="base.res_partner_address_8"/>
<field name="partner_shipping_id" ref="base.res_partner_address_8"/>
<field name="partner_order_id" ref="base.res_partner_address_8"/>
<field name="order_policy">prepaid</field>
</record>
<record id="line5" model="sale.order.line">
<field name="order_id" ref="order3"/>
@ -120,7 +127,6 @@
<field name="type">make_to_order</field>
<field name="delay">7</field>
</record>
<workflow action="order_confirm" model="sale.order" ref="order3"/>
<!--Resource: sale.order-->
@ -176,6 +182,16 @@
<field name="type">make_to_order</field>
<field name="delay">15</field>
</record>
<record id="line52" model="sale.order.line">
<field name="order_id" ref="order5"/>
<field name="name">[CPU1] Processor AMD Athlon XP 1800+</field>
<field name="product_id" ref="product.product_product_cpu1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">75</field>
<field name="product_uom_qty">3</field>
<field name="product_uos_qty">3</field>
<field name="type">make_to_stock</field>
</record>
<workflow action="order_confirm" model="sale.order" ref="order5"/>
<!--Resource: sale.order-->
@ -228,7 +244,7 @@
<field name="name">[MB1] Mainboard ASUStek A7N8X</field>
<field name="product_id" ref="product.product_product_mb1"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_uom_qty">4</field>
<field name="product_uom_qty">15</field>
<field name="price_unit">250</field>
<field name="type">make_to_order</field>
<field name="delay">15</field>
@ -238,13 +254,12 @@
<field name="name">[MB2] Mainboard ASUStek A7V8X-X</field>
<field name="product_id" ref="product.product_product_mb2"/>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="product_uom_qty">4</field>
<field name="product_uom_qty">5</field>
<field name="price_unit">500</field>
<field name="type">make_to_order</field>
<field name="delay">15</field>
</record>
<workflow action="order_confirm" model="sale.order" ref="order7"/>
<workflow action="manual_invoice" model="sale.order" ref="order7"/>
<!-- Run all schedulers -->
<function model="procurement.order" name="run_scheduler"/>

View File

@ -1,144 +0,0 @@
-
In order to test the Deposit wizard of sale module in the Open-ERP,
I create a Sale Order for LG Viewty Smart for qty 100 having order_policy manual.
-
!record {model: sale.order, id: sale_order_so5}:
invoice_quantity: order
order_line:
- product_uom_qty: 100.0
product_id: sale.product_product_lgviewtysmart0
name: LG View
product_uos_qty: 100.0
type: make_to_order
order_policy: manual
partner_id: sale.res_partner_cleartrail0
picking_policy: direct
-
I use the Advance Payment wizard.
-
!record {model: sale.advance.payment.inv, id: sale_advance_payment_inv_0}:
amount: 1000.0
product_id: product.product_product_pc3
qtty: 3.0
-
Then I click on the "Create Partial Invoice" button
-
!python {model: sale.advance.payment.inv}: |
self.create_invoices(cr, uid, [ref("sale_advance_payment_inv_0")], {"lang": 'en_US',
"active_model": 'sale.order', "active_ids": [ref("sale_order_so5")], "tz":
False, "active_id": ref("sale_order_so5"), })
-
I verify whether the invoice has been generated.
-
!python {model: sale.order}: |
so = self.read(cr, uid, ref("sale_order_so5"))
assert so['invoice_ids'], "Invoices has not been generated for sale_order_so5"
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
I verify that an invoice state has transit from draft to open state
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
assert invoice_id, "Invoice is not in the open state"
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
3000.0, ref('account.cash'), ref('account.period_5'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify that invoice has transit from Open to Paid state
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in paid state."
-
I verify that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so5"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so5}
-
I click on "Create Invoice" button of Sales order to create the invoice.
-
!workflow {model: sale.order, action: manual_invoice, ref: sale_order_so5}
-
I verify whether the invoice has been generated for SO
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so5"))
assert so.invoice_ids[1], "Invoices has not been generated for sale_order_so5"
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
I verify that an invoice state has transit from draft to open state
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
assert invoice_id, "Invoice is not in the open state"
-
I assign an analytic journal to the bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
14000.0, ref('account.cash'), ref('account.period_5'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_5'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify that an invoice is in done state.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so5"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in done state."
-
I verify that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so5"))
assert(sale_id.invoiced == True), "Paid has not been set to true"

View File

@ -1,258 +0,0 @@
-
In order to test the sale module, I need to configure details regarding product,customer and account.
-
I am going to sell my Mobile products to the customer with name Cleartrail
-
I create View Account Type.
-
!record {model: account.account.type, id: account_account_type_view0}:
close_method: none
code: View
name: View
sign: 1
-
I create Income Account Type.
-
!record {model: account.account.type, id: account_account_type_income0}:
close_method: unreconciled
code: Income
name: Income
sign: 1
-
I create Expense Account Type.
-
!record {model: account.account.type, id: account_account_type_expense0}:
close_method: unreconciled
code: Expense
name: Expense
sign: 1
-
I create Cash Account Type.
-
!record {model: account.account.type, id: account_account_type_cash0}:
close_method: balance
code: Cash
name: Cash
sign: 1
-
I create Minimal Chart Account.
-
!record {model: account.account, id: account_account_minimalchart0}:
code: MC
company_id: base.main_company
currency_mode: current
name: Minimal Chart
parent_left: 1
parent_right: 12
type: view
user_type: account_account_type_view0
-
I create Payable Account.
-
!record {model: account.account, id: account_account_payable1}:
code: AP
company_id: base.main_company
currency_mode: current
name: Payable
parent_id: account_account_minimalchart0
parent_left: 2
parent_right: 3
reconcile: true
type: payable
user_type: account_account_type_expense0
-
I create Receivable Account.
-
!record {model: account.account, id: account_account_receivable0}:
code: AR
company_id: base.main_company
currency_mode: current
name: Receivable
parent_id: account_account_minimalchart0
parent_left: 4
parent_right: 5
reconcile: true
type: receivable
user_type: account_account_type_income0
-
I create Cash Account.
-
!record {model: account.account, id: account_account_cash0}:
code: C
company_id: base.main_company
currency_mode: current
name: Cash
parent_id: account_account_minimalchart0
parent_left: 6
parent_right: 7
type: other
user_type: account_account_type_cash0
-
I create Purchases Account.
-
!record {model: account.account, id: account_account_purchases0}:
code: P
company_id: base.main_company
currency_mode: current
name: Purchases
parent_id: account_account_minimalchart0
parent_left: 8
parent_right: 9
type: other
user_type: account_account_type_expense0
-
I create Sales Account.
-
!record {model: account.account, id: account_account_sales0}:
code: S
company_id: base.main_company
currency_mode: current
name: Sales
parent_id: account_account_minimalchart0
parent_left: 10
parent_right: 11
type: other
user_type: account_account_type_income0
-
I create Purchase Journal - (test).
-
!record {model: account.journal, id: account_journal_purchasejournal0}:
code: PUJ
company_id: base.main_company
default_credit_account_id: account_account_purchases0
default_debit_account_id: account_account_purchases0
name: Purchase Journal - (test)
type: purchase
view_id: account.account_journal_view
-
I create Sale Journal.
-
!record {model: account.journal, id: account_journal_salejournal0}:
code: SJ
company_id: base.main_company
default_credit_account_id: account_account_sales0
default_debit_account_id: account_account_sales0
name: Sale Journal
type: sale
view_id: account.account_journal_view
-
I create Bank Journal.
-
!record {model: account.journal, id: account_journal_bankjournal0}:
code: BNK
company_id: base.main_company
default_credit_account_id: account_account_cash0
default_debit_account_id: account_account_cash0
name: Bank Journal
type: cash
view_id: account.account_journal_bank_view
-
I create ir.property for account payable.
-
!record {model: ir.property, id: ir_property_propertyaccountexpensecateg0}:
company_id: base.main_company
fields_id: account.field_res_partner_property_account_payable
name: property_account_expense_categ
value_reference: account.account,5
-
I create ir.property for account receivable.
-
!record {model: ir.property, id: ir_property_propertyaccountincomecateg0}:
company_id: base.main_company
fields_id: account.field_res_partner_property_account_receivable
name: property_account_income_categ
value_reference: account.account,6
-
I create Partner category Customers.
-
!record {model: res.partner.category, id: res_partner_category_customers0}:
name: Customers
-
I create Cleartrail Customer.
-
!record {model: res.partner, id: res_partner_cleartrail0}:
category_id:
- res_partner_category_customers0
name: Cleartrail
opt_out: True
-
I create contact address for Cleartrail.
-
!record {model: res.partner.address, id: res_partner_address_1}:
partner_id: res_partner_cleartrail0
street: onam plaza, 14 B palasia A B Road
type: contact
-
I create invoice address for Cleartrail.
-
!record {model: res.partner.address, id: res_partner_address_2}:
partner_id: res_partner_cleartrail0
street: sarda house 24 B palasia, A B Road
type: invoice
-
I create delivery address for Cleartrail.
-
!record {model: res.partner.address, id: res_partner_address_3}:
partner_id: res_partner_cleartrail0
street: sangam house 15 B palasia, A B Road
type: delivery
-
Customer Cleartrail has specific instrument requirement regarding the stockable products.
-
I define product category Mobile Products Sellable.
-
!record {model: product.category, id: product_category_allproductssellable0}:
name: Mobile Products Sellable
-
I define product category Mobile Services.
-
!record {model: product.category, id: product_category_services0}:
name: Mobile Services
-
I define LG Viewty Smart product.
-
!record {model: product.product, id: product_product_lgviewtysmart0}:
categ_id: product_category_allproductssellable0
cost_method: standard
list_price: 170.0
mes_type: fixed
name: LG Viewty Smart
procure_method: make_to_order
property_account_expense: sale.account_account_payable1
property_account_income: sale.account_account_receivable0
seller_delay: '1'
seller_ids:
- delay: 1
name: base.res_partner_agrolait
min_qty: 2.0
qty: 5.0
standard_price: 160.0
supply_method: produce
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
I define Slider Mobile.
-
!record {model: product.product, id: product_product_slidermobile0}:
categ_id: product_category_allproductssellable0
cost_method: standard
list_price: 200
mes_type: fixed
name: Slider Mobile
procure_method: make_to_order
property_account_expense: sale.account_account_payable1
property_account_income: sale.account_account_receivable0
seller_delay: '1'
seller_ids:
- delay: 1
name: base.res_partner_agrolait
min_qty: 2.0
qty: 5.0
standard_price: 189.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit

View File

@ -1,110 +0,0 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for 500 quantity having Shipping Policy 'Shipping & Manual Invoice' and Invoice on 'Ordered quantities'
in order to create an invoice based on the ordered quantity
-
!record {model: sale.order, id: sale_order_so9}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO006
order_line:
- name: Slider Mobile
price_unit: 200
product_uom: product.product_uom_unit
product_uom_qty: 200.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 200.0
type: make_to_order
order_policy: manual
invoice_quantity: order
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so9}
-
I verify that the picking has been generated for the sale order and I process it
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so9"))
assert so.picking_ids,"Picking has not been generated for sale_order_so9"
picking, = so.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I click on Create Invoice button to create the invoice.
-
!workflow {model: sale.order, action: manual_invoice, ref: sale_order_so9}
-
I verify whether the invoice has been generated for SO
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so9"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so9"
-
I verify that an invoice is created on the basis of ordered quantity
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
for so_lines in so.order_line:
qty = so_lines.product_uom_qty
ids = self.search(cr, uid, [('origin','=',so.name)])
inv_brw = self.browse(cr,uid,ids)[0]
for inv_lines in inv_brw.invoice_line:
qty1 = inv_lines.quantity
assert qty1==qty, "Quantities are not same"
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
40000.0, ref('account.cash'), ref('account.period_9'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify the invoice are in paid state or not.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert invoice.state =='paid', "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so9"))
assert sale_id.invoiced == True, "Paid has not been set to true"

View File

@ -1,124 +0,0 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for 200 quantity having Shipping Policy 'Invoice from Picking' and Invoice on 'Shipped quantities'
-
!record {model: sale.order, id: sale_order_so6}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO006BIS
order_line:
- name: Slider Mobile
price_unit: 200
product_uom: product.product_uom_unit
product_uom_qty: 200.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 200.0
type: make_to_order
order_policy: picking
invoice_quantity: procurement
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so6}
-
I verify that the picking has been generated for the sale order and I process it
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so6"))
assert so.picking_ids,"Picking has not been generated for sale_order_so6"
picking, = so.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
# I change the qty to 100 for a partial delivery
partial = stock_partial_picking.browse(cr,uid,partial_id)
line_id = partial.move_ids[0].id
partial.write({'move_ids': [(1,line_id,{'quantity':100})]})
partial.do_partial()
-
Then I click on 'Create Invoices' button
-
!python {model: stock.invoice.onshipping}: |
import time
sale_obj = self.pool.get('sale.order')
sale_id = sale_obj.browse(cr, uid, ref("sale_order_so6"))
ids = [x.id for x in sale_id.picking_ids if x.state == 'done']
wiz_id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.sales_journal')},
{'active_ids': ids, 'active_model': 'stock.picking'})
self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids, "active_id": ids[0]})
-
I verify whether the invoice has been generated for SO
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so6"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so6"
-
I verify that an invoice is created on the basis of shipped quantities 100 not ordered quantities 200
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('origin', '=', so.name),('type','=','out'),('state','=','done')])
qty = qty1 = 0.0
for pick_brw in picking_obj.browse(cr,uid, ids):
for lines in pick_brw.move_lines:
qty=lines.product_qty
inv_id = self.search(cr, uid, [('origin', 'like', so.name)])
inv_brw = self.browse(cr,uid,inv_id)[0]
for inv_lines in inv_brw.invoice_line:
qty1=inv_lines.quantity
assert (qty1 == qty), "Quantities are not the same: invoiced: %s, shipped: %s" % (qty1,qty)
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
invoice_id = self.search(cr, uid, [('origin','like',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
40000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify the invoice are in paid state or not.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert invoice.state=='paid', "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so6"))
assert sale_id.invoiced == True, "Paid has not been set to true"

View File

@ -1,261 +1,89 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for 500 quantity having Shipping Policy 'Shipping & Manual Invoice'
I confirm the Quotation with "Deliver & invoice on demand".
-
!record {model: sale.order, id: sale_order_so0}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO002
order_line:
- name: Slider Mobile
price_unit: 200
product_uom: product.product_uom_unit
product_uom_qty: 500.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 500.0
type: make_to_order
order_policy: manual
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
!workflow {model: sale.order, action: order_confirm, ref: order4}
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
-
I click on Create Invoice button to create the invoice.
-
!workflow {model: sale.order, action: manual_invoice, ref: sale_order_so0}
-
I verify whether the invoice has been generated for SO
I check that Invoice should not created.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so0"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so0"
sale_order = self.browse(cr, uid, ref("order4"))
assert len(sale_order.invoice_ids) == False, "Invoice should not created."
assert sale_order.picking_ids, "Delivery order should be created."
-
I open the Invoice for the SO.
I create advance invoice.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
!python {model: sale.advance.payment.inv}: |
ctx = context.copy()
ctx.update({"active_model": 'sale.order', "active_ids": [ref("order4")], "active_id":ref("order4")})
order_line = self.pool.get('sale.order.line').browse(cr, uid, ref("line7"), context=context)
pay_id = self.create(cr, uid, {'product_id': order_line.product_id.id, 'amount': order_line.price_subtotal, 'qtty': order_line.product_uom_qty})
self.create_invoices(cr, uid, [pay_id], context=ctx)
-
I check Invoice which made advance
-
!python {model: sale.order}: |
order = self.browse(cr, uid, ref('order4'))
assert order.invoice_ids, "Invoice should be created after make advance invoice."
-
I create Invoice from sale order line.
-
!python {model: sale.order.line.make.invoice}: |
ctx = context.copy()
ctx.update({"active_model": 'sale.order.line', "active_ids": [ref("line8")], "active_id":ref("line8")})
self.make_invoices(cr, uid, [], context=ctx)
-
I check Invoice which made from sale order line.
-
!python {model: sale.order.line}: |
line = self.browse(cr, uid, ref('line8'))
assert line.invoiced, "Line is not invoiced."
assert line.invoice_lines, "Invoice line should be created."
-
I create manual Invoice for order.
-
!record {model: sale.make.invoice, id: sale_make_invoice_1}:
invoice_date: !eval time.strftime('%Y-%m-%d')
-
!python {model: sale.make.invoice}: |
ctx = context.copy()
ctx = ctx.update({"active_model": 'sale.order', "active_ids": [ref("order4")], "active_id":ref("order4")})
self.make_invoices(cr, uid, [ref("sale_make_invoice_1")], context)
-
I open the Invoice.
-
!python {model: sale.order}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
I verify that an invoice state has transit from draft to open state
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
assert invoice_id, "Invoice is not in the open state"
-
I verify that its Journal Entries has been created
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
inv_brw = self.browse(cr, uid, invoice_id)[0]
assert inv_brw.move_id, "Journal Entries has not been created"
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
so = self.browse(cr, uid, ref("order4"))
for invoice in so.invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
100000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
sale_order = self.pool.get('sale.order')
order = sale_order.browse(cr, uid, ref("order4"))
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', order.company_id.id)], limit=1)
for invoice in order.invoice_ids:
invoice.pay_and_reconcile(
invoice.amount_total, ref('account.cash'), ref('account.period_8'),
journal_ids[0], ref('account.cash'),
ref('account.period_8'), journal_ids[0],
name='test')
-
I verify the invoice is in done state.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in done state."
-
I verify that Paid has been set to true.
I check Invoice after do manual.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so0"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
sale_order = self.browse(cr, uid, ref("order4"))
assert sale_order.invoice_ids, "Invoice should be created."
assert sale_order.invoiced, "Order is not invoiced."
assert sale_order.state == 'manual', 'Order should be in Manual.'
-
I verify that the picking has been generated for the sale order
I set order policy "Deliver & invoice on demand" as default policy.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so0"))
assert so.picking_ids,"Picking has not been generated for sale_order_so0"
!record {model: sale.config.picking_policy, id: sale.config.picking_policy_0}:
order_policy: 'manual'
-
I verify that delivery order has been generated for sale order
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
picking_id = self.search(cr, uid, [('origin','=',so.name)])
assert(picking_id),"Delivery order has not been generated"
-
I verify that a procurement has been generated for so
-
!python {model: procurement.order}: |
from tools.translate import _
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
assert(proc_ids),"No Procurements!"
-
Then I click on the "Run Procurement" button
-
!python {model: procurement.order}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
import netsvc
wf_service = netsvc.LocalService("workflow")
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
for proc in proc_ids:
wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
-
I verify that a procurement state is "running"
-
!python {model: procurement.order}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','in',['running','ready'])])
# should be running is 'purchase' is installed, else 'ready'
assert(proc_ids),"Procurement is not in running/ready state!"
-
I verify that a purchase order has been generated
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if(mod_brw.state == 'installed'):
so = self.browse(cr, uid, ref("sale_order_so0"))
pur_obj=self.pool.get('purchase.order')
pur_id=pur_obj.search(cr, uid, [('origin','=',so.name)])
assert(pur_id),"Purchase order has not been generated"
-
I click on the "Confirm" button to confirm the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if(mod_brw.state == 'installed'):
pur_obj=self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so0"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_confirm', cr)
-
I click on the "Approved by supplier" button to approve the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so0"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr)
-
I verify that a picking related to purchase order has been generated and I process it
-
!python {model: sale.order}: |
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so0"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
assert(po.picking_ids),"Picking for purchase order has not been generated"
picking, = po.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that picking for purchase order has been done.
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if(mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so0"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')])
assert(ids),"Picking is not in the done state!"
-
Then I process the picking
-
!python {model: stock.picking }: |
import time
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
if picking_id:
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that picking for sale order is in done state.
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
pick = self.browse(cr,uid,picking_id[0])
assert (pick.state) =='done', "Picking for SO is not in done state."
-
I verify that a "Picked" has been set to true
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so0"))
assert (so.shipped == True), "Picked has not been set to True"
-
I verify that a sale order is in done state
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so0"))
assert (so.state == 'done'), "Sale order is not in the done state."
!python {model: sale.config.picking_policy}: |
self.execute(cr, uid, [ref("sale.config.picking_policy_0")])

View File

@ -1,264 +1,171 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for qty 500 having Shipping Policy is 'Invoice from Picking'
In order to test process of the Sale Order,
-
!record {model: sale.order, id: sale_order_so7}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO007
order_line:
- name: Slider Mobile
price_unit: 200
product_uom: product.product_uom_unit
product_uom_qty: 500.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 500.0
th_weight: 0.0
type: make_to_order
order_policy: picking
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
First I check the total amount of the Quotation before Approved.
-
I confirm the sale order.
!assert {model: sale.order, id: order, string: The amount of the Quotation is not correctly computed}:
- sum([l.price_subtotal for l in order_line]) == amount_untaxed
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so7}
I confirm the quotation with "Invoice based on deliveries" policy.
-
I verify that picking has been generated for the sale order.
!workflow {model: sale.order, action: order_confirm, ref: order}
-
I check that invoice should not created before dispatch delivery.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so7"))
assert so.picking_ids,"Picking has not been generated for sale_order_so7"
order = self.pool.get('sale.order').browse(cr, uid, ref("order"))
assert order.state == 'progress', 'Order should be in inprogress.'
assert len(order.invoice_ids) == False, "Invoice should not created."
-
Then I done the picking
I check the details of procurement after confirmed quotation.
-
!python {model: stock.picking }: |
import time
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
if picking_id:
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
!python {model: sale.order}: |
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
order = self.browse(cr, uid, ref("order"))
for order_line in order.order_line:
procurement = order_line.procurement_id
date_planned = datetime.strptime(order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=order_line.delay or 0.0)
date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
assert procurement.date_planned == date_planned, "Scheduled date is not correspond."
assert procurement.product_id.id == order_line.product_id.id, "Product is not correspond."
assert procurement.product_qty == order_line.product_uom_qty, "Qty is not correspond."
assert procurement.product_uom.id == order_line.product_uom.id, "UOM is not correspond."
assert procurement.procure_method == order_line.type, "Procurement method is not correspond."
-
Then I click on 'Create Invoices' button
I run the scheduler.
-
!python {model: procurement.order}: |
self.run_scheduler(cr, uid)
-
I check the details of delivery order after confirmed quotation.
-
!python {model: sale.order}: |
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
sale_order = self.browse(cr, uid, ref("order"))
assert sale_order.picking_ids, "Delivery order is not created."
for picking in sale_order.picking_ids:
assert picking.state == "auto" or "confirmed", "Delivery order should be in 'Waitting Availability' state."
assert picking.origin == sale_order.name,"Origin of Delivery order is not correspond with sequence number of sale order."
assert picking.type == 'out',"Shipment should be Outgoing."
assert picking.move_type == sale_order.picking_policy,"Delivery Method is not corresponding with delivery method of sale order."
assert picking.address_id.id == sale_order.partner_shipping_id.id,"Shipping Address is not correspond with sale order."
assert picking.note == sale_order.note,"Note is not correspond with sale order."
assert picking.invoice_state == (sale_order.order_policy=='picking' and '2binvoiced') or 'none',"Invoice policy is not correspond with sale order."
assert len(picking.move_lines) == len(sale_order.order_line), "Total move of delivery order are not corresposning with total sale order lines."
location_id = sale_order.shop_id.warehouse_id.lot_stock_id.id
output_id = sale_order.shop_id.warehouse_id.lot_output_id.id
for move in picking.move_lines:
order_line = move.sale_line_id
date_planned = datetime.strptime(sale_order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=order_line.delay or 0.0)
date_planned = (date_planned - timedelta(days=sale_order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
assert datetime.strptime(move.date_expected, DEFAULT_SERVER_DATETIME_FORMAT) == datetime.strptime(date_planned, DEFAULT_SERVER_DATETIME_FORMAT), "Excepted Date is not correspond with Planned Date."
assert move.product_id.id == order_line.product_id.id,"Product is not correspond."
assert move.product_qty == order_line.product_uom_qty,"Product Quantity is not correspond."
assert move.product_uom.id == order_line.product_uom.id,"Product UOM is not correspond."
assert move.product_uos_qty == (order_line.product_uos and order_line.product_uos_qty) or order_line.product_uom_qty,"Product UOS Quantity is not correspond."
assert move.product_uos == (order_line.product_uos and order_line.product_uos.id) or order_line.product_uom.id,"Product UOS is not correspond"
assert move.product_packaging.id == order_line.product_packaging.id,"Product packaging is not correspond."
assert move.address_id.id == order_line.address_allotment_id.id or sale_order.partner_shipping_id.id,"Address is not correspond"
#assert move.location_id.id == location_id,"Source Location is not correspond."
#assert move.location_dest_id == output_id,"Destination Location is not correspond."
assert move.note == order_line.notes,"Note is not correspond"
assert move.price_unit == order_line.product_id.standard_price or 0.0,"Price Unit is not correspond"
-
Now, I dispatch delivery order.
-
!python {model: stock.partial.picking}: |
order = self.pool.get('sale.order').browse(cr, uid, ref("order"))
for pick in order.picking_ids:
data = pick.force_assign()
if data == True:
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
self.do_partial(cr, uid, [partial_id])
-
I check sale order to verify shipment.
-
!python {model: sale.order}: |
order = self.pool.get('sale.order').browse(cr, uid, ref("order"))
assert order.shipped == True, "Sale order is not Delivered."
assert order.picked_rate == 100, "Shipment progress is not 100%."
#assert order.state == 'progress', 'Order should be in inprogress.'
assert len(order.invoice_ids) == False, "Invoice should not created on dispatch delivery order."
-
I create Invoice from Delivery Order.
-
!python {model: stock.invoice.onshipping}: |
import time
sale_obj=self.pool.get('sale.order')
sale_id=sale_obj.browse(cr, uid, ref("sale_order_so7"))
ids = [x.id for x in sale_id.picking_ids]
wiz_id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.sales_journal')},
{'active_ids': ids, 'active_model': 'stock.picking'})
self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids, "active_id": ids[0]})
sale = self.pool.get('sale.order')
sale_order = sale.browse(cr, uid, ref("order"))
ship_ids = [x.id for x in sale_order.picking_ids]
wiz_id = self.create(cr, uid, {'journal_id': ref('account.sales_journal')},
{'active_ids': ship_ids, 'active_model': 'stock.picking'})
self.create_invoice(cr, uid, [wiz_id], {"active_ids": ship_ids, "active_id": ship_ids[0]})
-
I check that an invoice has been created.
I check the invoice details after dispatched delivery.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so7"))
assert(sale_id.invoice_ids), "Invoice has not been created"
order = self.browse(cr, uid, ref("order"))
assert order.invoice_ids, "Invoice is not created."
ac = order.partner_id.property_account_receivable.id
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale'), ('company_id', '=', order.company_id.id)], limit=1)
for invoice in order.invoice_ids:
assert invoice.type == 'out_invoice',"Invoice should be Customer Invoice."
assert invoice.account_id.id == ac,"Invoice account is not correspond."
assert invoice.reference == order.client_order_ref or order.name,"Reference is not correspond."
assert invoice.partner_id.id == order.partner_id.id,"Customer is not correspond."
assert invoice.address_invoice_id.id == order.partner_invoice_id.id,"Invoice Address is not correspond."
assert invoice.currency_id.id == order.pricelist_id.currency_id.id, "Currency is not correspond."
assert invoice.comment == order.note or '',"Note is not correspond."
assert invoice.journal_id.id == journal_ids[0],"Sales Journal is not link on Invoice."
assert invoice.payment_term.id == order.payment_term.id, "Payment term is not correspond."
for so_line in order.order_line:
inv_line = so_line.invoice_lines[0]
ac = so_line.product_id.product_tmpl_id.property_account_income.id or so_line.product_id.categ_id.property_account_income_categ.id
assert inv_line.product_id.id == so_line.product_id.id or False,"Product is not correspond"
assert inv_line.account_id.id == ac,"Account of Invoice line is not corresponding."
assert inv_line.uos_id.id == (so_line.product_uos and so_line.product_uos.id) or so_line.product_uom.id, "Product UOS is not correspond."
assert inv_line.price_unit == so_line.price_unit , "Price Unit is not correspond."
assert inv_line.quantity == (so_line.product_uos and so_line.product_uos_qty) or so_line.product_uom_qty , "Product qty is not correspond."
assert inv_line.price_subtotal == so_line.price_subtotal, "Price sub total is not correspond."
-
I open the Invoice for the SO.
I open the Invoice.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
!python {model: sale.order}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
so = self.browse(cr, uid, ref("order"))
for invoice in so.invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
invoice_id = self.search(cr, uid, [('origin','like',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
255000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
sale_order = self.pool.get('sale.order')
order = sale_order.browse(cr, uid, ref("order"))
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', order.company_id.id)], limit=1)
for invoice in order.invoice_ids:
invoice.pay_and_reconcile(
invoice.amount_total, ref('account.cash'), ref('account.period_8'),
journal_ids[0], ref('account.cash'),
ref('account.period_8'), journal_ids[0],
name='test')
-
I verify the invoice is in paid state.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert (invoice.state) =='paid', "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
I check the order after paid invoice.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so7"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
order = self.browse(cr, uid, ref("order"))
assert order.invoiced == True, "Sale order is not invoiced."
assert order.invoiced_rate == 100, "Invoiced progress is not 100%."
assert order.state == 'done', 'Order should be in closed.'
-
I verify that a procurement has been generated for so
-
!python {model: procurement.order}: |
from tools.translate import _
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
assert proc_ids, _('No Procurements!')
-
Then I click on the "Run Procurement" button
-
!python {model: procurement.order}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
import netsvc
wf_service = netsvc.LocalService("workflow")
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
for proc in proc_ids:
wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
-
I verify that a procurement state is "running"
-
!python {model: procurement.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','=','running')])
assert proc_ids, _('Procurement is not in the running state!')
-
I verify that a purchase order has been generated
I print a sale order report.
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
so = self.browse(cr, uid, ref("sale_order_so7"))
pur_obj=self.pool.get('purchase.order')
pur_id=pur_obj.search(cr, uid, [('origin','=',so.name)])
assert pur_id, _('Purchase order has not been generated')
-
I click on the "Confirm" button to confirm the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj=self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so7"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_confirm', cr)
-
I click on the "Approved by supplier" button to approve the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so7"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr)
-
I verify that a picking related to purchase order has been generated and I process it
-
!python {model: sale.order}: |
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so7"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
assert(po.picking_ids),"Picking for purchase order has not been generated"
picking, = po.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that picking for purchase order has been done.
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so7"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')])
assert ids, _('Picking is not in the done state!')
-
I verify that delivery order has been generated for sale order, and process it
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
picking_id = self.search(cr, uid, [('origin','=',so.name)])
assert (picking_id),"Delivery order has not been generated"
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that delivery state is done
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so7"))
picking_id = self.search(cr, uid, [('origin','=',so.name)])
if picking_id:
pick = self.browse(cr,uid,picking_id[0])
assert (pick.state) =='done', "Picking for SO is not in done state."
-
I verify that the sale order is marked as delivered
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so7"))
assert (so.shipped == True), "Picked has not been set to True"
-
I verify that a sale order is in done state
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so7"))
assert (so.state == 'done'), "Sale order is not in the done state."
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.sale.order').create(cr, uid, [ref('order')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'sale-sale_order.'+format), 'wb+').write(data)

View File

@ -1,274 +1,54 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for qty 500 having Shipping Policy is 'Invoice on order after Delivery'
Now I confirm the Quotation with "Invoice on order after delivery" policy.
-
!record {model: sale.order, id: sale_order_so8}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO008
order_line:
- name: Slider Mobile
price_unit: 200.0
product_uom: product.product_uom_unit
product_uom_qty: 500.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 500.0
type: make_to_order
order_policy: postpaid
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
!workflow {model: sale.order, action: order_confirm, ref: order2}
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so8}
-
I verify that the picking has been generated for the sale order
I check that related delivery order after confirmed.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so8"))
assert so.picking_ids,"Picking has not been generated for sale_order_so8"
sale_order = self.browse(cr, uid, ref("order2"))
assert sale_order.picking_ids, "Delivery Order should be created."
assert len(sale_order.invoice_ids) == False, "Invoice should be not created."
-
Then I done the picking
Now, I dispatch delivery order.
-
!python {model: stock.picking }: |
import time
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
if picking_id:
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
!python {model: stock.partial.picking}: |
order = self.pool.get('sale.order').browse(cr, uid, ref("order2"))
for pick in order.picking_ids:
data = pick.force_assign()
if data == True:
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
self.do_partial(cr, uid, [partial_id])
-
I verify that picking order is in done state.
I open the invoice.
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
if picking_id:
pick = self.browse(cr,uid,picking_id[0])
assert (pick.state == 'done'), "Picking for SO is not in done state."
-
I verify that delivery order has been generated for sale order
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
picking_id = self.search(cr, uid, [('origin','=',so.name)])
assert (picking_id),"Delivery order has not been generated"
-
I process the delivery order
-
!python {model: stock.picking }: |
import time
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
picking_id = self.search(cr, uid, [('origin','=',so.name)])
if picking_id:
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that delivery order is marked done
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
picking_id = self.search(cr, uid, [('origin','=',so.name)])
if picking_id:
pick = self.browse(cr,uid,picking_id[0])
assert (pick.state) =='done', "Picking for SO is not in done state."
-
I verify that a procurement has been generated for so
-
!python {model: procurement.order}: |
from tools.translate import _
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
assert proc_ids, _('No Procurements!')
-
Then I click on the "Run Procurement" button
-
!python {model: procurement.order}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
!python {model: sale.order}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
for proc in proc_ids:
wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
so = self.browse(cr, uid, ref("order2"))
for invoice in so.invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
-
I verify that a procurement state is "running"
-
!python {model: procurement.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','=','running')])
assert proc_ids, _('Procurement is not in the running state!')
-
I verify that a purchase order has been generated
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
so = self.browse(cr, uid, ref("sale_order_so8"))
pur_obj=self.pool.get('purchase.order')
pur_id=pur_obj.search(cr, uid, [('origin','=',so.name)])
assert pur_id, _('Purchase order has not been generated')
-
I click on the "Confirm" button to confirm the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj=self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so8"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_confirm', cr)
-
I click on the "Approved by supplier" button to approve the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so8"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr)
-
I verify that a picking related to purchase order has been generated and I process it
-
!python {model: sale.order}: |
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so8"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
assert(po.picking_ids),"Picking for purchase order has not been generated"
picking, = po.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that picking for purchase order has been marked done.
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so8"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')])
assert ids, _('Picking is not in the done state!')
-
I verify that the sale order is marked as delivered
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so8"))
assert (so.shipped == True), "Picking is not done."
-
I verify that an invoice has been generated for SO
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so8"))
assert so.invoice_ids, "Invoice has not been generated"
-
I open the Invoice for the SO.
I pay the invoice.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
sale_order = self.pool.get('sale.order')
order = sale_order.browse(cr, uid, ref("order2"))
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', order.company_id.id)], limit=1)
for invoice in order.invoice_ids:
invoice.pay_and_reconcile(
invoice.amount_total, ref('account.cash'), ref('account.period_8'),
journal_ids[0], ref('account.cash'),
ref('account.period_8'), journal_ids[0],
name='test')
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
100000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify the invoice are in paid state or not.
-
!python {model: account.invoice}: |
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so8"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert (invoice.state) =='paid', "Invoice for SO is not in done state."
-
I verify that Paid has been set to true.
I check that an order has been invoiced, shipped and closed.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so8"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
-
I verify that sale order is in done state
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so8"))
assert (so.state == 'done'), "Sale order is not in the done state."
order = self.browse(cr, uid, ref("order2"))
assert order.picked_rate == 100, "Shipment progress is not 100%."
assert order.shipped, "Delivery Order should be dispatch."
assert order.invoiced == True, "Sale order is not invoiced."
assert order.invoiced_rate == 100, "Invoiced progress is not 100%."
assert order.state == 'done', 'Order should be in closed.'
assert order.invoice_ids, "Invoice should be created after dispatch delivery order."

View File

@ -1,229 +1,11 @@
-
I create a Sale Order for LG Viewty Smart for qty 500 having Shipping Policy is 'Payment Before Delivery'
Now I confirm the Quotation with "Pay before delivery" policy.
-
!record {model: sale.order, id: sale_order_so1}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO001
order_line:
- name: Slider Mobile
price_unit: 200
product_uom: product.product_uom_unit
product_uom_qty: 500.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 500.0
th_weight: 0.0
type: make_to_order
order_policy: prepaid
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
!workflow {model: sale.order, action: order_confirm, ref: order3}
-
I confirm the sale order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so1}
-
I verify whether the invoice has been generated for SO since Shipping policy is 'Payment Before Delivery'
I check that delivery order should not created before invoice is paid.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so1"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so1"
-
I verify there are no pickings attached to this sale order
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
assert not picking_id,"As the order policy is prepaid, the sale order shouldn't have already a picking."
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
I assign an analytic journal to the Bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
85000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_5'), ref('sale.account_journal_bankjournal0'),
name='test002')
-
I verify the invoice is in done state or not.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so1"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
-
I verify the picking associated with the sale order sale_order_so1
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so1"))
assert so.picking_ids,"Picking has not been generated"
-
Products are delivered to the Cleartrail Customer.
-
!python {model: stock.picking }: |
import time
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
if picking_id:
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [pick.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
-
I verify that picking order is in done state.
-
!python {model: stock.picking }: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
pick = self.browse(cr,uid,picking_id[0])
assert (pick.state) =='done', "Picking for SO is not in done state."
-
I verify that a procurement has been generated for so
-
!python {model: procurement.order}: |
from tools.translate import _
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
assert proc_ids, _('No Procurements!')
-
Then I click on the "Run Procurement" button
-
!python {model: procurement.order}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
import netsvc
wf_service = netsvc.LocalService("workflow")
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
for proc in proc_ids:
wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
-
I verify that a procurement state is "running"
-
!python {model: procurement.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if(mod_brw.state == 'installed'):
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so1"))
proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','=','running')])
assert proc_ids, _('Procurement is not in the running state!')
-
I verify that a purchase order has been generated
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if(mod_brw.state == 'installed'):
so = self.browse(cr, uid, ref("sale_order_so1"))
pur_obj=self.pool.get('purchase.order')
pur_id=pur_obj.search(cr, uid, [('origin','=',so.name)])
assert pur_id, _('Purchase order has not been generated')
-
I click on the "Confirm" button to confirm the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if(mod_brw.state == 'installed'):
pur_obj=self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so1"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_confirm', cr)
-
I click on the "Approved by supplier" button to approve the purchase order
-
!python {model: sale.order}: |
from tools.translate import _
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so1"))
import netsvc
wf_service = netsvc.LocalService("workflow")
pur_ids = pur_obj.search(cr, uid, [('origin','=',so.name)])
for pur in pur_ids:
wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr)
-
I verify that a picking related to purchase order has been generated and I process it
-
!python {model: sale.order}: |
modules = self.pool.get('ir.module.module')
mod_pur = modules.search(cr, uid, [('name','=','purchase')])
mod_brw = modules.browse(cr,uid,mod_pur)[0]
if (mod_brw.state == 'installed'):
pur_obj = self.pool.get('purchase.order')
so = self.browse(cr, uid, ref("sale_order_so1"))
pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)])
po = pur_obj.browse(cr, uid, pur_id)[0]
assert(po.picking_ids),"Picking for purchase order has not been generated"
picking, = po.picking_ids
stock_partial_picking = self.pool.get('stock.partial.picking')
partial_id = stock_partial_picking.create(cr, uid, {},
context={'active_model': 'stock.picking',
'active_ids': [picking.id]})
stock_partial_picking.do_partial(cr, uid, [partial_id])
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id),('state', '=', 'done')])
assert ids, 'Picking should be marked done!'
-
I verify that the sale order is marked as delivered
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so1"))
assert (so.shipped == True), "Sale order is not marked as delivered"
-
I verify that a sale order is in done state
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so1"))
assert (so.state == 'done'), "Sale order is not in the done state."
sale_order = self.browse(cr, uid, ref("order3"))
assert len(sale_order.picking_ids) == False, "Delivery order should not created before invoice."
assert sale_order.invoice_ids, "Invoice should be created."

View File

@ -0,0 +1,13 @@
-
In order to test process of the Sale Order, I create sale order
-
!record {model: sale.order, id: order}:
partner_id: base.res_partner_agrolait
note: Invoice after delivery
payment_term: account.account_payment_term
-
!record {model: sale.order.line, id: line}:
product_id: product.product_product_mb1
price_unit: 190.50
product_uom_qty: 8

View File

@ -1,92 +0,0 @@
-
In order to test the sale order working with procurements I will create some
products with different supply method and procurement method.
-
I create one product Table as MTO.
-
!record {model: product.product, id: product_product_table0}:
categ_id: product.cat1
name: Table
procure_method: make_to_order
supply_method: produce
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
I create another product Wood as MTS.
-
!record {model: product.product, id: product_product_wood0}:
categ_id: product.cat1
name: Wood
procure_method: make_to_stock
supply_method: buy
type: product
uom_id: product.product_uom_kgm
uom_po_id: product.product_uom_kgm
-
I define Minimum stock rule for my stockable product Wood (qty between 10 and 15)
-
!record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}:
company_id: base.main_company
location_id: stock.stock_location_stock
logic: max
product_id: product_product_wood0
product_max_qty: 15.0
product_min_qty: 10.0
product_uom: product.product_uom_kgm
qty_multiple: 1
warehouse_id: stock.warehouse0
-
Now I make a sale order for table.
-
!record {model: sale.order, id: sale_order_so3}:
amount_total: 5.0
amount_untaxed: 5.0
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
order_line:
- company_id: base.main_company
delay: 7.0
name: Table
price_unit: 1.0
product_id: product_product_table0
product_uom: product.product_uom_unit
product_uom_qty: 5.0
product_uos_qty: 5.0
state: draft
type: make_to_order
order_policy: manual
partner_id: base.res_partner_agrolait
partner_invoice_id: base.res_partner_address_8
partner_order_id: base.res_partner_address_8
partner_shipping_id: base.res_partner_address_8
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so3}
-
I check that procurement is generated.
-
!python {model: procurement.order}: |
from tools.translate import _
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
proc_ids = self.search(cr, uid, [('origin','=',so.name)])
assert proc_ids, _('No Procurements!')
-
I run the scheduler.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[('state','=','confirmed')]"
-
I check that the procurement for the product table is in exception state.
As my product's supply method is produce and the BoM is not defined.
-
!python {model: procurement.order}: |
from tools.translate import _
proc_ids = self.search(cr, uid, [('state','=','exception'),('product_id','=',ref('sale.product_product_table0'))])
assert not proc_ids, _('There is no procurement in exception state!')

View File

@ -1,8 +0,0 @@
-
In order to test the PDF reports defined on a sale order, we will print a sale order
-
!python {model: sale.order}: |
import netsvc, tools, os
(data, format) = netsvc.LocalService('report.sale.order').create(cr, uid, [ref('sale.order'),ref('sale.order2')], {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'sale-sale_order.'+format), 'wb+').write(data)

View File

@ -1,142 +0,0 @@
-
In order to test the 'Make Invoices' wizard of sale module in the Open-ERP,
I create two Sale order,group them and create invoice.
-
I create a Sale Order for Slider Mobile for qty 100 having order_policy manual.
-
!record {model: sale.order, id: sale_order_so3}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO003
order_line:
- name: Slider Mobile
price_unit: 200.0
product_uom: product.product_uom_unit
product_uom_qty: 100.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 100.0
type: make_to_order
order_policy: manual
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so3}
-
I create a Sale Order for products Slider Mobile and LG Viewty Smart for qty 100 having order_policy manual.
-
!record {model: sale.order, id: sale_order_so4}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO004
order_line:
- name: Slider Mobile
price_unit: 200.0
product_uom: product.product_uom_unit
product_uom_qty: 100.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 100.0
type: make_to_order
- name: LG Viewty Smart
price_unit: 170.0
product_uom: product.product_uom_unit
product_uom_qty: 100.0
state: draft
delay: 7.0
product_id: sale.product_product_lgviewtysmart0
product_uos_qty: 100.0
th_weight: 0.0
type: make_to_order
order_policy: manual
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so4}
-
Then I click on the "Make Invoices" button
-
!record {model: sale.make.invoice, id: sale_make_invoice_1}:
grouped: 1
invoice_date: !eval time.strftime('%Y-%m-%d')
-
Then I click on the "Create Invoices" button of wizard
-
!python {model: sale.make.invoice}: |
self.make_invoices(cr, uid, [ref("sale_make_invoice_1")], {"lang": 'en_US', "search_default_user_id":
1, "tz": False, "active_model": 'sale.order', "active_ids": [ref("sale_order_so4"),ref("sale_order_so3")], "active_id":
ref("sale_order_so4")})
-
I verify that an invoice has been created
-
!python {model: account.invoice}: |
inv = self.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
assert inv, "Invoices has not been generated"
-
I verify that an account invoice line with origin 'Test_SO004' is created
-
!python {model: account.invoice.line}: |
sale_order_obj = self.pool.get('sale.order')
acc_inv_obj = self.pool.get('account.invoice')
inv = acc_inv_obj.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
so = sale_order_obj.browse(cr, uid, ref("sale_order_so4"))
inv_line = self.search(cr, uid, [('origin','=',so.name),('name','=','Slider Mobile'),('invoice_id','=',inv)])
assert inv_line, "Account invoice line has not been created"
-
I verify that an account invoice line with origin 'Test_SO003' is created
-
!python {model: account.invoice.line}: |
sale_order_obj = self.pool.get('sale.order')
acc_inv_obj = self.pool.get('account.invoice')
inv = acc_inv_obj.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
inv_line = self.search(cr, uid, [('origin','=',so.name),('name','=','Slider Mobile'),('invoice_id','=',inv)])
assert inv_line, "Account invoice line has not been created"
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
inv = self.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|')])
for id in inv:
wf_service.trg_validate(uid, 'account.invoice',id,'invoice_open', cr)
-
I assign an analytic journal to the bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
40000.0, ref('account.cash'), ref('account.period_5'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='tst')
-
I verify the invoice is in Paid state
-
!python {model: account.invoice}: |
invoice_id = self.search(cr, uid, [('origin','=','Test_SO004|Test_SO003|'),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in done state."

View File

@ -1,206 +0,0 @@
-
In order to test the invoices based on sale order lines of sales module in OpenERP
I create a Sale Order for two products LG Viewty Smart and Slider mobile for qty 100 having order_policy manual.
-
!record {model: sale.order, id: sale_order_so3}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: Test_SO003
order_line:
- name: Slider Mobile
sequence: 1
price_unit: 200.0
product_uom: product.product_uom_unit
product_uom_qty: 100.0
state: draft
delay: 7.0
product_id: sale.product_product_slidermobile0
product_uos_qty: 100.0
type: make_to_order
- name: LG Viewty Smart
price_unit: 170.0
sequence: 2
product_uom: product.product_uom_unit
product_uom_qty: 100.0
state: draft
delay: 7.0
product_id: sale.product_product_lgviewtysmart0
product_uos_qty: 100.0
th_weight: 0.0
type: make_to_order
order_policy: manual
partner_id: sale.res_partner_cleartrail0
partner_invoice_id: sale.res_partner_address_2
partner_order_id: sale.res_partner_address_1
partner_shipping_id: sale.res_partner_address_3
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
-
I confirm the Sale Order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so3}
-
I click on the "Make Invoice" button of sale order line
-
!record {model: sale.order.line.make.invoice, id: sale_order_line_make_invoice_0}:
{}
-
I click on the "Create Invoice" button of wizard
-
!python {model: sale.order.line.make.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
sol = so.order_line[0]
self.make_invoices(cr, uid, [ref("sale_order_line_make_invoice_0")], {"lang": "en_US",
"tz": False, "active_model": "sale.order.line", "active_ids": [sol.id],
"search_default_uninvoiced": 1, "active_id": sol.id,
})
-
I verify that "Invoiced" has been set to True.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so3"))
sol = sale_id.order_line[0]
assert(sol.invoiced == True), "Invoiced has not been set to true"
-
I verify that an invoice for sale order line has been created.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so3"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so3"
-
I click on the Create button of invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
I verify that an invoice state has transit from draft to open state
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
assert invoice_id, "Invoice is not in the open state"
-
I assign an analytic journal to the bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
20000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify that an invoice is in done state.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in done state."
-
I verify that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so3"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
-
I create an invoice for another sale order line. I click on the "Make Invoice" button of sale order line
-
!record {model: sale.order.line.make.invoice, id: sale_order_line_make_invoice_1}:
{}
-
I click on the "Create Invoice" button of wizard
-
!python {model: sale.order.line.make.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
sol = so.order_line[1]
self.make_invoices(cr, uid, [ref("sale_order_line_make_invoice_1")], {"lang": "en_US",
"tz": False, "active_model": "sale.order.line", "active_ids": [sol.id],
"search_default_uninvoiced": 1, "active_id": sol.id,
})
-
I verify that invoice for sale order line has been created.
-
!python {model: sale.order}: |
so = self.browse(cr, uid, ref("sale_order_so3"))
assert so.invoice_ids[1], "Invoices has not been generated for sale_order_so3"
-
I verify that "Invoiced" has been set to True.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so3"))
sol = sale_id.order_line[1]
assert(sol.invoiced == True), "Invoiced has not been set to true"
-
I verify that "Paid" has been set to False.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so3"))
assert(sale_id.invoiced == False), "Paid has not been set to true"
-
I open the Invoice for the SO.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
import netsvc
wf_service = netsvc.LocalService("workflow")
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
wf_service.trg_validate(uid, 'account.invoice',invoice.id,'invoice_open', cr)
-
I verify that an invoice state has transit from draft to open state
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
assert invoice_id, "Invoice is not in the open state"
-
Assign analytic journal into bank journal
-
!record {model: account.journal, id: sale.account_journal_bankjournal0}:
analytic_journal_id: account.cose_journal_sale
-
I pay the invoice
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','open')])
self.pay_and_reconcile(cr, uid, invoice_id,
17000.0, ref('account.cash'), ref('account.period_8'),
ref('sale.account_journal_bankjournal0'), ref('account.cash'),
ref('account.period_8'), ref('sale.account_journal_bankjournal0'),
name='test')
-
I verify the invoice is in done state.
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so3"))
invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','paid')])
assert invoice_id, "Invoice for SO is not in done state."
-
I verify that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so3"))
assert(sale_id.invoiced == True), "Paid has not been set to true"

View File

@ -39,7 +39,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
@return: A dictionary which of fields with values.
"""
if context is None: context = {}
res = False
invoices = {}