Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11.0 mig website sale affiliate #232

Closed
Closed
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
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 <brent.hughes@laslabs.com>
* Darko Nikolovski <darko@versada.eu>

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": "This module allows creation of affiliates and "
"tracking the sales conversions generated by them.",
"version": "11.0.1.0.0",
"category": "Website",
"website": "https://laslabs.com",
"author": "LasLabs, Odoo Community Association (OCA), Versada",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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
30 changes: 30 additions & 0 deletions website_sale_affiliate/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2017 LasLabs Inc.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)

from odoo.addons.website_sale.controllers.main import WebsiteSale as Base
from odoo.http import request, route


class WebsiteSale(Base):
def _store_affiliate_info(self, **kwargs):
Affiliate = request.env['sale.affiliate']
affiliate = Affiliate.sudo().find_from_kwargs(**kwargs)
try:
affiliate_request = affiliate.get_request(**kwargs)
request.session['affiliate_request'] = affiliate_request.id
except (AttributeError, ValueError):
pass

@route()
def shop(self, page=0, category=None, search='', ppg=False, **post):
res = super(WebsiteSale, self).shop(page, category,
search, ppg, **post)
self._store_affiliate_info(**post)
return res

@route()
def product(self, product, category='', search='', **kwargs):
res = super(WebsiteSale, self).product(product, category='',
search='', **kwargs)
self._store_affiliate_info(**kwargs)
return res
11 changes: 11 additions & 0 deletions website_sale_affiliate/data/sale_affiliate_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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>
29 changes: 29 additions & 0 deletions website_sale_affiliate/demo/sale_affiliate_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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>
<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>
<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