restricted.yml 7.08 KB
-
  Standard flow of a Call for Bids in mode restricted
-
  Create Call for Bids
-
  !record {model: purchase.requisition, id: req1}:
    date_end: '2013-08-30 00:00:00'
    bid_tendering_mode: 'restricted'
    schedule_date: '2013-09-30'
    req_validity: '2013-09-10'
    pricelist_id: purchase.list0
    line_ids:
      - product_id: product.product_product_15
        product_qty: 15.0
      - product_id: product.product_product_25
        product_qty: 5.0
      - product_id: product.product_product_27
        product_qty: 40.0
-
  Confirm Call
-
  !python {model: purchase.requisition, id: req1}: |
    self.signal_workflow('sent_suppliers')
-
  Create RFQ1. I run the 'Request a quotation' wizard. I fill the supplier.
-
  !record {model: purchase.requisition.partner, id: wizard_partner1}:
    partner_id: base.res_partner_1
-
  Create RFQ1. I confirm the wizard.
-
  !python {model: purchase.requisition.partner}: |
    self.create_order(cr, uid, [ref("wizard_partner1")],{
        'active_model': 'purchase.requisition',
        'active_id': ref("req1"),
        'active_ids': [ref("req1")],
        })
-
  Create RFQ2. I run the 'Request a quotation' wizard. I fill the supplier.
-
  !record {model: purchase.requisition.partner, id: wizard_partner2}:
    partner_id: base.res_partner_3
-
  Create RFQ2. I confirm the wizard.
-
  !python {model: purchase.requisition.partner}: |
    self.create_order(cr, uid, [ref("wizard_partner2")],{
        'active_model': 'purchase.requisition',
        'active_id': ref("req1"),
        'active_ids': [ref("req1")],
        })
-
  Check the RFQs. Type must be 'rfq', state 'draft', all prices 0 and the total untaxed amount 0.
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *

    assert_equal(len(self.purchase_ids), 2)

    for rfq in self.purchase_ids:
        assert_equal(rfq.type, 'rfq')
        assert_equal(rfq.state, 'draft')
        assert_equal(rfq.amount_untaxed, 0.0)

        for line in rfq.order_line:
            assert_equal(line.price_subtotal, 0.0)
-
  I send the RFQs. For this, I print the RFQ.
-
  !python {model: purchase.requisition}: |
    purchase_req = self.browse(cr, uid, ref("req1"))
    for rfq in purchase_req.purchase_ids:
        self.pool.get('purchase.order').print_quotation(cr, uid, [rfq.id])
-
  I check the RFQs are in "RFQ sent" state.
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *

    assert_equal(len(self.purchase_ids), 2)

    for rfq in self.purchase_ids:
        assert_equal(rfq.type, 'rfq')
        assert_equal(rfq.state, 'sent')
        assert_equal(rfq.amount_untaxed, 0.0)

        for line in rfq.order_line:
            assert_equal(line.price_subtotal, 0.0)
-
  I encode the bids. I set a price on the lines.
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *

    assert_equal(len(self.purchase_ids), 2)
    price = 30.0

    for rfq in self.purchase_ids:
        for line in rfq.order_line:
            line.price_unit = price
            price += 5.0
-
  I run the 'Bid encoded' wizard of bid1. I fill the date.
-
  !record {model: purchase.action_modal.datetime, id: wizard_encodebid1}:
    datetime: '2013-08-13 00:00:00'
-
  I run the 'Bid encoded' wizard of bid1. I confirm the wizard.
-
  !python {model: purchase.requisition}: |
    purchase_req = self.browse(cr, uid, ref("req1"))
    assert len(purchase_req.purchase_ids) == 2, "There must be 2 RFQs linked to this Call for bids"
    for rfq in purchase_req.purchase_ids:
        self.pool.get('purchase.order').bid_received_ok(cr, uid,
            [rfq.id],
            {'active_id': ref("wizard_encodebid1")
             })
-
  I run the 'Bid encoded' wizard of bid2. I fill the date.
-
  !record {model: purchase.action_modal.datetime, id: wizard_encodebid2}:
    datetime: '2013-08-13 00:10:00'
-
  I run the 'Bid encoded' wizard of bid2. I confirm the wizard.
-
  !python {model: purchase.requisition}: |
    purchase_req = self.browse(cr, uid, ref("req1"))
    assert len(purchase_req.purchase_ids) == 2, "There must be 2 RFQs linked to this Call for bids"
    for rfq in purchase_req.purchase_ids:
        self.pool.get('purchase.order').bid_received_ok(cr, uid,
            [rfq.id],
            {'active_id': ref("wizard_encodebid2")
             })
-
  I check the "Bid Encoded" status.
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *

    assert_equal(len(self.purchase_ids), 2)

    for rfq in self.purchase_ids:
        assert_equal(rfq.type, 'bid')
        assert_equal(rfq.state, 'bid')
        assert_not_equal(rfq.amount_untaxed, 0.0)

        for line in rfq.order_line:
            assert_not_equal(line.price_subtotal, 0.0)
-
  I close the Call for bids and move to bids selection
-
  !python {model: purchase.requisition, id: req1}: |
    self.signal_workflow('open_bid')
-
  In the bids selection, I confirm line 1 of bid 1 and line 2 of bid 2. For line 3, I select quantity 10 of bid 1 and confirm. I confirm line 3 of bid 2 for remaining quantity.
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *
    assert_equal(len(self.purchase_ids), 2)

    self.purchase_ids[0].order_line[0].action_confirm()
    self.purchase_ids[1].order_line[1].action_confirm()

    QuantityWizard = self.env['bid.line.qty']
    quantity_wizard = QuantityWizard.create({'qty': 5})

    quantity_wizard.with_context({
        'active_mode': 'purchase.order.line',
        'active_id': self.purchase_ids[0].order_line[2].id,
        'active_ids': [self.purchase_ids[0].order_line[2].id],
    }).change_qty()
    self.purchase_ids[1].order_line[2].action_confirm()
-
  For each call for bid lines, I check that the confirmed selection match the
  requested qty
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *
    for req_line in self.line_ids:
        req_qty = req_line.product_qty
        confirmed_qty = 0.0

        for pol in req_line.purchase_line_ids:
            if pol.state == 'confirmed':
                confirmed_qty += pol.quantity_bid

        assert_almost_equal(confirmed_qty, req_qty)
-
  I mark the tender as selected
-
  !python {model: purchase.requisition, id: req1}: |
    self.signal_workflow('bid_selected')
-
  I mark the tender as selection closed
-
  !python {model: purchase.requisition, id: req1}: |
    self.signal_workflow('close_bid')
-
  I generate the POs
-
  !python {model: purchase.requisition}: |
    self.generate_po(cr, uid, [ref("req1")])
-
  Then I should see 2 selected bids
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *

    assert_equal(2, len(self.purchase_ids))
    for bid in self.purchase_ids:
        assert_equal('bid_selected', bid.state)
        assert_equal('bid', bid.type)
-
  And I should see 2 generated purchase orders in draft that can be validated
  manually.
-
  !python {model: purchase.requisition, id: req1}: |
    from nose.tools import *

    assert_equal(2, len(self.generated_order_ids))
    for po in self.generated_order_ids:
        assert_equal('draftpo', po.state)
        assert_equal('purchase', po.type)
        assert_is(False, po.keep_in_draft)