mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-18 04:12:06 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
# Free Delivery with Coupon & Loyalty on eCommerce
|
||||
|
||||
Allows to offer free shippings in loyalty program rewards on eCommerce
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install odoo-bringout-oca-ocb-website_sale_loyalty_delivery
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
This addon depends on:
|
||||
- website_sale_delivery
|
||||
- website_sale_loyalty
|
||||
- sale_loyalty_delivery
|
||||
|
||||
## Manifest Information
|
||||
|
||||
- **Name**: Free Delivery with Coupon & Loyalty on eCommerce
|
||||
- **Version**: 1.0
|
||||
- **Category**: Website/Website
|
||||
- **License**: LGPL-3
|
||||
- **Installable**: False
|
||||
|
||||
## Source
|
||||
|
||||
Based on [OCA/OCB](https://github.com/OCA/OCB) branch 16.0, addon `website_sale_loyalty_delivery`.
|
||||
|
||||
## License
|
||||
|
||||
This package maintains the original LGPL-3 license from the upstream Odoo project.
|
||||
|
||||
## Documentation
|
||||
|
||||
- Overview: doc/OVERVIEW.md
|
||||
- Architecture: doc/ARCHITECTURE.md
|
||||
- Models: doc/MODELS.md
|
||||
- Controllers: doc/CONTROLLERS.md
|
||||
- Wizards: doc/WIZARDS.md
|
||||
- Reports: doc/REPORTS.md
|
||||
- Security: doc/SECURITY.md
|
||||
- Install: doc/INSTALL.md
|
||||
- Usage: doc/USAGE.md
|
||||
- Configuration: doc/CONFIGURATION.md
|
||||
- Dependencies: doc/DEPENDENCIES.md
|
||||
- Troubleshooting: doc/TROUBLESHOOTING.md
|
||||
- FAQ: doc/FAQ.md
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Architecture
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
U[Users] -->|HTTP| V[Views and QWeb Templates]
|
||||
V --> C[Controllers]
|
||||
V --> W[Wizards – Transient Models]
|
||||
C --> M[Models and ORM]
|
||||
W --> M
|
||||
M --> R[Reports]
|
||||
DX[Data XML] --> M
|
||||
S[Security – ACLs and Groups] -. enforces .-> M
|
||||
|
||||
subgraph Website_sale_loyalty_delivery Module - website_sale_loyalty_delivery
|
||||
direction LR
|
||||
M:::layer
|
||||
W:::layer
|
||||
C:::layer
|
||||
V:::layer
|
||||
R:::layer
|
||||
S:::layer
|
||||
DX:::layer
|
||||
end
|
||||
|
||||
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
|
||||
```
|
||||
|
||||
Notes
|
||||
- Views include tree/form/kanban templates and report templates.
|
||||
- Controllers provide website/portal routes when present.
|
||||
- Wizards are UI flows implemented with `models.TransientModel`.
|
||||
- Data XML loads data/demo records; Security defines groups and access.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Configuration
|
||||
|
||||
Refer to Odoo settings for website_sale_loyalty_delivery. Configure related models, access rights, and options as needed.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Controllers
|
||||
|
||||
HTTP routes provided by this module.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant U as User/Client
|
||||
participant C as Module Controllers
|
||||
participant O as ORM/Views
|
||||
|
||||
U->>C: HTTP GET/POST (routes)
|
||||
C->>O: ORM operations, render templates
|
||||
O-->>U: HTML/JSON/PDF
|
||||
```
|
||||
|
||||
Notes
|
||||
- See files in controllers/ for route definitions.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Dependencies
|
||||
|
||||
This addon depends on:
|
||||
|
||||
- [website_sale_delivery](../../odoo-bringout-oca-ocb-website_sale_delivery)
|
||||
- [website_sale_loyalty](../../odoo-bringout-oca-ocb-website_sale_loyalty)
|
||||
- [sale_loyalty_delivery](../../odoo-bringout-oca-ocb-sale_loyalty_delivery)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# FAQ
|
||||
|
||||
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
|
||||
- Q: How to enable? A: Start server with --addon website_sale_loyalty_delivery or install in UI.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Install
|
||||
|
||||
```bash
|
||||
pip install odoo-bringout-oca-ocb-website_sale_loyalty_delivery"
|
||||
# or
|
||||
uv pip install odoo-bringout-oca-ocb-website_sale_loyalty_delivery"
|
||||
```
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Models
|
||||
|
||||
Detected core models and extensions in website_sale_loyalty_delivery.
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
```
|
||||
|
||||
Notes
|
||||
- Classes show model technical names; fields omitted for brevity.
|
||||
- Items listed under _inherit are extensions of existing models.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Overview
|
||||
|
||||
Packaged Odoo addon: website_sale_loyalty_delivery. Provides features documented in upstream Odoo 16 under this addon.
|
||||
|
||||
- Source: OCA/OCB 16.0, addon website_sale_loyalty_delivery
|
||||
- License: LGPL-3
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Reports
|
||||
|
||||
This module does not define custom reports.
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# Security
|
||||
|
||||
This module does not define custom security rules or access controls beyond Odoo defaults.
|
||||
|
||||
Default Odoo security applies:
|
||||
- Base user access through standard groups
|
||||
- Model access inherited from dependencies
|
||||
- No custom row-level security rules
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Troubleshooting
|
||||
|
||||
- Ensure Python and Odoo environment matches repo guidance.
|
||||
- Check database connectivity and logs if startup fails.
|
||||
- Validate that dependent addons listed in DEPENDENCIES.md are installed.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Usage
|
||||
|
||||
Start Odoo including this addon (from repo root):
|
||||
|
||||
```bash
|
||||
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon website_sale_loyalty_delivery
|
||||
```
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Wizards
|
||||
|
||||
This module does not include UI wizards.
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
[project]
|
||||
name = "odoo-bringout-oca-ocb-website_sale_loyalty_delivery"
|
||||
version = "16.0.0"
|
||||
description = "Free Delivery with Coupon & Loyalty on eCommerce - Allows to offer free shippings in loyalty program rewards on eCommerce"
|
||||
authors = [
|
||||
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
|
||||
]
|
||||
dependencies = [
|
||||
"odoo-bringout-oca-ocb-website_sale_delivery>=16.0.0",
|
||||
"odoo-bringout-oca-ocb-website_sale_loyalty>=16.0.0",
|
||||
"odoo-bringout-oca-ocb-sale_loyalty_delivery>=16.0.0",
|
||||
"requests>=2.25.1"
|
||||
]
|
||||
readme = "README.md"
|
||||
requires-python = ">= 3.11"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Topic :: Office/Business",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
homepage = "https://github.com/bringout/0"
|
||||
repository = "https://github.com/bringout/0"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["website_sale_loyalty_delivery"]
|
||||
|
||||
[tool.rye]
|
||||
managed = true
|
||||
dev-dependencies = [
|
||||
"pytest>=8.4.1",
|
||||
]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import controllers
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': "Free Delivery with Coupon & Loyalty on eCommerce",
|
||||
'summary': """Allows to offer free shippings in loyalty program rewards on eCommerce""",
|
||||
'description': """Allows to offer free shippings in loyalty program rewards on eCommerce""",
|
||||
'category': 'Website/Website',
|
||||
'version': '1.0',
|
||||
'depends': ['website_sale_delivery', 'website_sale_loyalty', 'sale_loyalty_delivery'],
|
||||
'auto_install': True,
|
||||
'assets': {
|
||||
'web.assets_frontend': [
|
||||
'website_sale_loyalty_delivery/static/src/**/*',
|
||||
],
|
||||
'web.assets_tests': [
|
||||
'website_sale_loyalty_delivery/static/tests/**/*',
|
||||
],
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import main
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo import http
|
||||
from odoo.addons.payment import utils as payment_utils
|
||||
from odoo.addons.website_sale_delivery.controllers.main import WebsiteSaleDelivery
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class WebsiteSaleLoyaltyDelivery(WebsiteSaleDelivery):
|
||||
|
||||
@http.route()
|
||||
def update_eshop_carrier(self, **post):
|
||||
Monetary = request.env['ir.qweb.field.monetary']
|
||||
result = super().update_eshop_carrier(**post)
|
||||
order = request.website.sale_get_order()
|
||||
free_shipping_lines = None
|
||||
|
||||
if order:
|
||||
order._update_programs_and_rewards()
|
||||
order.validate_taxes_on_sales_order()
|
||||
free_shipping_lines = order._get_free_shipping_lines()
|
||||
|
||||
if free_shipping_lines:
|
||||
currency = order.currency_id
|
||||
if request.env.user.has_group('account.group_show_line_subtotals_tax_excluded'):
|
||||
amount_free_shipping = sum(free_shipping_lines.mapped('price_subtotal'))
|
||||
else:
|
||||
amount_free_shipping = sum(free_shipping_lines.mapped('price_total'))
|
||||
result.update({
|
||||
'new_amount_delivery_discounted': Monetary.value_to_html(order.amount_delivery + amount_free_shipping, {'display_currency': currency}),
|
||||
'new_amount_delivery_discount': Monetary.value_to_html(amount_free_shipping, {'display_currency': currency}),
|
||||
'new_amount_untaxed': Monetary.value_to_html(order.amount_untaxed, {'display_currency': currency}),
|
||||
'new_amount_tax': Monetary.value_to_html(order.amount_tax, {'display_currency': currency}),
|
||||
'new_amount_total': Monetary.value_to_html(order.amount_total, {'display_currency': currency}),
|
||||
'new_amount_order_discounted': Monetary.value_to_html(order.reward_amount - amount_free_shipping, {'display_currency': currency}),
|
||||
'new_amount_total_raw': order.amount_total,
|
||||
'delivery_discount_minor_amount': payment_utils.to_minor_currency_units(
|
||||
amount_free_shipping, currency
|
||||
),
|
||||
})
|
||||
return result
|
||||
|
||||
@http.route()
|
||||
def cart_carrier_rate_shipment(self, carrier_id, **kw):
|
||||
Monetary = request.env['ir.qweb.field.monetary']
|
||||
order = request.website.sale_get_order(force_create=True)
|
||||
free_shipping_lines = order._get_free_shipping_lines()
|
||||
# Avoid computing carrier price delivery is free (coupon). It means if
|
||||
# the carrier has error (eg 'delivery only for Belgium') it will show
|
||||
# Free until the user clicks on it.
|
||||
if free_shipping_lines:
|
||||
return {
|
||||
'carrier_id': carrier_id,
|
||||
'status': True,
|
||||
'is_free_delivery': True,
|
||||
'new_amount_delivery': Monetary.value_to_html(0.0, {'display_currency': order.currency_id}),
|
||||
'error_message': None,
|
||||
}
|
||||
return super().cart_carrier_rate_shipment(carrier_id, **kw)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-02-10 08:28+0000\n"
|
||||
"PO-Revision-Date: 2025-02-10 08:28+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import publicWidget from 'web.public.widget';
|
||||
|
||||
publicWidget.registry.websiteSaleDelivery.include({
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_handleCarrierUpdateResult: async function (result) {
|
||||
await this._super.apply(this, arguments);
|
||||
if (result.new_amount_delivery_discount) {
|
||||
// Update discount of the order
|
||||
const cart_summary_discount_line = document.querySelector('[data-reward-type="shipping"]')
|
||||
if (cart_summary_discount_line) {
|
||||
cart_summary_discount_line.innerHTML = result.new_amount_delivery_discount;
|
||||
}
|
||||
}
|
||||
if (result.new_amount_delivery_discounted) {
|
||||
// Update discount of the order
|
||||
$('#order_delivery .monetary_field').html(result.new_amount_delivery_discounted);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/** @odoo-module alias=website_sale_loyalty_giftcard.test **/
|
||||
|
||||
import tour from 'web_tour.tour';
|
||||
import wsTourUtils from "website_sale.tour_utils";
|
||||
|
||||
tour.register('shop_sale_loyalty_delivery', {
|
||||
test: true,
|
||||
url: '/shop?search=Accoustic',
|
||||
},
|
||||
[
|
||||
{
|
||||
content: "select Small Cabinet",
|
||||
trigger: '.oe_product a:contains("Acoustic Bloc Screens")',
|
||||
},
|
||||
{
|
||||
content: "add 1 Small Cabinet into cart",
|
||||
trigger: '#product_details input[name="add_qty"]',
|
||||
run: "text 1",
|
||||
},
|
||||
{
|
||||
content: "click on 'Add to Cart' button",
|
||||
trigger: "a:contains(ADD TO CART)",
|
||||
},
|
||||
wsTourUtils.goToCart(1),
|
||||
{
|
||||
content: "go to checkout",
|
||||
trigger: 'a[href="/shop/checkout?express=1"]',
|
||||
run: 'click'
|
||||
},
|
||||
{
|
||||
content: "select delivery method 1",
|
||||
trigger: "li label:contains(delivery1)",
|
||||
run: 'click'
|
||||
},
|
||||
{
|
||||
content: "click on 'Pay with gift card'",
|
||||
trigger: '.show_coupon',
|
||||
run: 'click'
|
||||
},
|
||||
{
|
||||
content: "Enter gift card code",
|
||||
trigger: "form[name='coupon_code'] input[name='promo']",
|
||||
run: 'text 123456'
|
||||
},
|
||||
{
|
||||
content: "click on 'Pay'",
|
||||
trigger: "a[role='button'].a-submit:contains(Apply)",
|
||||
run: 'click'
|
||||
},
|
||||
{
|
||||
content: "check if delivery price is correct'",
|
||||
trigger: "#order_delivery .oe_currency_value:contains(5.00)",
|
||||
run: () => {} // this is a check
|
||||
},
|
||||
{
|
||||
content: "check if total price is correct",
|
||||
trigger: "tr#order_total span.oe_currency_value:contains(0.00)",
|
||||
run: () => {} // this is a check
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
tour.register('check_shipping_discount', {
|
||||
test: true,
|
||||
url: '/shop?search=Plumbus',
|
||||
},
|
||||
[
|
||||
{
|
||||
content: "select Plumbus",
|
||||
trigger: '.oe_product a:contains("Plumbus")',
|
||||
},
|
||||
{
|
||||
content: "add 3 Plumbus into cart",
|
||||
trigger: '#product_details input[name="add_qty"]',
|
||||
run: "text 3",
|
||||
},
|
||||
{
|
||||
content: "click on 'Add to Cart' button",
|
||||
trigger: "a:contains(ADD TO CART)",
|
||||
},
|
||||
wsTourUtils.goToCart({quantity: 3}),
|
||||
{
|
||||
content: "go to checkout",
|
||||
trigger: 'a[href="/shop/checkout?express=1"]',
|
||||
run: 'click'
|
||||
},
|
||||
{
|
||||
content: "select delivery with rule",
|
||||
trigger: "li label:contains(rule)",
|
||||
run: 'click'
|
||||
},
|
||||
{
|
||||
content: "check if delivery price is correct'",
|
||||
trigger: 'label:contains("delivery with rule") + span.o_wsale_delivery_badge_price:contains(100.00)',
|
||||
run: () => {} // this is a check
|
||||
},
|
||||
{
|
||||
content: "check if delivery price is correct'",
|
||||
trigger: "#order_delivery .oe_currency_value:contains(25.00)",
|
||||
run: () => {} // this is a check
|
||||
},
|
||||
{
|
||||
content: "check if delivery price is correct'",
|
||||
trigger: "[data-reward-type='shipping']:contains(-75.00)",
|
||||
run: () => {} // this is a check
|
||||
},
|
||||
]
|
||||
);
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_website_sale_loyalty_delivery
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import Command
|
||||
|
||||
from odoo.tests.common import HttpCase
|
||||
from odoo.tests import tagged
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestWebsiteSaleDelivery(HttpCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.env.ref('base.user_admin').write({
|
||||
'name': 'Mitchell Admin',
|
||||
'street': '215 Vine St',
|
||||
'phone': '+1 555-555-5555',
|
||||
'city': 'Scranton',
|
||||
'zip': '18503',
|
||||
'country_id': self.env.ref('base.us').id,
|
||||
'state_id': self.env.ref('base.state_us_39').id,
|
||||
})
|
||||
|
||||
self.env['product.product'].create({
|
||||
'name': 'Acoustic Bloc Screens',
|
||||
'list_price': 2950.0,
|
||||
'website_published': True,
|
||||
})
|
||||
|
||||
self.gift_card = self.env['product.product'].create({
|
||||
'name': 'TEST - Gift Card',
|
||||
'list_price': 50,
|
||||
'type': 'service',
|
||||
'is_published': True,
|
||||
'sale_ok': True,
|
||||
'taxes_id': False,
|
||||
})
|
||||
|
||||
# Disable any other program
|
||||
self.env['loyalty.program'].search([]).write({'active': False})
|
||||
|
||||
self.gift_card_program = self.env['loyalty.program'].create({
|
||||
'name': 'Gift Cards',
|
||||
'program_type': 'gift_card',
|
||||
'applies_on': 'future',
|
||||
'trigger': 'auto',
|
||||
'rule_ids': [(0, 0, {
|
||||
'reward_point_amount': 1,
|
||||
'reward_point_mode': 'money',
|
||||
'reward_point_split': True,
|
||||
'product_ids': self.gift_card,
|
||||
})],
|
||||
'reward_ids': [(0, 0, {
|
||||
'reward_type': 'discount',
|
||||
'discount_mode': 'per_point',
|
||||
'discount': 1,
|
||||
'discount_applicability': 'order',
|
||||
'required_points': 1,
|
||||
'description': 'PAY WITH GIFT CARD',
|
||||
})],
|
||||
})
|
||||
|
||||
# Create a gift card to be used
|
||||
self.env['loyalty.card'].create({
|
||||
'program_id': self.gift_card_program.id,
|
||||
'points': 50000,
|
||||
'code': '123456',
|
||||
})
|
||||
|
||||
self.product_delivery_normal1 = self.env['product.product'].create({
|
||||
'name': 'Normal Delivery Charges',
|
||||
'invoice_policy': 'order',
|
||||
'type': 'service',
|
||||
})
|
||||
|
||||
self.product_delivery_normal2 = self.env['product.product'].create({
|
||||
'name': 'Normal Delivery Charges',
|
||||
'invoice_policy': 'order',
|
||||
'type': 'service',
|
||||
})
|
||||
|
||||
self.normal_delivery = self.env['delivery.carrier'].create({
|
||||
'name': 'delivery1',
|
||||
'fixed_price': 5,
|
||||
'delivery_type': 'fixed',
|
||||
'website_published': True,
|
||||
'product_id': self.product_delivery_normal1.id,
|
||||
})
|
||||
|
||||
self.normal_delivery2 = self.env['delivery.carrier'].create({
|
||||
'name': 'delivery2',
|
||||
'fixed_price': 10,
|
||||
'delivery_type': 'fixed',
|
||||
'website_published': True,
|
||||
'product_id': self.product_delivery_normal2.id,
|
||||
})
|
||||
|
||||
def test_shop_sale_gift_card_keep_delivery(self):
|
||||
# Get admin user and set his preferred shipping method to normal delivery
|
||||
# This test also tests that we can indeed pay delivery fees with gift cards/ewallet
|
||||
admin_user = self.env.ref('base.user_admin')
|
||||
admin_user.partner_id.write({'property_delivery_carrier_id': self.normal_delivery.id})
|
||||
|
||||
self.start_tour("/", 'shop_sale_loyalty_delivery', login='admin')
|
||||
|
||||
def test_shipping_discount(self):
|
||||
self.env['product.product'].create({
|
||||
'name': 'Plumbus',
|
||||
'list_price': 100.0,
|
||||
'website_published': True,
|
||||
})
|
||||
self.env['loyalty.program'].create({
|
||||
'name': 'Buy 3 get free shipping up to 75$',
|
||||
'program_type': 'promotion',
|
||||
'applies_on': 'current',
|
||||
'trigger': 'auto',
|
||||
'rule_ids': [(0, 0, {
|
||||
'minimum_amount': 300.0
|
||||
})],
|
||||
'reward_ids': [(0, 0, {
|
||||
'reward_type': 'shipping',
|
||||
'discount_max_amount': 75.0
|
||||
})],
|
||||
})
|
||||
product_paid_delivery = self.env['product.product'].create({
|
||||
'name': 'free shipping (Max 75$)',
|
||||
'invoice_policy': 'order',
|
||||
'type': 'service',
|
||||
})
|
||||
delivery_with_rule = self.env['delivery.carrier'].create({
|
||||
'name': 'delivery with rule',
|
||||
'delivery_type': 'base_on_rule',
|
||||
'price_rule_ids': [Command.create({
|
||||
'variable': 'quantity',
|
||||
'operator': '>=',
|
||||
'max_value': 3,
|
||||
'list_base_price': 100,
|
||||
})],
|
||||
|
||||
'website_published': True,
|
||||
'product_id': product_paid_delivery.id,
|
||||
})
|
||||
admin_user = self.env.ref('base.user_admin')
|
||||
admin_user.partner_id.write({'property_delivery_carrier_id': delivery_with_rule.id})
|
||||
self.start_tour("/", 'check_shipping_discount', login="admin")
|
||||
Loading…
Add table
Add a link
Reference in a new issue