-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
[ADD] oca_monetize #57
base: 14.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
**This file is going to be generated by oca-gen-addon-readme.** | ||
|
||
*Manual changes will be overwritten.* | ||
|
||
Please provide content in the ``readme`` directory: | ||
|
||
* **DESCRIPTION.rst** (required) | ||
* INSTALL.rst (optional) | ||
* CONFIGURE.rst (optional) | ||
* **USAGE.rst** (optional, highly recommended) | ||
* DEVELOP.rst (optional) | ||
* ROADMAP.rst (optional) | ||
* HISTORY.rst (optional, recommended) | ||
* **CONTRIBUTORS.rst** (optional, highly recommended) | ||
* CREDITS.rst (optional) | ||
|
||
Content of this README will also be drawn from the addon manifest, | ||
from keys such as name, authors, maintainers, development_status, | ||
and license. | ||
|
||
A good, one sentence summary in the manifest is also highly recommended. | ||
|
||
|
||
Automatic changelog generation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_. | ||
|
||
Just put towncrier compatible changelog fragments into `readme/newsfragments` | ||
and the changelog file will be automatically generated and updated when a new fragment is added. | ||
|
||
Please refer to `towncrier` documentation to know more. | ||
|
||
NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. | ||
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2024 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) | ||
|
||
{ | ||
"name": "OCA monetization", | ||
"summary": "Nag users of OCA modules to buy a subscription", | ||
"version": "14.0.1.0.0", | ||
"development_status": "Alpha", | ||
"category": "Uncategorized", | ||
"website": "https://github.com/OCA/oca-customize", | ||
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)", | ||
"maintainers": ["hbrunn"], | ||
"license": "AGPL-3", | ||
"preloadable": True, | ||
"depends": [ | ||
"web", | ||
"base_setup", | ||
], | ||
"data": [ | ||
"views/res_config_settings.xml", | ||
"views/templates.xml", | ||
], | ||
"qweb": [ | ||
"static/src/xml/oca_monetize.xml", | ||
], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import oca_monetize | ||
from . import res_config_settings |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2024 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) | ||
|
||
from datetime import date | ||
import json | ||
import base64 | ||
from odoo import api, fields, models, tools | ||
|
||
|
||
class OcaMonetize(models.AbstractModel): | ||
_name = "oca.monetize" | ||
|
||
@api.model | ||
def has_valid_subscription(self): | ||
# hello reader, you've found the spot where you can deactivate the | ||
# nagging for a subscription easily. | ||
# there's no way to detain you from doing so, but before going ahead | ||
# please consider the high value you get from oca, and that this | ||
# needs to be financed somehow. if there are too many people dodging | ||
# contributing, the whole thing collapses | ||
return bool(self._get_subscription()) | ||
|
||
@api.model | ||
def _get_subscription(self, enforce_valid=True): | ||
ResConfigSettings = self.env['res.config.settings'] | ||
try: | ||
name = self.env['ir.config_parameter'].sudo().get_param( | ||
ResConfigSettings._fields['oca_monetize_name'].config_parameter, '', | ||
) | ||
subscription = json.loads(base64.b64decode(self.env['ir.config_parameter'].sudo().get_param( | ||
ResConfigSettings._fields['oca_monetize_key'].config_parameter, '', | ||
))) | ||
subscription['version'] = tools.parse_version(subscription['version']) | ||
subscription['start_date'] = fields.Date.from_string(subscription['start_date']) | ||
subscription['end_date'] = fields.Date.from_string(subscription['end_date']) | ||
if not enforce_valid: | ||
return subscription | ||
if subscription['partner_name'] != name: | ||
return {} | ||
if subscription['start_date'] >= date.today() or subscription['end_date'] <= date.today(): | ||
return {} | ||
return subscription | ||
except: | ||
|
||
return {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class OcaMonetize(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
oca_monetize_name = fields.Char('Partner Name', config_parameter='oca_monetize.name') | ||
oca_monetize_key = fields.Char('Subscription Key', config_parameter='oca_monetize.key') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- | ||
Audience: users that will configure Odoo to make this module work. | ||
|
||
Purpose: help them configure Odoo appropriately. | ||
|
||
⚠️ Cautions: | ||
|
||
- Do not assume the user knows how to find the menus. Guide them there. | ||
|
||
⛔ REMOVE THIS FILE if the module works out of the box and there is nothing to configure. | ||
--> | ||
|
||
To configure this module, you need to: | ||
|
||
1. Go to ... | ||
|
||
 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- | ||
Audience: end users. | ||
|
||
Purpose: help them evaluate if this module is useful in their context: | ||
|
||
- Why this module exists. | ||
- Business requirement that generated the need to develop this module. | ||
- Point to other related modules. | ||
- Explain how those other modules can complement this one. | ||
--> | ||
|
||
This module was developed because ... | ||
|
||
It will be useful for you if ... | ||
|
||
If you need this module for those reasons, these might interest you too: | ||
|
||
- ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!-- | ||
Audience: Everybody. | ||
|
||
Purpose: Credit whoever participated in the module development. | ||
--> | ||
|
||
- Firstname Lastname \<[email protected]> (optional company website url) | ||
- Second Person \<[email protected]> (optional company website url) | ||
- Moduon Employee ([Moduon](https://www.moduon.team/)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
Audience: everybody. | ||
|
||
Purpose: thank financial contributors. | ||
|
||
⚠️ Cautions: | ||
|
||
- DO NOT include contributors. These go into ./CONTRIBUTORS.rst. | ||
- DO NOT include authors. These go in the "author" key in ../__manifest__.py. | ||
- DO NOT include maintainers. These go in the "maintainers" key in ../__manifest__.py. | ||
- Only include other companies or persons that have financed the development | ||
of this module. Maybe through direct funding, crowdfunding, etc. | ||
|
||
⛔ REMOVE THIS FILE if there are no other financial supporters. | ||
--> | ||
|
||
The development of this module has been financially supported by: | ||
|
||
- Company 1 name | ||
- Company 2 name |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- | ||
Audience: people considering if they need this module. | ||
|
||
Purpose: help them know if this is the module they need. | ||
|
||
⚠️ Cautions: | ||
|
||
- This file IS REQUIRED. | ||
- Explain *why* this module exists. | ||
- Be short. Max: 2-3 paragraphs. | ||
--> | ||
|
||
This module extends the functionality of ... to support ... and to allow you to ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- | ||
Audience: Odoo users and integrators. | ||
|
||
Purpose: help them know what changed in this module over time. | ||
|
||
⚠️ Cautions: | ||
|
||
- DO NOT include purely technical changes such as code refactoring. | ||
- This file may contain ONE level of section titles, underlined | ||
with the ~ (tilde) character. Other section markers are | ||
forbidden and will likely break the structure of the README.rst | ||
or other documents where this fragment is included. | ||
|
||
⛔ REMOVE THIS FILE if you won't maintain this file updated. It is better to | ||
have no changelog than to have it unmaintained. In such case, you probably | ||
want to remove ./newsfragments/ too. | ||
--> | ||
|
||
## 11.0.x.y.z (YYYY-MM-DD) | ||
|
||
- [BREAKING] Breaking changes come first. | ||
([#70](https://github.com/OCA/repo/issues/70)) | ||
- [ADD] New feature. ([#74](https://github.com/OCA/repo/issues/74)) | ||
- [FIX] Correct this. ([#71](https://github.com/OCA/repo/issues/71)) | ||
|
||
## 11.0.x.y.z (YYYY-MM-DD) | ||
|
||
- ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- | ||
Audience: system administrators. | ||
|
||
Purpose: help them provide this module's technical requirements. | ||
|
||
⚠️ Cautions: | ||
|
||
- DO NOT specify Python or Odoo dependencies. These are specified in | ||
../__manifest__.py and Odoo will raise an error automatically with a | ||
specific message if one of these is missing. | ||
|
||
⛔ REMOVE THIS FILE if there are no special installation instructions. | ||
--> | ||
|
||
To install this module, you need to: | ||
|
||
1. Do this ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- | ||
Audience: end users, contributors, maintainers. | ||
|
||
Purpose: let them know limitations or potential future improvements. | ||
|
||
⚠️ Cautions: | ||
|
||
- Enumerate known caveats and future potential improvements. | ||
- Help potential new contributors discover new features to implement. | ||
|
||
⛔ REMOVE THIS FILE if the module is feature-complete or has no known issues. | ||
--> | ||
|
||
- ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- | ||
Audience: end users, functional reviewers. | ||
|
||
Purpose: help them use this module. | ||
|
||
⚠️ Cautions: | ||
|
||
- Required section. | ||
|
||
- This section implies that somebody (maybe another user with more privileges) | ||
already followed any instructions in ./CONFIGURE.rst. | ||
|
||
- Guide the user, step by step, to see the module effect in Odoo. | ||
|
||
- DO NOT ASSUME that the user knows where to find stuff or technical terms. | ||
|
||
Bad example: | ||
#. Create a new partner. | ||
|
||
Good example: | ||
#. Go to the "Contacts" app. | ||
#. Create a new contact. | ||
|
||
- IT MUST NOT contain reStructuredText sections, only body text (paragraphs, lists, | ||
tables, etc). | ||
|
||
If you need a more elaborate structure to explain the addon, please create a | ||
Sphinx documentation (which may include this file as a "quick start" section). | ||
--> | ||
|
||
To use this module, you need to: | ||
|
||
1. Go to ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* Copyright 2024 Hunki Enterprises BV | ||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) */ | ||
|
||
odoo.define("oca_monetize", function (require) { | ||
"use strict"; | ||
|
||
var core = require("web.core"); | ||
var rpc = require("web.rpc"); | ||
|
||
core.bus.on("web_client_ready", null, function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a warning appearing for all users, perpetually, is perhaps too much nag for people to live with on a daily basis. CEO's will complain that their users get confused by it, it takes space on the screen, etc. I think the message should be:
What I thought really sympathetic and what made me pay is how the creator of KeePass for Android pops up a message after each Oktoberfest has passed, asking to buy him a beer at the Octoberfest if you like the app. If you don't like the app enough, by all means don't do it. This serves to not annoy people, eg you can easily click the message away, but even a yearly reminder serves already the purpose of making people aware that there is a team of volunteers behind this that created a specific value for you, and explains you how you can contribute. That's already a win compared to the current situation of most people being completely unaware. |
||
return rpc.query({model: 'oca.monetize', method: 'has_valid_subscription'}).then(function(result) { | ||
if (result) { | ||
jQuery("#oca_monetize").remove() | ||
} | ||
}); | ||
}); | ||
|
||
return {}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 Hunki Enterprises BV | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) --> | ||
<template> | ||
<t t-extend="Menu"> | ||
<t t-jquery=".o_main_navbar" t-operation="before"> | ||
<div class="alert-danger p-4" id="oca_monetize"> | ||
You have installed modules whose authors requested that you <a href="link to subscription product on shop">buy</a> an <a href="link explaining the whole thing">OCA subscription</a> | ||
If you already have a subscription key, please fill it in the <a href="">settings</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this could be a text that a scheduled action regularly refreshes from an online source, in order to keep it up to date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If i remember right the "call to action" from Wikipedia (and others) usually also contains different options for support that try to resemble the grade of utility to the user. That leads from small amounts (one time) to regular contributions. I don't know how something like that would be perceived among contributors / OCA members, but i would prefer a system that is able to differentiate the link to the "subscription product" according to the overall share of the OCA code base use in the concrete installation (and dependent on oca_monetize) as well as the number of users on the DB. As both maybe conceived as sensitive data and and GDPR issue after all, we might want to let the end user control what he is actually sending to the OCA to have his fair subscription package link generated. |
||
</div> | ||
</t> | ||
</t> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_oca_monetize |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2024 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) | ||
|
||
from datetime import date | ||
import base64 | ||
import json | ||
from odoo import fields | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestOcaMonetize(TransactionCase): | ||
def test_subscription(self): | ||
"""First line of docstring appears in test logs. | ||
|
||
Other lines do not. | ||
|
||
Any method starting with ``test_`` will be tested. | ||
""" | ||
self.assertFalse(self.env['oca.monetize']._get_subscription()) | ||
self.env['ir.config_parameter'].set_param( | ||
'oca_monetize.name', 'Hunki Enterprises BV', | ||
) | ||
version = '1.0' | ||
partner_name = "Hunki Enterprises BV" | ||
start_date = fields.Datetime.to_string(date.today().replace(month=1, day=1)) | ||
end_date = fields.Datetime.to_string(date.today().replace(month=12, day=31)) | ||
subscription = dict(version=version, start_date=start_date, end_date=end_date, partner_name=partner_name) | ||
self.env['ir.config_parameter'].set_param( | ||
'oca_monetize.key', base64.b64encode((json.dumps(subscription)).encode('utf8')).decode('utf8'), | ||
) | ||
self.assertTrue(self.env['oca.monetize']._get_subscription()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and if that's the approach, I'd rather call this
oca_information
- inform people about what OCA is and in what ways they are able to pay