Skip to content

Commit

Permalink
💣 developing process
Browse files Browse the repository at this point in the history
Signed-off-by: Vildan Safin <[email protected]>
  • Loading branch information
Enigma228322 committed Feb 25, 2020
1 parent 9dd511b commit 2d62ac3
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ coverage.xml
.mr.developer.cfg
.project
.pydevproject
.mrbob.ini

# Rope
.ropeproject
Expand Down
8 changes: 3 additions & 5 deletions saas_apps/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
Saas Apps
===========

short
Base module for manage modules in saas.

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

Credits
=======

Contributors
------------
* `saas apps <https://it-projects.info/team/saas-addons>`__:

* :one::zero: init version of the module
* `Vildan Safin <https://www.it-projects.info/team/Enigma228322>`__

Sponsors
--------
Expand Down
9 changes: 6 additions & 3 deletions saas_apps/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": """SaaS Apps""",
"summary": """short""",
"summary": """Choose your apps""",
"category": "Marketing",
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=12.0",
"images": [],
Expand All @@ -17,12 +17,15 @@
# "price": 9.00,
# "currency": "EUR",

"depends": [
],
"depends": ['website'],
"external_dependencies": {"python": [], "bin": []},
"data": [
'security/ir.model.access.csv',
'views/calculator.xml',
'views/assets.xml'
],
"demo": [
'demo/saas_demo.xml'
],
"qweb": [
],
Expand Down
11 changes: 7 additions & 4 deletions saas_apps/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo.http import route, request, Controller

from odoo import http

class SaaSAppsController(Controller):
@route('/price', type='http', auth='public')
def index(self, *kw):
return "shit"
@route('/price', auth='public', website=True)
def index(self, **kw):
apps = http.request.env['ir.module.module']
return http.request.render('saas_apps.index', {
'apps': apps.search([])
})
20 changes: 20 additions & 0 deletions saas_apps/demo/saas_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<record id="pos_ms" model="saas.lines">
<field name="module_name">POS Multi Session</field>
<field name="price">15</field>
</record>
<record id="durak" model="saas.lines">
<field name="module_name">POS Durak</field>
<field name="price">10</field>
</record>
<record id="chat" model="saas.lines">
<field name="module_name">POS Chat</field>
<field name="price">3</field>
</record>
<record id="welldone" model="saas.lines">
<field name="module_name">POS VILDAN</field>
<field name="price">228</field>
</record>
</odoo>
52 changes: 50 additions & 2 deletions saas_apps/models/saas_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,58 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
import logging

_logger = logging.getLogger(__name__)

class SAASApps(models.Model):
_name = 'saas.apps'
class SAASBasket(models.Model):
_name = 'saas.basket'
_description = 'Module for selecting applications'

users = fields.Integer(default=0)
module_sets_in_basket = fields.One2many('saas.set', 'basket', ondelete="cascade", delegate=True)
final_basket_price = fields.Float(default=0.0, compute='_compute_price', string="Price of the set")

def _compute_price(self):
for set in self.module_set_in_basket:
self.final_basket_price = self.final_basket_price + set.price


class SAASLine(models.Model):
_name = 'saas.lines'
_description = 'Model line'

module_name = fields.Char(default="default")
price = fields.Float(default=0.0)
icon_path = fields.Char(compute='_compute_path', string="icon path")
dependencies = fields.Many2one('saas.set', string="Module dependences")

def _compute_path(self):
self.icon_path = "/saas_apps/static/src/img/%s.png" % self.module_name

@api.constrains('price')
def _validate_price(self):
if self.price < 0:
raise ValidationError("Price can't be negative.")


class SAASDependence(models.Model):
_name = 'saas.set'
_description = 'Module with dependencies'

basket = fields.Many2one('saas.basket', string='Modules in basket')
modules = fields.One2many('saas.lines', 'dependencies', ondelete='cascade', delegate=True)
final_set_price = fields.Float(default=0.0, compute='_compute_price', string="Price of the set")

def add_dependence(self, new_module_name, new_module_price):
try:
self.modules.create({
'module_name': new_module_name,
'price': new_module_name_price,
})
except:
_logger.error("Can't add new item in dependencies of this module")

def _compute_price(self):
for module in self.modules:
self.final_set_price = self.final_set_price + module.price
4 changes: 4 additions & 0 deletions saas_apps/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_saas_basket,access_saas_basket,model_saas_basket,base.group_user,1,1,1,1
access_saas_lines,access_saas_lines,model_saas_lines,base.group_user,1,1,1,1
access_saas_set,access_saas_set,model_saas_set,base.group_user,1,1,1,1
9 changes: 9 additions & 0 deletions saas_apps/static/src/css/calculator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.main-control-pad{
margin-left: 15%;
width: auto;
}

.col-lg-12{
flex: 0 0 100%;
max-width: 100%;
}
Binary file added saas_apps/static/src/img/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions saas_apps/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<template id="assets_frontend" name="saas_styles" inherit_id="website.assets_frontend">
<xpath expr="." position="inside">
<link rel="stylesheet" type="text/scss" href="/saas_apps/static/src/css/calculator.css"/>
</xpath>
</template>
</odoo>
70 changes: 70 additions & 0 deletions saas_apps/views/calculator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2020 Vildan Safin <https://github.com/Enigma228322>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<template id="index">
<t t-call="website.layout">
<title>Apps</title>
<div class="row main-control-pad container">
<div class="col-sm-8">
<!-- Users qty -->
<h3 class="mt16 mb8">Choose the number of users</h3>
<div class="row" style="max-width: 30%">
<div class="col-sm">
<input class="openerp_enterprise_pricing_users form-control border text-right pr-2" min="1" id="users" type="number" style="max-width: 120px;" value="1"></input>
</div>
<div class="col-sm">
<label class="px-2 mr-1 mb-0 bg-200 border-top border-right border-bottom">Users</label>
</div>
<div class="col-sm">
<label>
<del class="text-700 ml-1 mr-2 openerp_enterprise_user_pricing_monthly d-none"><span class="openerp_enterprise_pricing_user_amount_monthly_full">15,00</span><span class="openerp_enterprise_pricing_currency">EUR</span></del>
<del class="text-700 ml-1 mr-2 openerp_enterprise_user_pricing_yearly"><span class="openerp_enterprise_pricing_user_amount_yearly_full">12,00</span><span class="openerp_enterprise_pricing_currency">EUR</span></del>
<b class="openerp_enterprise_user_pricing_monthly d-none">
<span class="openerp_enterprise_pricing_user_amount_monthly">12,50</span>;<span class="openerp_enterprise_pricing_currency">EUR</span><small class="fw_semibold">/user/month</small>
</b>
<b class="openerp_enterprise_user_pricing_yearly">
<span class="openerp_enterprise_pricing_user_amount_yearly">10,00</span>;<span class="openerp_enterprise_pricing_currency">EUR</span><small class="fw_semibold">/user/month</small>
</b>
</label>
</div>
</div>
<div class="col-12 col-md-8 col-lg-9">
<!-- App list -->
<h3 class="mt16 mb16">Choose your Apps</h3>
<div class="openerp_enterprise_pricing_step_body mb24">
<div class="form-row">
<t t-foreach="apps" t-as="app">
<p class="col-12 col-sm-6 col-lg-4 shadow p-3 bg-white rounded price-window"><t t-esc="app.name"/></p>
</t>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<!-- Price window -->
<div class="col-12 col-md-4 col-lg-3 mt16">
<span class="shadow p-3 mb-5 bg-white rounded price-window">
░░░░░▄▄▄▄▄░░░░▄██▄░░░░░░░░░░░░░
░░░░░▀████░▄███▀▀██▄▄░░░░░░░░░░
░░░░░░███████▀░▄▄░▀███▄░░░░░░░░
░░░░░░█████▀░▄████▄░▀███▄░░░░░░
░░░░▄███░Here█gonna█be▀███▄▄░░░
░░▄███▀░▄▄███an░window▄░░▀███▄░
▄███▀░▄████████▄▄███████▄▄░▀██▄
▀▀░░▄████████with█price████░░▀▀
░░░░████▀▀▀▀▀▀▀███▀▀▀▀▀▀▀██░░░░
░░░░████░██░██░███░██░██░██░░░░
░░░░████░▄▄░▄▄░███░██░██░██░░░░
░░░░████░▀▀░▀▀░███▄▄▄▄▄▄▄██░░░░
░░░░████░██░██░████████████░░░░
░░░▄████▄▄▄▄▄▄▄████████████▄░░░
░░░█████████████████████████░░░
░░░█████████████████████████░░░
</span>
</div>
</div>
</div>
</t>
</template>
</odoo>

0 comments on commit 2d62ac3

Please sign in to comment.