diff --git a/.gitignore b/.gitignore index d3799e6a6..4440a810d 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ coverage.xml .mr.developer.cfg .project .pydevproject +.mrbob.ini # Rope .ropeproject diff --git a/saas_apps/README.rst b/saas_apps/README.rst index 660002acc..95c401776 100644 --- a/saas_apps/README.rst +++ b/saas_apps/README.rst @@ -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 `__: - - * :one::zero: init version of the module +* `Vildan Safin `__ Sponsors -------- diff --git a/saas_apps/__manifest__.py b/saas_apps/__manifest__.py index 242bd9be6..235488b7a 100644 --- a/saas_apps/__manifest__.py +++ b/saas_apps/__manifest__.py @@ -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": [], @@ -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": [ ], diff --git a/saas_apps/controllers/main.py b/saas_apps/controllers/main.py index 0ddc65176..11a663ad7 100644 --- a/saas_apps/controllers/main.py +++ b/saas_apps/controllers/main.py @@ -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([]) + }) diff --git a/saas_apps/demo/saas_demo.xml b/saas_apps/demo/saas_demo.xml new file mode 100644 index 000000000..4a8b6fb7a --- /dev/null +++ b/saas_apps/demo/saas_demo.xml @@ -0,0 +1,20 @@ + + + + POS Multi Session + 15 + + + POS Durak + 10 + + + POS Chat + 3 + + + POS VILDAN + 228 + + \ No newline at end of file diff --git a/saas_apps/models/saas_apps.py b/saas_apps/models/saas_apps.py index ea644efb2..ea34a242f 100644 --- a/saas_apps/models/saas_apps.py +++ b/saas_apps/models/saas_apps.py @@ -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 diff --git a/saas_apps/security/ir.model.access.csv b/saas_apps/security/ir.model.access.csv new file mode 100644 index 000000000..7dde2b75b --- /dev/null +++ b/saas_apps/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/saas_apps/static/src/css/calculator.css b/saas_apps/static/src/css/calculator.css new file mode 100644 index 000000000..0efc03b36 --- /dev/null +++ b/saas_apps/static/src/css/calculator.css @@ -0,0 +1,9 @@ +.main-control-pad{ + margin-left: 15%; + width: auto; +} + +.col-lg-12{ + flex: 0 0 100%; + max-width: 100%; +} \ No newline at end of file diff --git a/saas_apps/static/src/img/default.png b/saas_apps/static/src/img/default.png new file mode 100644 index 000000000..abf1e5d8d Binary files /dev/null and b/saas_apps/static/src/img/default.png differ diff --git a/saas_apps/views/assets.xml b/saas_apps/views/assets.xml new file mode 100644 index 000000000..b28ad44f3 --- /dev/null +++ b/saas_apps/views/assets.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/saas_apps/views/calculator.xml b/saas_apps/views/calculator.xml new file mode 100644 index 000000000..20511552f --- /dev/null +++ b/saas_apps/views/calculator.xml @@ -0,0 +1,70 @@ + + + + +