~account-core-editors/account-invoice-report/github-7.0

« back to all changes in this revision

Viewing changes to account_invoice_production_lot/test/sale.yml

  • Committer: Joel Grand-Guillaume
  • Author(s): Lorenzo Battistini
  • Date: 2014-01-17 15:10:59 UTC
  • mfrom: (40.4.3)
  • Revision ID: git-v1:c40f4f84682b4e7c861dd2f5409f2287e19537f7
[MRG][ADD] account_invoice_production_lot copied from https://code.launchpad.net/~agilebg/account-invoicing/adding_account_invoice_production_lot_7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-
 
2
 !record {model: stock.location, id: location_opening}:
 
3
    name: opening
 
4
    usage: inventory
 
5
-
 
6
 !record {model: product.product, id: product_icecream}:
 
7
    default_code: 001
 
8
    name: Ice Cream
 
9
    type: product
 
10
    categ_id: product.product_category_1
 
11
    list_price: 100.0
 
12
    standard_price: 70.0
 
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
 
17
    valuation: real_time
 
18
    cost_method: average
 
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.
 
22
-
 
23
 !record {model: stock.production.lot, id: lot_icecream_0}:
 
24
    name: Lot0 for Ice cream
 
25
    product_id: product_icecream
 
26
-
 
27
  I create a draft Sale Order
 
28
-
 
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
 
33
    pricelist_id: 1
 
34
    order_policy: picking
 
35
    order_line:
 
36
      - product_id: product_icecream
 
37
        product_uom_qty: 1.0
 
38
        product_uom: 1
 
39
        price_unit: 100.0
 
40
-
 
41
  I confirm the quotation with Invoice based on deliveries policy.
 
42
-
 
43
  !workflow {model: sale.order, action: order_confirm, ref: sale_order}
 
44
-
 
45
  Now, I dispatch delivery order.
 
46
-
 
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()
 
51
        if data == True:
 
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"),
 
56
              })
 
57
          self.do_partial(cr, uid, [partial_id])
 
58
-
 
59
  I create Invoice from Delivery Order.
 
60
-
 
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]})
 
68
-
 
69
  I check the invoice details after dispatched delivery.
 
70
-
 
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