summaryrefslogtreecommitdiff
path: root/addons/stock_dropshipping/tests/test_procurement_exception.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/stock_dropshipping/tests/test_procurement_exception.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/stock_dropshipping/tests/test_procurement_exception.py')
-rw-r--r--addons/stock_dropshipping/tests/test_procurement_exception.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/stock_dropshipping/tests/test_procurement_exception.py b/addons/stock_dropshipping/tests/test_procurement_exception.py
new file mode 100644
index 00000000..2d5c7e44
--- /dev/null
+++ b/addons/stock_dropshipping/tests/test_procurement_exception.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.tests import common, Form
+
+
+class TestProcurementException(common.TransactionCase):
+
+ def test_00_procurement_exception(self):
+
+ res_partner_2 = self.env['res.partner'].create({'name': 'My Test Partner'})
+ res_partner_address = self.env['res.partner'].create({
+ 'name': 'My Test Partner Address',
+ 'parent_id': res_partner_2.id,
+ })
+
+ # I create a product with no supplier define for it.
+ product_form = Form(self.env['product.product'])
+ product_form.name = 'product with no seller'
+ product_form.lst_price = 20.00
+ product_form.categ_id = self.env.ref('product.product_category_1')
+ product_with_no_seller = product_form.save()
+
+ product_with_no_seller.standard_price = 70.0
+
+ # I create a sales order with this product with route dropship.
+ so_form = Form(self.env['sale.order'])
+ so_form.partner_id = res_partner_2
+ so_form.partner_invoice_id = res_partner_address
+ so_form.partner_shipping_id = res_partner_address
+ so_form.payment_term_id = self.env.ref('account.account_payment_term_end_following_month')
+ with so_form.order_line.new() as line:
+ line.product_id = product_with_no_seller
+ line.product_uom_qty = 3
+ line.route_id = self.env.ref('stock_dropshipping.route_drop_shipping')
+ sale_order_route_dropship01 = so_form.save()
+
+ # I confirm the sales order, but it will raise an error
+ with self.assertRaises(Exception):
+ sale_order_route_dropship01.action_confirm()
+
+ # I set the at least one supplier on the product.
+ with Form(product_with_no_seller) as f:
+ with f.seller_ids.new() as seller:
+ seller.delay = 1
+ seller.name = res_partner_2
+ seller.min_qty = 2.0
+
+ # I confirm the sales order, no error this time
+ sale_order_route_dropship01.action_confirm()
+
+ # I check a purchase quotation was created.
+ purchase = self.env['purchase.order.line'].search([
+ ('sale_line_id', '=', sale_order_route_dropship01.order_line.ids[0])]).order_id
+
+ self.assertTrue(purchase, 'No Purchase Quotation is created')