odoo/addons/stock_invoice_directly/test/stock_invoice_directly.yml

62 lines
2.8 KiB
YAML

-
In order to test the stock_invoice_directly module. I will create an outgoing
picking order which creates an invoice from the picking order itself.
-
I create an Outgoing Picking order.
-
!record {model: stock.picking, id: stock_picking_out0}:
partner_id: base.res_partner_address_22
invoice_state: 2binvoiced
move_lines:
- company_id: base.main_company
location_id: stock.stock_location_stock
product_id: product.product_product_3
product_qty: 3.0
product_uom: product.product_uom_unit
location_dest_id: stock.stock_location_customers
move_type: direct
type: out
-
I need to check the availability of the product so I make my picking order for processing later.
-
!python {model: stock.picking}: |
self.draft_force_assign(cr, uid, [ref("stock_picking_out0")], {"lang": "en_US", "search_default_available":
1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
"active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
})
-
I check the product availability. Product is available in the stock and ready to be sent.
-
!python {model: stock.picking}: |
self.action_assign(cr, uid, [ref("stock_picking_out0")], {"lang": "en_US", "search_default_available":
1, "tz": False, "active_model": "ir.ui.menu", "contact_display": "partner",
"active_ids": [ref("stock.menu_action_picking_tree")], "active_id": ref("stock.menu_action_picking_tree"),
})
-
I process the delivery
-
!python {model: stock.partial.picking}: |
partial_id = self.create(cr, uid, {}, context={'active_model':'stock.picking',
'active_ids':[ref('stock_picking_out0')]})
self.do_partial(cr, uid, [partial_id])
-
As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
-
!python {model: stock.invoice.onshipping}: |
wiz_id = self.create(cr, uid, {'invoice_date': '2010-08-04', 'journal_id': ref('account.sales_journal')},
{'active_ids': [ref("stock_picking_out0")], "active_model": "stock.picking"})
self.create_invoice(cr, uid, [wiz_id], {"lang": "en_US",
"search_default_available": 1, "tz": False, "active_model": "stock.picking",
"contact_display": "partner", "active_ids": [ref("stock_picking_out0")], "active_id": ref("stock_picking_out0")})
-
I check that the customer invoice is created successfully.
-
!python {model: account.invoice}: |
picking_obj = self.pool.get('stock.picking')
picking = picking_obj.browse(cr, uid, [ref('stock_picking_out0')])
partner = picking[0].partner_id.id
inv_ids = self.search(cr, uid, [('type','=','out_invoice'),('partner_id','=',partner)])
assert inv_ids, 'No Invoice is generated!'