-
  In order to test the sale_journal module in OpenERP,
  I create a sale journal and place a sale order related to a journal
-
  I create a sale journal
-
  !record {model: sale_journal.sale.journal, id: sale_journal_sale_journal_journal0}:
    code: J1
    date: '2010-08-04'
    date_created: '2010-08-04'
    name: Journal_1
    state: draft
    user_id: base.user_root
-
  I place a sale order for product keyboard, quantity 100
-
  !record {model: sale.order, id: sale_order_so0}:
    date_order: '2010-08-04'
    invoice_quantity: order
    invoice_type_id: sale_journal.daily
    journal_id: sale_journal_sale_journal_journal0
    name: Test_SO012
    order_line:
      - name: '[KEYA] Keyboard - AZERTY'
        price_unit: 7.0
        product_uom: product.product_uom_unit
        product_uom_qty: 100.0
        state: draft
        delay: 7.0
        product_id: product.product_product_24
        product_uos_qty: 100.0
        th_weight: 0.0
        type: make_to_stock
    order_policy: manual
    partner_id: base.res_partner_4
    partner_invoice_id: base.res_partner_address_7
    partner_order_id: base.res_partner_address_7
    partner_shipping_id: base.res_partner_address_7
    picking_policy: direct
    pricelist_id: product.list0
    shop_id: sale.shop
-
  I verify that a Journal consist of sale order
-
  !python {model: sale_journal.sale.journal}: |
    sal_jour = self.browse(cr, uid, ref("sale_journal_sale_journal_journal0"))
    assert sal_jour.sale_stats_ids, "Journal does not consist of a sale order details" 
-
  Then I click on the 'Open Journal' button
-
  !python {model: sale_journal.sale.journal}: |
    self.button_open(cr, uid, [ref("sale_journal_sale_journal_journal0")], {"lang": "en_US", "search_default_user_id":
      1, "tz": False, "active_model": "ir.ui.menu", "active_ids": [ref("sale_journal.menu_definition_journal")],
      "active_id": ref("sale_journal.menu_definition_journal")})
-
  I verify that a state of journal has transit from draft to open state
-
  !python {model: sale_journal.sale.journal}: |
    sal_jour = self.browse(cr, uid, ref("sale_journal_sale_journal_journal0"))
    assert (sal_jour.state == 'open'), "Journal is not in the open state"
-
  Then I click on the 'Confirm Sales' button   
-
  !python {model: sale_journal.sale.journal}: |
    self.button_sale_confirm(cr, uid, [ref("sale_journal_sale_journal_journal0")], {"lang": "en_US", "search_default_user_id":
      1, "tz": False, "active_model": "ir.ui.menu", "active_ids": [ref("sale_journal.menu_definition_journal")],
      "active_id": ref("sale_journal.menu_definition_journal")})   
-
  I verify that a state of journal has transit from open to confirm state
-
  !python {model: sale_journal.sale.journal}: |
    sal_jour = self.browse(cr, uid, ref("sale_journal_sale_journal_journal0"))
    assert (sal_jour.state == 'confirm'), "Journal is not in the confirm state"
-
  I verify that a sale order is now in the confirm state
-
  !python {model: sale.order}: |
    sale_jour_obj = self.pool.get('sale_journal.sale.journal')
    jour = sale_jour_obj.browse(cr, uid, ref("sale_journal_sale_journal_journal0"))
    so = self.browse(cr, uid, ref("sale_order_so0"))
    so_jour = self.search(cr, uid, [('journal_id','=',jour.name) and ('state','=','manual')])
    assert so_jour, "Sale order is not in the confirm state"
-
  Then I click on the 'Close Journal' button
-
  !python {model: sale_journal.sale.journal}: |
    self.button_close(cr, uid, [ref("sale_journal_sale_journal_journal0")], {"lang": "en_US", "search_default_user_id":
      1, "tz": False, "active_model": "ir.ui.menu", "active_ids": [ref("sale_journal.menu_definition_journal")],
      "active_id": ref("sale_journal.menu_definition_journal")})
-
  I verify that a state of journal has transit from confirm to close state
-
  !python {model: sale_journal.sale.journal}: |
    sal_jour = self.browse(cr, uid, ref("sale_journal_sale_journal_journal0"))
    assert (sal_jour.state == 'close'), "Journal is not in the close state" 