diff --git a/setup/website_sale_loyalty_page/odoo/addons/website_sale_loyalty_page b/setup/website_sale_loyalty_page/odoo/addons/website_sale_loyalty_page new file mode 120000 index 000000000..892c946d3 --- /dev/null +++ b/setup/website_sale_loyalty_page/odoo/addons/website_sale_loyalty_page @@ -0,0 +1 @@ +../../../../website_sale_loyalty_page \ No newline at end of file diff --git a/setup/website_sale_loyalty_page/setup.py b/setup/website_sale_loyalty_page/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/website_sale_loyalty_page/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_sale_loyalty_page/README.rst b/website_sale_loyalty_page/README.rst new file mode 100644 index 000000000..80ab156bd --- /dev/null +++ b/website_sale_loyalty_page/README.rst @@ -0,0 +1,99 @@ +========================= +Website Sale Loyalty Page +========================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github + :target: https://github.com/OCA/sale-promotion/tree/16.0/website_sale_loyalty_page + :alt: OCA/sale-promotion +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-website_sale_loyalty_page + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/sale-promotion&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to publish promotions on Website using banners uploaded to each one. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To show the promotions/coupons on website you need to: + +#. Go to *Website > eCommerce > Loyalty > Discount & Loyalty*. +#. Select the program that we will publish. +#. In the Website tab, upload an image, add a text or both. +#. Press on the smart button for publishing the loyalty. + +**Note:** The order of the items is defined by a sequence, but the promotions will +appear before the coupons. + +Usage +===== + +When the promotions/coupons are published you can see the result at */promotions*. There +you will see all published items. + +To enlarge the image, just click it. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Pedro M. Baeza + * Carlos Roca + * Stefan Ungureanu + * Pilar Vargas + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/sale-promotion `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_loyalty_page/__init__.py b/website_sale_loyalty_page/__init__.py new file mode 100644 index 000000000..f7209b171 --- /dev/null +++ b/website_sale_loyalty_page/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import controllers diff --git a/website_sale_loyalty_page/__manifest__.py b/website_sale_loyalty_page/__manifest__.py new file mode 100644 index 000000000..d7ce9d0ee --- /dev/null +++ b/website_sale_loyalty_page/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2021 Tecnativa - Carlos Roca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Website Sale Loyalty Page", + "version": "16.0.1.0.0", + "category": "Website", + "website": "https://github.com/OCA/sale-promotion", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "LGPL-3", + "application": False, + "installable": True, + "depends": ["website_sale_loyalty"], + "data": [ + "views/sale_loyalty_program_views.xml", + "templates/promotion_templates.xml", + ], + "assets": { + "web.assets_tests": [ + "/website_sale_loyalty_page/static/src/js/website_sale_loyalty_page_portal.js", + ] + }, +} diff --git a/website_sale_loyalty_page/controllers/__init__.py b/website_sale_loyalty_page/controllers/__init__.py new file mode 100644 index 000000000..12a7e529b --- /dev/null +++ b/website_sale_loyalty_page/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/website_sale_loyalty_page/controllers/main.py b/website_sale_loyalty_page/controllers/main.py new file mode 100644 index 000000000..250cb95be --- /dev/null +++ b/website_sale_loyalty_page/controllers/main.py @@ -0,0 +1,31 @@ +# Copyright 2021 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import http +from odoo.http import request + + +class WebsiteSale(http.Controller): + @http.route(["""/promotions"""], type="http", auth="public", website=True) + def promotion(self, **post): + all_promos = ( + request.env["loyalty.program"] + .sudo() + .search( + [ + ("is_published", "=", True), + "|", + ("website_id", "=", False), + ("website_id", "=", request.env.context.get("website_id")), + ] + ) + ) + values = {"promos": []} + for promo in all_promos: + values["promos"].append( + { + "id": promo.id, + "image_1920": promo.image_1920, + "public_name": promo.public_name, + } + ) + return request.render("website_sale_loyalty_page.promotion_layout", values) diff --git a/website_sale_loyalty_page/i18n/es.po b/website_sale_loyalty_page/i18n/es.po new file mode 100644 index 000000000..a89500f84 --- /dev/null +++ b/website_sale_loyalty_page/i18n/es.po @@ -0,0 +1,108 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_loyalty_page +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-07-16 13:58+0000\n" +"PO-Revision-Date: 2021-07-16 15:59+0200\n" +"Last-Translator: Carlos \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.available_promotions +msgid "No promotions available" +msgstr "No hay promociones disponibles" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__can_publish +msgid "Can Publish" +msgstr "" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.promotion_item +msgid "Close" +msgstr "Cerrar" + +#. module: website_sale_loyalty_page +#: model:ir.model,name:website_sale_loyalty_page.model_coupon_program +msgid "Loyalty display on a website" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_1920 +msgid "Image" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_1024 +msgid "Image 1024" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_128 +msgid "Image 128" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_256 +msgid "Image 256" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_512 +msgid "Image 512" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__is_published +msgid "Is Published" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,help:website_sale_loyalty_page.field_coupon_program__public_name +msgid "Name of the promo showed on website bellow the banner image." +msgstr "" +"Nombre de la promoción mostrado en el sitio web debajo del la imagen " +"promocional." + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.promotion_layout +msgid "Promotions" +msgstr "Cupones y Promociones" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__public_name +msgid "Public Name" +msgstr "Nombre público" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,help:website_sale_loyalty_page.field_coupon_program__website_url +msgid "The full URL to access the document through the website." +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__website_published +msgid "Visible on current website" +msgstr "" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.coupon_program_view_form_common +msgid "Website" +msgstr "Sitio Web" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__website_url +msgid "Website URL" +msgstr "" + +#~ msgid "Sales Coupon Program" +#~ msgstr "Programa de cupones de ventas" diff --git a/website_sale_loyalty_page/i18n/website_sale_coupon_page.pot b/website_sale_loyalty_page/i18n/website_sale_coupon_page.pot new file mode 100644 index 000000000..15f6ce166 --- /dev/null +++ b/website_sale_loyalty_page/i18n/website_sale_coupon_page.pot @@ -0,0 +1,99 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_loyalty_page +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \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" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.available_promotions +msgid "No promotions available" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__can_publish +msgid "Can Publish" +msgstr "" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.promotion_item +msgid "Close" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model,name:website_sale_loyalty_page.model_coupon_program +msgid "Loyalty display on a website" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_1920 +msgid "Image" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_1024 +msgid "Image 1024" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_128 +msgid "Image 128" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_256 +msgid "Image 256" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__image_512 +msgid "Image 512" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__is_published +msgid "Is Published" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,help:website_sale_loyalty_page.field_coupon_program__public_name +msgid "Name of the promo showed on website bellow the banner image." +msgstr "" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.promotion_layout +msgid "Promotions" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__public_name +msgid "Public Name" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,help:website_sale_loyalty_page.field_coupon_program__website_url +msgid "The full URL to access the document through the website." +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__website_published +msgid "Visible on current website" +msgstr "" + +#. module: website_sale_loyalty_page +#: model_terms:ir.ui.view,arch_db:website_sale_loyalty_page.coupon_program_view_form_common +msgid "Website" +msgstr "" + +#. module: website_sale_loyalty_page +#: model:ir.model.fields,field_description:website_sale_loyalty_page.field_coupon_program__website_url +msgid "Website URL" +msgstr "" diff --git a/website_sale_loyalty_page/models/__init__.py b/website_sale_loyalty_page/models/__init__.py new file mode 100644 index 000000000..9afd49560 --- /dev/null +++ b/website_sale_loyalty_page/models/__init__.py @@ -0,0 +1 @@ +from . import loyalty_program diff --git a/website_sale_loyalty_page/models/loyalty_program.py b/website_sale_loyalty_page/models/loyalty_program.py new file mode 100644 index 000000000..aec187119 --- /dev/null +++ b/website_sale_loyalty_page/models/loyalty_program.py @@ -0,0 +1,14 @@ +# Copyright 2021 Tecnativa - Carlos Roca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class LoyaltyProgram(models.Model): + _name = "loyalty.program" + _inherit = ["loyalty.program", "image.mixin", "website.published.mixin"] + _description = "Loyalty display on a website" + + public_name = fields.Html( + help="Name of the promo showed on website bellow the banner image.", + ) diff --git a/website_sale_loyalty_page/readme/CONFIGURE.rst b/website_sale_loyalty_page/readme/CONFIGURE.rst new file mode 100644 index 000000000..1d0555cf7 --- /dev/null +++ b/website_sale_loyalty_page/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +To show the promotions/coupons on website you need to: + +#. Go to *Website > eCommerce > Loyalty > Discount & Loyalty*. +#. Select the program that we will publish. +#. In the Website tab, upload an image, add a text or both. +#. Press on the smart button for publishing the loyalty. + +**Note:** The order of the items is defined by a sequence, but the promotions will +appear before the coupons. diff --git a/website_sale_loyalty_page/readme/CONTRIBUTORS.rst b/website_sale_loyalty_page/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..94d722a53 --- /dev/null +++ b/website_sale_loyalty_page/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* `Tecnativa `_: + + * Pedro M. Baeza + * Carlos Roca + * Stefan Ungureanu + * Pilar Vargas diff --git a/website_sale_loyalty_page/readme/DESCRIPTION.rst b/website_sale_loyalty_page/readme/DESCRIPTION.rst new file mode 100644 index 000000000..2e40003eb --- /dev/null +++ b/website_sale_loyalty_page/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to publish promotions on Website using banners uploaded to each one. diff --git a/website_sale_loyalty_page/readme/USAGE.rst b/website_sale_loyalty_page/readme/USAGE.rst new file mode 100644 index 000000000..e668e7e25 --- /dev/null +++ b/website_sale_loyalty_page/readme/USAGE.rst @@ -0,0 +1,4 @@ +When the promotions/coupons are published you can see the result at */promotions*. There +you will see all published items. + +To enlarge the image, just click it. diff --git a/website_sale_loyalty_page/static/description/icon.png b/website_sale_loyalty_page/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/website_sale_loyalty_page/static/description/icon.png differ diff --git a/website_sale_loyalty_page/static/description/index.html b/website_sale_loyalty_page/static/description/index.html new file mode 100644 index 000000000..0135402ca --- /dev/null +++ b/website_sale_loyalty_page/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +Website Sale Loyalty Page + + + +
+

