Skip to content

Commit

Permalink
Merge remote-tracking branch 'em230418/14.0-mig-website_sale_affiliat…
Browse files Browse the repository at this point in the history
…e' into 14.0
  • Loading branch information
em230418 committed Sep 11, 2024
2 parents ec0a281 + bcc3b0c commit 9b591a2
Show file tree
Hide file tree
Showing 98 changed files with 22,571 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/website_sale_affiliate/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
115 changes: 115 additions & 0 deletions website_sale_affiliate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
=================
Affiliate Program
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:23190d8c4c1e8fceddf5e8d03b8b4d96e2cda899540a9f3baff2ded30fadcf04
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/14.0/website_sale_affiliate
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-14-0/e-commerce-14-0-website_sale_affiliate
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows for the creation of affiliates and the tracking of
sales conversions generated by them.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you must first create at least one affiliate (found
in Website/Affiliate Program).

Once an affiliate has been created, append one of the following to a
compatible shop or product url (see below) to track the affiliate's
conversions:

- ?aff_ref=\ *affiliate_id*
- ?aff_ref=\ *affiliate_id*\ &aff_key=\ *custom_key*

The "affiliate_id" is the ID displayed on the affiliate's record, e.g.
"1".

The "custom_key" (optional) is a url-friendly string of your choice used
to track a specific campaign, e.g. "anniversary_sale". Associated
affiliate requests will be named after this key, if provided.

**Example:** /shop?aff_ref=1&aff_key=anniversary_sale

Compatible URLs
---------------

- /shop
- /shop/category/{category}
- /shop/category/{category}/page/{page}
- /shop/page/{page}
- /shop/product/{product}

Known issues / Roadmap
======================

- Evaluate usefulness of IP as a fallback affiliate request identifier

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_affiliate%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* LasLabs

Contributors
------------

- Brent Hughes <brent.hughes@laslabs.com>
- Dave Lasley <dave@laslabs.com>
- Eugene Molotov <molotov@it-projects.info>

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/e-commerce <https://github.com/OCA/e-commerce/tree/14.0/website_sale_affiliate>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions website_sale_affiliate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)

from . import controllers
from . import models
28 changes: 28 additions & 0 deletions website_sale_affiliate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)

{
"name": "Affiliate Program",
"summary": "Create an e-commerce affiliate program for the tracking of "
"referrals and conversions.",
"version": "14.0.1.0.0",
"category": "E-Commerce",
"website": "https://github.com/OCA/e-commerce",
"author": "LasLabs, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"depends": [
"website_sale",
],
"data": [
"data/sale_affiliate_data.xml",
"security/ir.model.access.csv",
"views/sale_affiliate_view.xml",
"views/sale_affiliate_request_view.xml",
"views/sale_order_view.xml",
],
"demo": [
"demo/sale_affiliate_demo.xml",
],
}
4 changes: 4 additions & 0 deletions website_sale_affiliate/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)

from . import main
32 changes: 32 additions & 0 deletions website_sale_affiliate/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)

from odoo.http import request, route

from odoo.addons.website_sale.controllers.main import WebsiteSale as Base


class WebsiteSale(Base):
def _store_affiliate_info(self, **kwargs):
Affiliate = request.env["sale.affiliate"]
affiliate = Affiliate.sudo().find_from_kwargs(**kwargs)
if not affiliate:
return

affiliate_request = affiliate.get_request(**kwargs)
if not affiliate_request:
return # pragma: no cover

request.session["affiliate_request"] = affiliate_request.id

@route()
def shop(self, *args, **post):
res = super(WebsiteSale, self).shop(*args, **post)
self._store_affiliate_info(**post)
return res

@route()
def product(self, *args, **kwargs):
res = super(WebsiteSale, self).product(*args, **kwargs)
self._store_affiliate_info(**kwargs)
return res
10 changes: 10 additions & 0 deletions website_sale_affiliate/data/sale_affiliate_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 LasLabs Inc.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo noupdate="1">
<record id="request_sequence" model="ir.sequence">
<field name="name">Affiliate Request Sequence</field>
<field name="padding">10</field>
<field name="number_next">1</field>
</record>
</odoo>
28 changes: 28 additions & 0 deletions website_sale_affiliate/demo/sale_affiliate_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 LasLabs Inc.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo noupdate="1">
<record id="sale_affiliate_myaffiliate" model="sale.affiliate">
<field name="name">MyAffiliate</field>
<field name="company_id" ref="base.main_company" />
<field name="valid_hours">24</field>
<field name="valid_sales">1</field>
</record>

<record id="sale_affiliate_request_firesale" model="sale.affiliate.request">
<field name="name">firesale</field>
<field name="affiliate_id" ref="sale_affiliate_myaffiliate" />
<field name="ip">0.0.0.0</field>
<field name="referrer">referrer</field>
<field name="user_agent">user agent</field>
<field name="accept_language">language</field>
</record>

<record id="sale.sale_order_1" model="sale.order">
<field name="affiliate_request_id" ref="sale_affiliate_request_firesale" />
</record>

<record id="sale.sale_order_2" model="sale.order">
<field name="affiliate_request_id" ref="sale_affiliate_request_firesale" />
</record>
</odoo>
Loading

0 comments on commit 9b591a2

Please sign in to comment.