2
!record {model: stock.location, id: location_opening}:
6
!record {model: product.product, id: product_icecream}:
10
categ_id: product.product_category_1
13
uom_id: product.product_uom_kgm
14
uom_po_id: product.product_uom_kgm
15
procure_method: make_to_stock
16
property_stock_inventory: location_opening
19
property_stock_account_input: account.o_expense
20
property_stock_account_output: account.o_income
21
description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events.
23
!record {model: stock.production.lot, id: lot_icecream_0}:
24
name: Lot0 for Ice cream
25
product_id: product_icecream
27
I create a draft Sale Order
29
!record {model: sale.order, id: sale_order}:
30
partner_id: base.res_partner_2
31
partner_invoice_id: base.res_partner_address_3
32
partner_shipping_id: base.res_partner_address_3
36
- product_id: product_icecream
41
I confirm the quotation with Invoice based on deliveries policy.
43
!workflow {model: sale.order, action: order_confirm, ref: sale_order}
45
Now, I dispatch delivery order.
47
!python {model: stock.partial.picking}: |
48
order = self.pool.get('sale.order').browse(cr, uid, ref("sale_order"))
49
for pick in order.picking_ids:
50
data = pick.force_assign()
52
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
53
partial = self.browse(cr, uid, partial_id)
54
partial.move_ids[0].write({
55
'prodlot_id': ref("lot_icecream_0"),
57
self.do_partial(cr, uid, [partial_id])
59
I create Invoice from Delivery Order.
61
!python {model: stock.invoice.onshipping}: |
62
sale = self.pool.get('sale.order')
63
sale_order = sale.browse(cr, uid, ref("sale_order"))
64
ship_ids = [x.id for x in sale_order.picking_ids]
65
wiz_id = self.create(cr, uid, {'journal_id': ref('account.sales_journal')},
66
{'active_ids': ship_ids, 'active_model': 'stock.picking'})
67
self.create_invoice(cr, uid, [wiz_id], {"active_ids": ship_ids, "active_id": ship_ids[0]})
69
I check the invoice details after dispatched delivery.
71
!python {model: sale.order}: |
72
order = self.browse(cr, uid, ref("sale_order"))
73
assert order.invoice_ids, "Invoice is not created."
74
ac = order.partner_invoice_id.property_account_receivable.id
75
for invoice in order.invoice_ids:
76
invoice.load_lines_lots()
77
assert invoice.invoice_line[0].formatted_note == '<ul> <li>S/N Lot0 for Ice cream</li> </ul>', "Wrgong formatted note for '%s' line" % invoice.invoice_line[0].name