Website Sale Loyalty Page

+ + +

Beta License: LGPL-3 OCA/sale-promotion Translate me on Weblate Try me on Runboat

+

This module allows to publish promotions on Website using banners uploaded to each one.

+

Table of contents

+ +
+

Configuration

+

To show the promotions/coupons on website you need to:

+
    +
  1. Go to Website > eCommerce > Loyalty > Discount & Loyalty.
  2. +
  3. Select the program that we will publish.
  4. +
  5. In the Website tab, upload an image, add a text or both.
  6. +
  7. Press on the smart button for publishing the loyalty.
  8. +
+

Note: The order of the items is defined by a sequence, but the promotions will +appear before the coupons.

+
+
+

Usage

+

When the promotions/coupons are published you can see the result at /promotions. There +you will see all published items.

+

To enlarge the image, just click it.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Pedro M. Baeza
    • +
    • Carlos Roca
    • +
    • Stefan Ungureanu
    • +
    • Pilar Vargas
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/sale-promotion project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_sale_loyalty_page/static/src/js/website_sale_loyalty_page_portal.js b/website_sale_loyalty_page/static/src/js/website_sale_loyalty_page_portal.js new file mode 100644 index 000000000..368dec5e5 --- /dev/null +++ b/website_sale_loyalty_page/static/src/js/website_sale_loyalty_page_portal.js @@ -0,0 +1,31 @@ +/* Copyright 2020 Jairo Llopis - Tecnativa + * License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + +odoo.define("website_sale_loyalty_page.tour_portal", function (require) { + "use strict"; + + const tour = require("web_tour.tour"); + + tour.register( + "website_sale_loyalty_page_portal", + { + url: "/promotions", + test: true, + }, + [ + { + trigger: + ".card:has(.card-body:has(.card-text:contains('10% discount'))) .card-img-top", + }, + { + trigger: "button.btn-close", + extra_trigger: ".show:has(.modal-body:has(img))", + }, + { + trigger: "a[href='/shop']", + extra_trigger: + ".card:not(:has(.card-body:has(.card-text:contains('Promo not published'))))", + }, + ] + ); +}); diff --git a/website_sale_loyalty_page/static/src/scss/styles.scss b/website_sale_loyalty_page/static/src/scss/styles.scss new file mode 100644 index 000000000..144f77b5d --- /dev/null +++ b/website_sale_loyalty_page/static/src/scss/styles.scss @@ -0,0 +1,5 @@ +.promo-image { + display: flex; + justify-content: center; + align-items: center; +} diff --git a/website_sale_loyalty_page/templates/promotion_templates.xml b/website_sale_loyalty_page/templates/promotion_templates.xml new file mode 100644 index 000000000..86787cfab --- /dev/null +++ b/website_sale_loyalty_page/templates/promotion_templates.xml @@ -0,0 +1,80 @@ + + + + + + + + diff --git a/website_sale_loyalty_page/tests/__init__.py b/website_sale_loyalty_page/tests/__init__.py new file mode 100644 index 000000000..8cba17481 --- /dev/null +++ b/website_sale_loyalty_page/tests/__init__.py @@ -0,0 +1 @@ +from . import test_website_sale_loyalty_page diff --git a/website_sale_loyalty_page/tests/test_website_sale_loyalty_page.py b/website_sale_loyalty_page/tests/test_website_sale_loyalty_page.py new file mode 100644 index 000000000..6348ebf1d --- /dev/null +++ b/website_sale_loyalty_page/tests/test_website_sale_loyalty_page.py @@ -0,0 +1,45 @@ +# Copyright 2021 Tecnativa - Carlos Roca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 +import io + +from PIL import Image + +from odoo.tests import tagged +from odoo.tests.common import HttpCase + + +@tagged("post_install", "-at_install") +class WebsiteSaleHttpCase(HttpCase): + def setUp(self): + super().setUp() + # Creation of generic test banner + f = io.BytesIO() + Image.new("RGB", (800, 500), "#FF0000").save(f, "JPEG") + f.seek(0) + image = base64.b64encode(f.read()) + self.promo_published = self.env["loyalty.program"].create( + { + "program_type": "promotion", + "name": "Test 01", + "is_published": True, + "public_name": "

10% discount

", + "image_1920": image, + } + ) + self.promo_not_published = self.env["loyalty.program"].create( + { + "program_type": "promotion", + "name": "Test 02", + "is_published": False, + "public_name": "

Promo not published

", + "image_1920": image, + } + ) + + def test_ui(self): + self.start_tour( + "/promotions", + "website_sale_loyalty_page_portal", + login="portal", + ) diff --git a/website_sale_loyalty_page/views/sale_loyalty_program_views.xml b/website_sale_loyalty_page/views/sale_loyalty_program_views.xml new file mode 100644 index 000000000..69a7d7e71 --- /dev/null +++ b/website_sale_loyalty_page/views/sale_loyalty_program_views.xml @@ -0,0 +1,28 @@ + + + + loyalty.program + + + + + + + + + + + + + + + +