-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import oca_monetize | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ... | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
||
- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
--> | ||
|
||
- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ... |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () { | ||
return rpc.query({model: 'oca.monetize', method: 'has_valid_subscription'}).then(function(result) { | ||
if (result) { | ||
jQuery("#oca_monetize").remove() | ||
} | ||
}); | ||
}); | ||
|
||
return {}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</div> | ||
</t> | ||
</t> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_oca_monetize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Oops, something went wrong.