Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
language: fail
files: '[a-zA-Z0-9_]*/i18n/en\.po$'
- repo: https://github.com/oca/maintainer-tools
rev: d5fab7ee87fceee858a3d01048c78a548974d935
rev: b89f767503be6ab2b11e4f50a7557cb20066e667
hooks:
# update the NOT INSTALLABLE ADDONS section above
- id: oca-update-pre-commit-excluded-addons
Expand All @@ -54,14 +54,14 @@ repos:
- --if-source-changed
- --keep-source-digest
- repo: https://github.com/OCA/odoo-pre-commit-hooks
rev: v0.0.25
rev: v0.1.1
hooks:
- id: oca-checks-odoo-module
- id: oca-checks-po
args:
- --disable=po-pretty-format
- repo: https://github.com/myint/autoflake
rev: v1.6.1
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand All @@ -72,7 +72,7 @@ repos:
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/psf/black
rev: 22.8.0
rev: 25.1.0
hooks:
- id: black
- repo: local
Expand Down Expand Up @@ -127,7 +127,7 @@ repos:
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
rev: v3.19.1
hooks:
- id: pyupgrade
args: ["--keep-percent-format"]
Expand All @@ -140,7 +140,7 @@ repos:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.1.8
rev: "3.3"
hooks:
- id: setuptools-odoo-make-default
- id: setuptools-odoo-get-requirements
Expand All @@ -150,13 +150,13 @@ repos:
- --header
- "# generated from manifests external_dependencies"
- repo: https://github.com/PyCQA/flake8
rev: 5.0.0
rev: 7.1.2
hooks:
- id: flake8
name: flake8
additional_dependencies: ["flake8-bugbear==21.9.2"]
- repo: https://github.com/OCA/pylint-odoo
rev: v8.0.19
rev: v9.3.2
hooks:
- id: pylint_odoo
name: pylint with optional checks
Expand Down
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,
)
82 changes: 82 additions & 0 deletions website_sale_affiliate/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3

=================
Affiliate Program
=================

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

Usage
=====

To use this module, you must first create at least one affiliate (found in Sales/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}

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/113/10.0

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 smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

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

* Brent Hughes <[email protected]>
* Dave Lasley <[email protected]>

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

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
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": "16.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
34 changes: 34 additions & 0 deletions website_sale_affiliate/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)
import logging

from odoo.http import request, route

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

_logger = logging.getLogger(__name__)


class WebsiteSale(Base):
def _store_affiliate_info(self, **kwargs):
affiliate = request.env["sale.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().shop(*args, **post)
self._store_affiliate_info(**post)
return res

@route()
def product(self, *args, **post):
res = super().product(*args, **post)
self._store_affiliate_info(**post)
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