[MERGE] trunk-simplify_picking_invoice-sgo (simplify order policy on sale orders

bzr revid: rco@openerp.com-20120427135948-0jh7go0b17uk9nii
This commit is contained in:
Raphael Collet
2012-04-27 15:59:48 +02:00
6 changed files with 13 additions and 69 deletions
-1
View File
@@ -92,7 +92,6 @@ Dashboard for Sales Manager that includes:
'test/sale_order_demo.yml',
'test/picking_order_policy.yml',
'test/manual_order_policy.yml',
'test/postpaid_order_policy.yml',
'test/prepaid_order_policy.yml',
'test/cancel_order.yml',
'test/delete_order.yml',
+10 -11
View File
@@ -222,18 +222,17 @@ class sale_order(osv.osv):
'incoterm': fields.many2one('stock.incoterms', 'Incoterm', help="Incoterm which stands for 'International Commercial terms' implies its a series of sales terms which are used in the commercial transaction."),
'picking_policy': fields.selection([('direct', 'Deliver each product when available'), ('one', 'Deliver all products at once')],
'Picking Policy', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="""If you don't have enough stock available to deliver all at once, do you accept partial shipments or not?"""),
'Shipping Policy', required=True, readonly=True, states={'draft': [('readonly', False)]},
help="""If you don't have enough stock available to deliver all at once, do you accept partial shipments or not?"""),
'order_policy': fields.selection([
('prepaid', 'Pay before delivery'),
('manual', 'Deliver & invoice on demand'),
('picking', 'Invoice based on deliveries'),
('postpaid', 'Invoice on order after delivery'),
], 'Invoice Policy', required=True, readonly=True, states={'draft': [('readonly', False)]},
help="""The Invoice Policy is used to synchronise invoice and delivery operations.
- The 'Pay before delivery' choice will first generate the invoice and then generate the picking order after the payment of this invoice.
- The 'Deliver & Invoice on demand' will create the picking order directly and wait for the user to manually click on the 'Invoice' button to generate the draft invoice based on the sale order or the sale order lines.
- The 'Invoice on order after delivery' choice will generate the draft invoice based on sales order after all picking lists have been finished.
- The 'Invoice based on deliveries' choice is used to create an invoice during the picking process."""),
('manual', 'On Demand'),
('picking', 'On Delivery Order'),
('prepaid', 'Before Delivery'),
], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)]},
help="""This field controls how invoice and delivery operations are synchronized.
- With 'On Demand', the invoice is created manually when needed.
- With 'On Delivery Order', a draft invoice is generated after all pickings have been processed.
- With 'Before Delivery', a draft invoice is created, and it must be paid before delivery."""),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="Pricelist for current sales order."),
'project_id': fields.many2one('account.analytic.account', 'Contract/Analytic Account', readonly=True, states={'draft': [('readonly', False)]}, help="The analytic account related to a sales order."),
+1 -1
View File
@@ -68,7 +68,7 @@
<field name="partner_invoice_id" ref="base.res_partner_address_9"/>
<field name="partner_shipping_id" ref="base.res_partner_address_9"/>
<field name="invoice_quantity">order</field>
<field name="order_policy">postpaid</field>
<field name="order_policy">prepaid</field>
</record>
+1 -1
View File
@@ -227,7 +227,7 @@
<field name="incoterm" widget="selection"/>
<field name="picking_policy" required="True"/>
<field name="order_policy" on_change="shipping_policy_change(order_policy)"/>
<field name="invoice_quantity" attrs="{'readonly':[('order_policy','in',('prepaid','picking'))]}"/>
<field name="invoice_quantity" invisible="True"/>
</group>
<group colspan="2" col="2">
<separator string="References" colspan="2"/>
+1 -1
View File
@@ -172,7 +172,7 @@
<record id="trans_wait_invoice_invoice" model="workflow.transition">
<field name="act_from" ref="act_wait_invoice"/>
<field name="act_to" ref="act_invoice"/>
<field name="condition">(order_policy=='prepaid') or ((order_policy=='postpaid') and shipped)</field>
<field name="condition">(order_policy=='prepaid')</field>
</record>
<record id="trans_wait_invoice_invoice_manual" model="workflow.transition">
@@ -1,54 +0,0 @@
-
Now I confirm the Quotation with "Invoice on order after delivery" policy.
-
!workflow {model: sale.order, action: order_confirm, ref: order2}
-
I check that related delivery order after confirmed.
-
!python {model: sale.order}: |
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."
-
Now, I dispatch delivery order.
-
!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 open the invoice.
-
!python {model: sale.order}: |
import netsvc
wf_service = netsvc.LocalService("workflow")
order = self.browse(cr, uid, ref("order2"))
#assert order.invoice_ids, "Invoice should be created after dispatch delivery order."
for invoice in order.invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
-
I pay the invoice.
-
!python {model: account.invoice}: |
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')
-
I check that an order has been invoiced, shipped and closed.
-
!python {model: sale.order}: |
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." #TOFIX: procurement is gone in idle state so order never shipped, invoiced. after install mrp, it will be normal.
#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.'