コード例 #1
0
 def test_confirm_purch_line_creates_po(self):
     line = Form(self.env["sale.purchase.report.line"])
     line.partner_id = self.vendor
     line.type = "purch"
     line.product_id = self.product
     line.qty_scheduled = 10
     line.price = 80
     line = line.save()
     self.assertFalse(line.sale_line_id)
     self.assertFalse(line.purchase_line_id)
     line.action_confirm()
     self.assertTrue(line.purchase_line_id)
     self.assertFalse(line.sale_line_id)
     self.assertEqual(line.purchase_line_id.order_id.state, "purchase")
コード例 #2
0
    def test_flow_warning_bom_1(self):
        """ Record Component for a bom subcontracted with a flexible and flexible + warning consumption """
        self.bom.consumption = 'warning'
        # Create a receipt picking from the subcontractor
        picking_form = Form(self.env['stock.picking'])
        picking_form.picking_type_id = self.env.ref('stock.picking_type_in')
        picking_form.partner_id = self.subcontractor_partner1
        with picking_form.move_ids_without_package.new() as move:
            move.product_id = self.finished
            move.product_uom_qty = 1
        picking_receipt = picking_form.save()
        picking_receipt.action_confirm()

        self.assertEqual(picking_receipt.display_action_record_components,
                         'facultative')
        action = picking_receipt.action_record_components()
        mo = self.env['mrp.production'].browse(action['res_id'])
        mo_form = Form(mo.with_context(**action['context']),
                       view=action['view_id'])
        mo_form.qty_producing = 1
        with mo_form.move_line_raw_ids.edit(0) as ml:
            self.assertEqual(ml.product_id, self.comp1)
            self.assertEqual(ml.qty_done, 1)
            ml.qty_done = 2
        mo = mo_form.save()
        action_warning = mo.subcontracting_record_component()
        warning = Form(self.env['mrp.consumption.warning'].with_context(
            **action_warning['context']))
        warning = warning.save()
        warning.action_cancel()

        action_warning = mo.subcontracting_record_component()
        warning = Form(self.env['mrp.consumption.warning'].with_context(
            **action_warning['context']))
        warning = warning.save()
        warning.action_confirm()

        self.assertEqual(mo.move_raw_ids[0].move_line_ids.qty_done, 2)

        # We should not be able to call the 'record_components' button
        self.assertEqual(picking_receipt.display_action_record_components,
                         'hide')

        picking_receipt.button_validate()
        self.assertEqual(mo.state, 'done')
        avail_qty_comp1 = self.env['stock.quant']._get_available_quantity(
            self.comp1,
            self.subcontractor_partner1.property_stock_subcontractor,
            allow_negative=True)
        self.assertEqual(avail_qty_comp1, -2)
コード例 #3
0
    def generate_sale_order(self, company, partner, user):
        """ Generate sale order and confirm its state """
        sale_order = Form(self.env['sale.order'])
        sale_order.company_id = company
        sale_order.warehouse_id = company.warehouse_id
        sale_order.user_id = user
        sale_order.pricelist_id = self.env['product.pricelist'].search([
            ('id', '=', 1)
        ])
        sale_order.partner_id = partner
        sale_order.partner_invoice_id = partner
        sale_order.partner_shipping_id = partner
        sale_order = sale_order.save()

        with Form(sale_order) as so:
            with so.order_line.new() as line:
                line.name = 'Service'
                line.product_id = self.product_consultant
                line.price_unit = 450.0

        # Confirm Sale order
        sale_order.action_confirm()