[IMP,MOVE]purchase: move create_invoice.yml to invoice_from_reception.yml and improve its code
bzr revid: dbr@tinyerp.com-20111018102138-ie0menbd3asvpxc5
This commit is contained in:
parent
b9d1f4f3b7
commit
9b45d19df1
|
@ -62,7 +62,7 @@ Dashboard for purchase management that includes:
|
|||
'test': [
|
||||
#'test/ui/onchange_methods.yml',
|
||||
'test/process/rfq2purchase_order.yml',
|
||||
#'test/process/create_invoice.yml',
|
||||
'test/process/invoice_from_reception.yml',
|
||||
#'test/process/purchase_from_picking.yml',
|
||||
#'test/process/procurement_buy.yml',
|
||||
#'test/process/merge_purchase_order.yml',
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
-
|
||||
I create invoice for order where invoice control is 'Draft invoices pre-generated'.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_invoice_create(cr, uid, [ref("order_purchase1")])
|
||||
-
|
||||
I create invoice for order where invoice control is 'Based on receptions'.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
ids = self.action_picking_create(cr, uid, [ref("order_purchase2")])
|
||||
-
|
||||
I check the delivery order.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
#search_picking_id and pass it as IDs
|
||||
try:
|
||||
self.action_process(cr, uid, [ref("order_purchase2")],context=context)
|
||||
except:
|
||||
pass
|
|
@ -0,0 +1,36 @@
|
|||
-
|
||||
I create reception for order where invoice control is 'Based on receptions'.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.action_picking_create(cr, uid, [ref("order_purchase2")])
|
||||
-
|
||||
I create an invoice for order by clicking on "Create Invoice" wizard
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
import time
|
||||
pick_ids = [x.id for x in self.pool.get('purchase.order').browse(cr, uid, ref("order_purchase2")).picking_ids]
|
||||
id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.expenses_journal')},{'active_ids': pick_ids, 'active_model': 'stock.picking'})
|
||||
self.create_invoice(cr, uid, [id], {"active_ids": pick_ids, "active_id": pick_ids[0]})
|
||||
-
|
||||
Reception is ready for process so now done the process.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
pick_ids = [x.id for x in self.browse(cr, uid, ref("order_purchase2")).picking_ids]
|
||||
self.pool.get('stock.picking').validate_picking(cr, uid, pick_ids)
|
||||
-
|
||||
Now,put all Purchase Order invoice in open state.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
import netsvc
|
||||
purchase = self.pool.get('purchase.order')
|
||||
invoice_ids = [x.id for x in purchase.browse(cr, uid, ref("order_purchase2")).invoice_ids]
|
||||
invoice_ids.append([x.id for x in purchase.browse(cr, uid, ref("order_purchase1")).invoice_ids][0])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for invoice in invoice_ids:
|
||||
wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_open', cr)
|
||||
-
|
||||
I check that purchase order is invoiced & paid or it's shipped.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
assert self.browse(cr, uid, ref("order_purchase2")).shipped == True,"Reception is not delivered"
|
||||
assert self.browse(cr, uid, ref("order_purchase1")).invoiced == True,"Purchase order is not Invoiced & Paid"
|
|
@ -24,7 +24,10 @@
|
|||
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert len(purchase_order.invoice_ids) == 1,"Invoice line is not more or less than one"
|
||||
for invoice in purchase_order.invoice_ids:
|
||||
assert invoice.state == "draft", "Invoice state should be draft"
|
||||
if purchase_order.invoiced == True:
|
||||
assert invoice.state == "open", "Invoice state should be Open"
|
||||
else:
|
||||
assert invoice.state == "draft", "Invoice state should be draft"
|
||||
assert invoice.reference == purchase_order.partner_ref or purchase_order.name,"Invoice reference is not correspond with purchase order"
|
||||
assert invoice.account_id == purchase_order.partner_id.property_account_payable ,"Invoice account_id is not correspond with purchase order"
|
||||
assert invoice.type == 'in_invoice',"Invoice type is not correspond with purchase order"
|
||||
|
@ -33,7 +36,6 @@
|
|||
assert invoice.address_contact_id == purchase_order.partner_address_id ,"Invoice address_contact is not correspond with purchase order"
|
||||
assert invoice.origin == purchase_order.name,"Invoice origin is not correspond with purchase order"
|
||||
assert invoice.company_id == purchase_order.company_id ,"Invoice company is not correspond with purchase order"
|
||||
assert invoice.state == "draft", "Invoice state should be draft"
|
||||
assert invoice.name == purchase_order.name, "Invoice name is not correspond with purchase order"
|
||||
assert invoice.amount_untaxed == purchase_order.amount_untaxed, "Invoice untaxed amount is not correspond with purchase order"
|
||||
assert invoice.amount_tax == purchase_order.amount_tax, "Invoice tax amount is not correspond with purchase order"
|
||||
|
@ -55,12 +57,17 @@
|
|||
I check that the purchase order has now a corresponding Reception.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase2"))
|
||||
assert len(purchase_order.picking_ids) == 1, "Reception line should be more or less than one"
|
||||
purchase_order = self.browse(cr, uid, ref("order_purchase1"))
|
||||
assert len(purchase_order.picking_ids) == 1, "Reception line should be one"
|
||||
for picking in purchase_order.picking_ids:
|
||||
assert picking.state == "assigned", "Reception state should be in assigned state"
|
||||
assert picking.address_id == purchase_order.dest_address_id or purchase_order.partner_address_id ,"Reception product is not correspond with purchase order"
|
||||
assert picking.invoice_state == '2binvoiced',"Reception Invoice state should be 2binvoiced"
|
||||
if purchase_order.invoice_method == 'picking':
|
||||
assert picking.invoice_state == '2binvoiced',"Reception Invoice state should be 2binvoiced if it's Based on receptions "
|
||||
elif purchase_order.invoice_method == 'picking':
|
||||
assert picking.invoice_state == 'invoiced',"Reception Invoice state should be invoiced."
|
||||
else:
|
||||
assert picking.invoice_state == 'none',"Reception Invoice state should be Not applicable if it's invoice method is 'Draft invoices pre-generated'"
|
||||
assert picking.company_id == purchase_order.company_id ,"Reception company is not correspond with purchase order"
|
||||
for index in range(0,len(picking.move_lines)):
|
||||
assert picking.move_lines[index].product_id == purchase_order.order_line[index].product_id, "Reception product is not correspond with purchase order"
|
||||
|
|
|
@ -1145,7 +1145,22 @@ class stock_picking(osv.osv):
|
|||
move_obj.unlink(cr, uid, ids2, ctx)
|
||||
|
||||
return super(stock_picking, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
|
||||
def validate_picking(self, cr, uid, id, context=None):
|
||||
for picking in self.browse(cr, uid, id, context=context):
|
||||
partial_datas = {
|
||||
'partner_id': picking.address_id.partner_id.id,
|
||||
'address_id': picking.address_id.id,
|
||||
'delivery_date' : time.strftime('%Y-%m-%d')
|
||||
}
|
||||
for move in picking.move_lines:
|
||||
partial_datas['move%s'%(move.id)]= {
|
||||
'product_id': move.product_id,
|
||||
'product_qty': move.product_qty,
|
||||
'product_uom': move.product_uom.id,
|
||||
}
|
||||
val = self.do_partial(cr, uid, [picking.id], partial_datas, context=context)
|
||||
return val
|
||||
# FIXME: needs refactoring, this code is partially duplicated in stock_move.do_partial()!
|
||||
def do_partial(self, cr, uid, ids, partial_datas, context=None):
|
||||
""" Makes partial picking and moves done.
|
||||
|
|
Loading…
Reference in New Issue