summaryrefslogtreecommitdiff
path: root/addons/website_sale_slides/tests
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2019-02-11 12:32:19 +0000
committerThibault Delavallée <tde@odoo.com>2019-02-11 17:46:40 +0000
commit9b7bee73e5b6c09656c3720a5c9709f3948534c0 (patch)
tree8ae9dccb279ec0c01800ec0dc1f9695a717c03f8 /addons/website_sale_slides/tests
parentfb8126ddd7d0eb6a55435c1eadf99df6cf4fb658 (diff)
[ADD] website_sale_slides: allow to sell slide.channel
Task #1937160 Purpose ======= This commit adds sale capabilities to a slide.channel. A slide.channel can now have the 'payment' visibility, that requires a 'product_id' configured on the channel. When a customer purchases a product linked to a channel, he is added to the members of the channel (see slide.channel.partner_ids) when his order is confirmed. The feature is added in a new module 'website_sale_slides' that comes as a bridge auto-installed between 'website_slides' and 'website_sale'. The final goal is to be able to sell "courses" (see task #1902304).
Diffstat (limited to 'addons/website_sale_slides/tests')
-rw-r--r--addons/website_sale_slides/tests/__init__.py4
-rw-r--r--addons/website_sale_slides/tests/test_course_purchase_flow.py46
2 files changed, 50 insertions, 0 deletions
diff --git a/addons/website_sale_slides/tests/__init__.py b/addons/website_sale_slides/tests/__init__.py
new file mode 100644
index 00000000000..536fe88b96c
--- /dev/null
+++ b/addons/website_sale_slides/tests/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import test_course_purchase_flow
diff --git a/addons/website_sale_slides/tests/test_course_purchase_flow.py b/addons/website_sale_slides/tests/test_course_purchase_flow.py
new file mode 100644
index 00000000000..c97a0269f93
--- /dev/null
+++ b/addons/website_sale_slides/tests/test_course_purchase_flow.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.addons.website_slides.tests import common
+
+
+class TestCoursePurchaseFlow(common.SlidesCase):
+ def test_course_purchase_flow(self):
+ # Step1: create a course product and assign it to 2 slide.channels
+ course_product = self.env['product.product'].create({
+ 'name': "Course Product",
+ 'standard_price': 100,
+ 'list_price': 150,
+ 'type': 'service',
+ 'invoice_policy': 'order',
+ })
+
+ self.channel.write({
+ 'visibility': 'payment',
+ 'product_id': course_product.id
+ })
+
+ self.channel_2 = self.env['slide.channel'].sudo(self.user_publisher).create({
+ 'name': 'Test Channel',
+ 'visibility': 'payment',
+ 'product_id': course_product.id
+ })
+
+ # Step 2: create a sale_order with the course product
+ sale_order = self.env['sale.order'].create({
+ 'partner_id': self.customer.id,
+ 'order_line': [
+ (0, 0, {
+ 'name': course_product.name,
+ 'product_id': course_product.id,
+ 'product_uom_qty': 1,
+ 'price_unit': course_product.list_price,
+ })
+ ],
+ })
+
+ sale_order.action_confirm()
+
+ # Step 3: check that the customer is now a member of both channel
+ self.assertIn(self.customer, self.channel.partner_ids)
+ self.assertIn(self.customer, self.channel_2.partner_ids)