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

🎉 saas apps #100

Open
wants to merge 60 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
845b109
:tada: first commit
Enigma228322 Feb 22, 2020
b98976d
:bomb: developing process
Enigma228322 Feb 24, 2020
e3b5afa
:bomb: Added Manage Apps view in website configuration
Enigma228322 Feb 28, 2020
29848c6
:bomb: Added 'Refresh' button
Enigma228322 Feb 29, 2020
235ebc2
:bomb: started js low flexing
Enigma228322 Mar 2, 2020
40f02c3
:bomb: Added a little bit calculator logic
Enigma228322 Mar 3, 2020
e8dd2e8
:bomb: Added apps choosing logic
Enigma228322 Mar 3, 2020
58234c9
:bomb: Added price window
Enigma228322 Mar 3, 2020
9e61bae
:bomb: made beautiful price window
Enigma228322 Mar 6, 2020
eb2907d
:bomb: Added tree traversal in js and a little bit in python
Enigma228322 Mar 6, 2020
81e4d1e
:bomb: Added tree
Enigma228322 Mar 7, 2020
79c35c7
:bomb: Added child_tree and onload func in js
Enigma228322 Mar 13, 2020
3154109
:bomb: Made many2many instead one2many btw saas.lines and saas.module…
Enigma228322 Mar 17, 2020
f1a14e0
:bomb: Added pictures and fixied bug with :contains selector, when se…
Enigma228322 Mar 17, 2020
1440f2d
:bomb: shifted block with modules in center
Enigma228322 Mar 17, 2020
b0fa938
:bomb: Made frontend like pushka
Enigma228322 Mar 17, 2020
c47992f
:bomb: Changed allow_to_sell vars changing in overrided write functio…
Enigma228322 Mar 18, 2020
e776229
:bomb: Made access lvl public for not autorized users
Enigma228322 Mar 19, 2020
d1136db
:bomb: Added new template creating and redirecting to new db(Without …
Enigma228322 Mar 27, 2020
29911a7
:bomb: Added auto authorization
Enigma228322 Mar 28, 2020
337085a
:bomb: Added method that collects and sends all modules dependencies …
Enigma228322 Mar 29, 2020
d2aa52b
:bomb: Fixed bug with 'default' named modules
Enigma228322 Mar 29, 2020
787c8e1
:bomb: Now applications only is visible
Enigma228322 Mar 30, 2020
8147ade
:bomb: Added loader and indent corrections
Enigma228322 Mar 31, 2020
9b5d380
:green_heart:
Enigma228322 Mar 31, 2020
cfa5293
:bomb: Made fields editable
Enigma228322 Apr 2, 2020
5c64909
:bomb: temporary
Enigma228322 Apr 6, 2020
80673c3
:bomb: Corrected frontend
Enigma228322 Apr 6, 2020
0e1086b
:green_heart:
Enigma228322 Apr 7, 2020
b038cd6
:bomb: Added saas.line price changing
Enigma228322 Apr 7, 2020
009f9a1
:bomb: Added currency and fixed some bugs
Enigma228322 Apr 8, 2020
ea56bde
:bomb: Added currency linked to the company
Enigma228322 Apr 10, 2020
8419591
:bomb: now template doesn't creates every time, when build creates
Enigma228322 Apr 14, 2020
07f7d44
:bomb: Added 'set_as_base' field in saas_template and this field chec…
Enigma228322 Apr 15, 2020
fde507d
:bomb: added price blink in box, and divided apps price and users price
Enigma228322 Apr 20, 2020
b5ba13d
:bomb: added feature to integrate saas_apps with sign_up form
Enigma228322 Apr 21, 2020
77dfd5a
:bomb: Fixed error with same saas.template.operator name creation
Enigma228322 Apr 21, 2020
32dbf36
:bomb: added base_template record in demo data and docs
Enigma228322 Apr 21, 2020
992e60d
:bomb: Added loader in the begining and choosen_modules saving in loc…
Enigma228322 Apr 22, 2020
1085d17
:bomb: Changed 'Get Started' button, to 'Try trial' and 'Buy now'
Enigma228322 Apr 24, 2020
0a8c338
:bomb: Added packages
Enigma228322 May 2, 2020
1a757b0
:bomb: Added binary icons and corrected saas_apps form view
Enigma228322 May 7, 2020
c571c0c
:bomb: Deleted unnecessary method and added website_sale dependence
Enigma228322 May 8, 2020
e0b6343
:arrow_down::one::two:
Enigma228322 May 9, 2020
540cb72
:bomb: Added users changing buttons at /price page
Enigma228322 May 10, 2020
c2210a4
:bomb: Added apps and packages visibility properties in website settings
Enigma228322 May 11, 2020
838e4a6
:bomb: fixed bug, when price window is absent, values keep calculating
Enigma228322 May 11, 2020
e5fb5d5
:bomb: fixed bug, when saas_apps installs, theres an error with packa…
Enigma228322 May 12, 2020
b1f4710
:bomb: Changed saas_apps settings h2 body
Enigma228322 May 12, 2020
e7ecfcc
:base: Added app alingnment when they're less than 3
Enigma228322 May 12, 2020
e589d21
:book: Added show apps and show packs instr
Enigma228322 May 15, 2020
dd76550
:bomb: Now product.product 'website_published' field related to saas.…
Enigma228322 May 19, 2020
bd57266
:bomb: Changed product.product model relation to product.template
Enigma228322 May 20, 2020
da1e5db
:bomb: Fixed bug. When /price loads button listeners didnt initialize…
Enigma228322 May 20, 2020
47c2974
:bomb: Litle fix to avoid a huge error
Enigma228322 May 25, 2020
da04c05
:bomb: Fixed error, when saas template and package creates in the sam…
Enigma228322 May 26, 2020
0dbe77d
:bomb: Added show 'buy now' button option in settings
Enigma228322 May 28, 2020
37a8121
:bomb: Deleted unnecessary css classes
Enigma228322 Jun 1, 2020
a5b9676
:bomb: 'Try trial' and 'Buy now' are hiding when no application is se…
Enigma228322 Jun 1, 2020
2324ede
:bomb: Fixed bug when currency isn't visible when apps aren't selected
Enigma228322 Jun 1, 2020
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
49 changes: 49 additions & 0 deletions saas_apps/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3
Enigma228322 marked this conversation as resolved.
Show resolved Hide resolved

===========
Saas Apps
===========

Base module for manage modules in saas.

Module allows to choose modules that users gona use in their db.

Credits
=======

Contributors
------------
* `Vildan Safin <https://www.it-projects.info/team/Enigma228322>`__

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

To get a guaranteed support
you are kindly requested to purchase the module
at `odoo apps store <https://apps.odoo.com/apps/modules/12.0/saas_apps/>`__.

Thank you for understanding!

`IT-Projects Team <https://www.it-projects.info/team>`__

Further information
===================

Demo: http://runbot.it-projects.info/demo/odoo-saas-tools/12.0

HTML Description: https://apps.odoo.com/apps/modules/12.0/saas_apps/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Notifications on updates: `via Atom <https://github.com/it-projects-llc/odoo-saas-tools/commits/12.0/saas_apps.atom>`_, `by Email <https://blogtrottr.com/?subscribe=https://github.com/it-projects-llc/odoo-saas-tools/commits/12.0/saas_apps.atom>`_

Tested on Odoo 12.0 feb7c99f47cae55fff77035fe53975ea4a14d624
2 changes: 2 additions & 0 deletions saas_apps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import controllers, models
54 changes: 54 additions & 0 deletions saas_apps/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2020 Vildan Safin <https://www.it-projects.info/team/Enigma228322>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

{
"name": """SaaS Apps""",
"summary": """Choose your apps""",
"category": "Marketing",
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=12.0",
"images": ['/images/attention.jpg'],
"version": "12.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Vildan Safin",
"support": "apps@it-projects.info",
"website": "https://apps.odoo.com/apps/modules/12.0/saas_apps/",
"license": "AGPL-3",
# "price": 9.00,
# "currency": "EUR",

"depends": ['website', 'saas_public', 'website_sale'],
"external_dependencies": {"python": [], "bin": []},
"data": [
'security/ir.model.access.csv',
'views/calculator.xml',
'views/manage.xml',
"data/saas_base_template.xml",
"data/saas_apps_product_user.xml",
'views/assets.xml'
],
"demo": [
],
"qweb": [
'views/refresh.xml'
],

"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,

"auto_install": False,
"installable": True,

# "demo_title": "SaaS Apps",
# "demo_addons": [
# ],
# "demo_addons_hidden": [
# ],
# "demo_url": "DEMO-URL",
# "demo_summary": "short",
# "demo_images": [
# "images/MAIN_IMAGE",
# ]
}
2 changes: 2 additions & 0 deletions saas_apps/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import main
163 changes: 163 additions & 0 deletions saas_apps/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Copyright 2020 Vildan Safin <https://www.it-projects.info/team/Enigma228322>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo.http import route, request, Controller
from odoo.addons.saas_public.controllers.saas_public import SaaSPublicController
Enigma228322 marked this conversation as resolved.
Show resolved Hide resolved
from odoo.addons.website_sale.controllers.main import WebsiteSale
import urllib.parse

DB_TEMPLATE = 'template_database_'

class SaaSAppsController(Controller):


@route('/price', type='http', auth='public', website=True)
def user_page(self, **kw):
res = request.env['res.config.settings'].sudo().get_values()
apps = request.env['saas.line'].sudo()
packages = request.env['saas.template'].sudo()
if not apps.search_count([]):
apps.refresh_lines()
return request.render('saas_apps.Price', {
'apps': apps.search([('allow_to_sell', '=', True)]),
'packages': packages.search([('set_as_package', '=', True)]),
'show_apps': bool(res['show_apps']),
'show_packages': bool(res['show_packages']),
'show_buy_now_button':bool(res['show_buy_now_button'])
})

@route(['/refresh'], type='json', auth='public')
def catch_app_click(self, **kw):
apps = request.env['saas.line']
apps.refresh_lines()
return {}

@route(['/what_dependencies'], type='json', auth='public')
def search_incoming_app_dependencies(self, **kw):
app_tech_name = kw.get('root')
app = request.env['saas.line'].sudo().search([('name', '=', app_tech_name)])
return {
'dependencies': app.dependencies_info('root')
}

@route(['/check_currency'], type='json', auth='public')
def what_company_curency_to_use(self, **kw):
apps = request.env['saas.line'].sudo()
return {
'currency': apps.search([])[0].currency_id.display_name,
'symbol': apps.search([])[0].currency_id.symbol
}

@route(['/take_template_id'], type='json', auth='public')
def is_build_created(self, **kw):
package = kw.get('package')
templates = request.env['saas.template'].sudo()
# If package exist, use package saas_template
template = templates.search([('set_as_package', '=', True), ('name', '=', package)])
if not template:
# If package wasn't selected, use base saas_template
template = templates.search([('set_as_base', '=', True)])
if not template:
template, saas_template_operator = self.create_new_template()
return {
'id': template.id,
'state': 'creating'
}
if not template.operator_ids.random_ready_operator_check():
return {
'id': template.id,
'state': 'creating'
}
return {
'id': template.id,
'state': 'ready'
}

def create_new_template(self):
saas_template = request.env['saas.template'].sudo().create({
'name': 'Base',
'template_demo': True,
'public_access': True,
'set_as_base': True,
'template_module_ids': request.env['saas.module'].sudo().search([('name', '=', 'mail')]),
'build_post_init': "env['ir.module.module'].search([('name', 'in', {installing_modules})]).button_immediate_install()"
})
saas_operator = request.env.ref("saas.local_operator")
saas_template_operator = request.env['saas.template.operator'].sudo().create({
'template_id': saas_template.id,
'operator_id': saas_operator.id,
'operator_db_name': DB_TEMPLATE + str(saas_template.operator_ids.search_count([]) + 1),
})
saas_template_operator.sudo().preparing_template_next()
return saas_template, saas_template_operator

@route(['/price/take_product_ids'], type='json', auth='public')
def take_product_ids(self, **kw):
module_names = kw.get('module_names', [])
modules = request.env['saas.line'].sudo()
apps_product_ids = []
apps = modules.search([('name', 'in', module_names), ('application', '=', True)])
templates = request.env['saas.template'].sudo().search([('name', 'in', module_names)])
for app in apps.product_id + templates.product_id:
apps_product_ids.append(app.product_variant_id.id)

return {
'ids': apps_product_ids
}


class SaasAppsCart(WebsiteSale):


@route('/price/cart_update', type='json', auth='public', website=True)
def cart_update_price_page(self, **kw):
period = kw.get('period')
sale_order = request.website.sale_get_order(force_create=True)
product_ids = kw.get('old_apps_ids', [])
# Adding user as product in cart
user_product_tmp = request.env.ref("saas_apps.product_user").sudo()
user_product = user_product_tmp.product_variant_id
user_product.price = kw.get('user_price')
if not period == 'm':
user_product.price *= 12
old_user_cnt = 0
if kw.get('old_user_cnt'):
old_user_cnt = float(kw.get('old_user_cnt'))
user_cnt = float(kw.get('user_cnt'))
if not old_user_cnt:
old_user_cnt = 0
sale_order._cart_update(
product_id=int(user_product.id),
add_qty=(user_cnt - old_user_cnt)
)

# Delete old products from cart
for id in product_ids:
sale_order._cart_update(
product_id=int(id),
add_qty=-1
)

# Changing prices
product_ids = kw.get('product_ids', [])
pr_tmp = request.env['product.template'].sudo()
for id in product_ids:
product = pr_tmp.browse(id).product_variant_id
app = request.env['saas.line'].sudo().search([('module_name', '=', product.name)])
packages = request.env['saas.template'].sudo().search([('name', '=', product.name)])
if period == 'm':
app.change_product_price(app, app.month_price)
packages.change_product_price(packages, packages.month_price)
else:
app.change_product_price(app, app.year_price)
packages.change_product_price(packages, packages.year_price)

# Add new ones
for id in product_ids:
sale_order._cart_update(
product_id=int(id),
add_qty=1
)
return {
"link": "/shop/cart"
}
10 changes: 10 additions & 0 deletions saas_apps/data/saas_apps_product_user.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- Copyright 2020 Vildan Safin <https://www.it-projects.info/team/Enigma228322>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).-->
<odoo>
<record id="product_user" model="product.template">
<field name="name">User</field>
<field name="price">10</field>
<field name="website_published">True</field>
<field file="saas_apps/static/src/img/user.png" name="image_1920" type="base64" />
</record>
</odoo>
27 changes: 27 additions & 0 deletions saas_apps/data/saas_base_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Copyright 2020 Vildan Safin <https://www.it-projects.info/team/Enigma228322>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).-->
<odoo>
<record id="base_template" model="saas.template">
<field name="name">Base</field>
<field name="template_demo">True</field>
<field name="public_access">True</field>
<field name="set_as_base">True</field>
<field name="build_post_init">env['ir.module.module'].search([('name', 'in', {installing_modules})]).button_immediate_install()</field>
</record>
<record id="saas_base_template_operator" model="saas.template.operator">
<field name="operator_db_name">demo_template_database</field>
<field name="template_id" eval="ref('base_template')"/>
Copy link
Member

Choose a reason for hiding this comment

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

Тут можно было вместо eval="ref сделать просто ref="saas.base_template".

Ниже сделал также

<field name="operator_id" ref="saas.local_operator"/>
</record>

<record id="saas_apps_base_image" model="ir.attachment">
<field name="name">Application base icon</field>
<field name="datas_fname">base.png</field>
<field name="use_as_background">True</field>
<field
name="datas"
type="base64"
file="saas_apps/static/src/img/base.png"
/>
</record>
</odoo>
4 changes: 4 additions & 0 deletions saas_apps/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
`1.0.0`
-------

- **Init version**
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

42 changes: 42 additions & 0 deletions saas_apps/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
===========
Saas Apps
===========

Installation
============

* `Activate longpolling <https://odoo-development.readthedocs.io/en/latest/admin/longpolling.html>`__
*
* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way

Configuration
=============

* `Log in as SUPERUSER <https://odoo-development.readthedocs.io/en/latest/odoo/usage/login-as-superuser.html>`__
* `Activate Developer Mode <https://odoo-development.readthedocs.io/en/latest/odoo/usage/debug-mode.html>`__
* Open menu ``[[ Website ]] >> Configuration >> Manage Apps``
* Click ``[ Refresh ]``
* Choose modules that you want to make saleable by clicking to ``[ Saleable ]``

{Instruction for make apps and packages visible on ``Price`` page.}

* Open menu ``[[ Website ]] >> Configuration >> Settings >> SaaS pricing page``
* Click ``[[ Show packages ]]`` to show packages
* Click ``[[ Show apps ]]`` to show packages

Usage
=====

{Instruction for daily usage. It should describe how to check that module works. What shall user do and what would user get.}

* Open ``[http://odoo-saas.sh/]``
* Click ``[{Make new Odoo instance}]``
* Choose modules that you want to buy by on them
* Choose the using period year/month
* Click ``[Buy now]`` or ``[Try trial]``
* RESULT: you will be redirected and logged in to the created build with choosen modules

Uninstallation
==============

* Open menu ``[[ Apps ]] >> [[SaaS Apps]] >> Uninstall``
2 changes: 2 additions & 0 deletions saas_apps/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import saas_apps
Loading