From 091dbcc4878e96aa77aa514b028cbe6495214678 Mon Sep 17 00:00:00 2001 From: Hiren Jungi Date: Mon, 5 Nov 2018 16:15:06 +0530 Subject: [PATCH 1/3] [ADD] Online delayed release support --- .../base_setup/models/res_config_settings.py | 2 +- addons/web/controllers/main.py | 51 +++++++++++++++---- addons/web/models/ir_http.py | 23 ++++++--- .../DialogRegisterContract.js | 7 +-- addons/web/static/src/js/chrome/web_client.js | 14 ++++- addons/web/static/src/xml/backend_theme.xml | 8 +++ 6 files changed, 83 insertions(+), 22 deletions(-) diff --git a/addons/base_setup/models/res_config_settings.py b/addons/base_setup/models/res_config_settings.py index 4a632fef..1ec28c9a 100644 --- a/addons/base_setup/models/res_config_settings.py +++ b/addons/base_setup/models/res_config_settings.py @@ -134,7 +134,7 @@ class ResConfigSettings(models.TransientModel): if self.activator_key and self.contract_id: try: set_param = self.env['ir.config_parameter'].sudo().set_param - binary = json.loads(base64.decodestring(self.activator_key)).encode('ascii') + binary = json.loads(base64.decodestring(self.activator_key).decode('utf-8')).encode('ascii') binary = base64.decodestring(binary) enc = json.dumps(decrypt(binary, self.contract_id)) if enc: diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index a374f0bc..9b168a7c 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1867,13 +1867,44 @@ class ReportController(http.Controller): class LicensingController(http.Controller): @http.route('/flectra/licensing', type='http', auth="user") - def download(self, binary='', **kwargs): - filename = '%s.%s' % (FILENAME, EXT) - content = binary - return request.make_response( - content, - headers=[ - ('Content-Type', 'plain/text' or 'application/octet-stream'), - ('Content-Disposition', content_disposition(filename)) - ] - ) + def download(self, contract_id=None, type=None, binary='', **kwargs): + if type == 'offline': + filename = '%s.%s' % (FILENAME, EXT) + content = binary + return request.make_response( + content, + headers=[ + ('Content-Type', 'plain/text' or 'application/octet-stream'), + ('Content-Disposition', content_disposition(filename)) + ] + ) + elif type == 'online': + error = { + 'code': 200, + 'message': "Invalid License Key", + 'data': '' + } + try: + if contract_id: + data = { + 'data': binary, + 'contract_id': contract_id + } + p = requests.post( + server_url + '/my/contract/validate/online', + params=data, + headers={'Content-type': 'plain/text' or 'application/octet-stream'}) + content = json.loads(p.content.decode('utf-8')) + if 'activation_key' in content: + date = datetime.datetime.now() + datetime.timedelta(days=(12 * 30 * 1)) + set_param = request.env['ir.config_parameter'].sudo().set_param + set_param('database.expiration_date', date) + set_param('contract.validity', + base64.encodestring( + encrypt(json.dumps(str(date)),str(date)))) + if 'error_in_key' in content: + return request.make_response(html_escape(json.dumps(error))) + except Exception as e: + error['code'] = 400 + error['message'] = 'Flectra Error!' + return request.make_response(html_escape(json.dumps(error))) \ No newline at end of file diff --git a/addons/web/models/ir_http.py b/addons/web/models/ir_http.py index 893b24c6..2a636eb8 100644 --- a/addons/web/models/ir_http.py +++ b/addons/web/models/ir_http.py @@ -61,17 +61,28 @@ class Http(models.AbstractModel): currencies = Currency.search([]).read(['symbol', 'position', 'decimal_places']) return { c['id']: {'symbol': c['symbol'], 'position': c['position'], 'digits': [69,c['decimal_places']]} for c in currencies} - def get_contracted_modules(self, contract_key='', ir_module_module_ids=None): + def get_contracted_modules(self, type=None, contract_key=None, ir_module_module_ids=None): if ir_module_module_ids: + contract_key = contract_key or '' contracted_module_list = ir_module_module_ids.mapped('name') - contracts = encrypt(json.dumps(contracted_module_list), contract_key) + warrant = self.env['publisher_warranty.contract'].sudo()._get_message() + warrant.update({ + 'contracts': contracted_module_list, + 'contract_id': contract_key + }) + if type != 'online': + contracts = encrypt(json.dumps(warrant), contract_key) + else: + contracts = str.encode(json.dumps(warrant)) return contracts @api.model - def contract_validate_file(self, contract_id): - ir_module_module_ids = self.env['ir.module.module'].sudo().search( - [('contract_certificate', '!=', False), ('state', '=', 'installed')]) - contracts = self.get_contracted_modules(contract_id,ir_module_module_ids) + def contract_validate_file(self, contract_id, type): + contracts = [] + if contract_id: + ir_module_module_ids = self.env['ir.module.module'].sudo().search( + [('contract_certificate', '!=', False), ('state', '=', 'installed')]) + contracts = self.get_contracted_modules(type, contract_id, ir_module_module_ids) return json.dumps(base64.encodestring(contracts).decode('ascii')) def check_validate_date(self, config): diff --git a/addons/web/static/src/js/backend_theme_customizer/DialogRegisterContract.js b/addons/web/static/src/js/backend_theme_customizer/DialogRegisterContract.js index dd855bd9..6cd22c82 100644 --- a/addons/web/static/src/js/backend_theme_customizer/DialogRegisterContract.js +++ b/addons/web/static/src/js/backend_theme_customizer/DialogRegisterContract.js @@ -24,15 +24,16 @@ flectra.define('FlectraLicensing.DialogRegisterContract', function (require) { save: function () { var contract_id = this.$el.find('#contract_id').val(); var self = this; - if (!contract_id) { + var type = this.$el.find("input[name='activate']:checked").val(); + if (!contract_id || !type) { return; } rpc.query({ model: 'ir.http', method: 'contract_validate_file', - args: [contract_id] + args: [contract_id,type] }).done(function (bin) { - self.trigger('get_key', {'key': contract_id, 'binary': bin}); + self.trigger('get_key', {'key': contract_id, 'binary': bin, 'type': type}); self.close(); }); } diff --git a/addons/web/static/src/js/chrome/web_client.js b/addons/web/static/src/js/chrome/web_client.js index bfa5b91d..9b550d96 100644 --- a/addons/web/static/src/js/chrome/web_client.js +++ b/addons/web/static/src/js/chrome/web_client.js @@ -244,7 +244,17 @@ return AbstractWebClient.extend({ session.get_file({ url: '/flectra/licensing', data: { - 'binary': key['binary'] + 'binary': key['binary'], + 'type': key['type'], + 'contract_id': key['key'] + }, + error: function (err) { + new require('web.Dialog').alert(null,err['message']); + }, + success:function () { + if (key['type'] === 'online') { + window.location.reload(); + } } }); }); @@ -291,7 +301,7 @@ return AbstractWebClient.extend({ overlayCSS: {cursor: 'auto'} }); self.contract_expired(); - }, 15000); + }, 150000); }, }); diff --git a/addons/web/static/src/xml/backend_theme.xml b/addons/web/static/src/xml/backend_theme.xml index 81ac3564..cae9c9cb 100755 --- a/addons/web/static/src/xml/backend_theme.xml +++ b/addons/web/static/src/xml/backend_theme.xml @@ -122,6 +122,14 @@
+
+ + +
From 4f7a4fd5330b7adc75744376c12b1e6d0524a5e6 Mon Sep 17 00:00:00 2001 From: Haresh Chavda Date: Tue, 20 Nov 2018 10:37:43 +0530 Subject: [PATCH 2/3] [IMP]:Issues-145, Issues-147 --- addons/account/__manifest__.py | 2 +- addons/analytic/__manifest__.py | 2 +- addons/base_branch_company/models/res_branch.py | 13 +++++++++++++ addons/crm/__manifest__.py | 1 + addons/project/__manifest__.py | 3 ++- addons/project_scrum/__manifest__.py | 2 +- addons/purchase/__manifest__.py | 2 +- addons/purchase_indent/__manifest__.py | 1 + addons/sale/__manifest__.py | 2 +- addons/sales_team/__manifest__.py | 2 +- addons/stock/__manifest__.py | 2 +- addons/stock/models/stock_location.py | 2 +- 12 files changed, 25 insertions(+), 9 deletions(-) diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index 541dbb35..11f9e78d 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -12,7 +12,7 @@ Core mechanisms for the accounting modules. To display the menuitems, install th 'category': 'Accounting', 'website': 'https://flectrahq.com/accounting', 'images' : ['images/accounts.jpeg','images/bank_statement.jpeg','images/cash_register.jpeg','images/chart_of_accounts.jpeg','images/customer_invoice.jpeg','images/journal_entries.jpeg'], - 'depends' : ['base_setup', 'product', 'analytic', 'web_planner', 'portal', 'digest'], + 'depends' : ['base_setup', 'product', 'analytic', 'web_planner', 'portal', 'digest', 'base_branch_company'], 'data': [ 'security/account_security.xml', 'security/ir.model.access.csv', diff --git a/addons/analytic/__manifest__.py b/addons/analytic/__manifest__.py index de8f232f..e81f0dd9 100644 --- a/addons/analytic/__manifest__.py +++ b/addons/analytic/__manifest__.py @@ -7,7 +7,7 @@ 'version': '1.1', 'website' : 'https://flectrahq.com/accounting', 'category': 'Hidden/Dependency', - 'depends' : ['base', 'decimal_precision', 'mail'], + 'depends' : ['base', 'decimal_precision', 'mail', 'base_branch_company'], 'description': """ Module for defining analytic accounting object. =============================================== diff --git a/addons/base_branch_company/models/res_branch.py b/addons/base_branch_company/models/res_branch.py index df6d6ca4..22cb3b62 100644 --- a/addons/base_branch_company/models/res_branch.py +++ b/addons/base_branch_company/models/res_branch.py @@ -92,6 +92,19 @@ class Users(models.Model): _inherit = "res.users" + @api.multi + def read(self, fields=None, load='_classic_read'): + result = super(Users, self).read(fields, load=load) + self.with_context({'check_branch': True}).check_missing_branch() + return result + + @api.multi + def check_missing_branch(self): + for user_id in self: + if self._context.get('check_branch', False) and user_id.company_id.branch_id and not user_id.default_branch_id: + user_id.default_branch_id = user_id.company_id.branch_id.id + user_id.branch_ids = [(4, user_id.company_id.branch_id.id)] + @api.model def branch_default_get(self, user): if not user: diff --git a/addons/crm/__manifest__.py b/addons/crm/__manifest__.py index d0958782..2b463c0c 100644 --- a/addons/crm/__manifest__.py +++ b/addons/crm/__manifest__.py @@ -22,6 +22,7 @@ 'web_tour', 'contacts', 'digest', + 'base_branch_company' ], 'data': [ 'security/crm_security.xml', diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index 744b496e..5593d0bf 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -19,7 +19,8 @@ 'web', 'web_planner', 'web_tour', - 'digest' + 'digest', + 'base_branch_company' ], 'description': "", 'data': [ diff --git a/addons/project_scrum/__manifest__.py b/addons/project_scrum/__manifest__.py index 4eee4b70..bca98bf2 100755 --- a/addons/project_scrum/__manifest__.py +++ b/addons/project_scrum/__manifest__.py @@ -9,7 +9,7 @@ 'sequence': 40, 'summary': 'A module for Scrum implementation', 'depends': [ - 'project', 'resource' + 'project', 'resource', 'base_branch_company' ], 'data': [ 'security/ir.model.access.csv', diff --git a/addons/purchase/__manifest__.py b/addons/purchase/__manifest__.py index 2fc282b9..b10816f4 100644 --- a/addons/purchase/__manifest__.py +++ b/addons/purchase/__manifest__.py @@ -10,7 +10,7 @@ 'summary': 'Purchase Orders, Receipts, Vendor Bills', 'description': "", 'website': 'https://flectrahq.com/purchase', - 'depends': ['stock_account'], + 'depends': ['stock_account', 'base_branch_company'], 'data': [ 'security/purchase_security.xml', 'security/ir.model.access.csv', diff --git a/addons/purchase_indent/__manifest__.py b/addons/purchase_indent/__manifest__.py index bbf67653..2bccade7 100644 --- a/addons/purchase_indent/__manifest__.py +++ b/addons/purchase_indent/__manifest__.py @@ -13,6 +13,7 @@ 'depends': [ 'purchase', 'purchase_requisition', + 'base_branch_company' ], 'data': [ 'security/ir.model.access.csv', diff --git a/addons/sale/__manifest__.py b/addons/sale/__manifest__.py index 6b67047d..d1cb5ea5 100644 --- a/addons/sale/__manifest__.py +++ b/addons/sale/__manifest__.py @@ -10,7 +10,7 @@ 'description': """ This module contains all the common features of Sales Management and eCommerce. """, - 'depends': ['sales_team', 'account', 'portal'], + 'depends': ['sales_team', 'account', 'portal', 'base_branch_company'], 'data': [ 'security/sale_security.xml', 'security/ir.model.access.csv', diff --git a/addons/sales_team/__manifest__.py b/addons/sales_team/__manifest__.py index e16b45c9..a71b0dc2 100644 --- a/addons/sales_team/__manifest__.py +++ b/addons/sales_team/__manifest__.py @@ -11,7 +11,7 @@ Using this application you can manage Sales Channels with CRM and/or Sales =========================================================================== """, 'website': 'https://flectrahq.com/page/crm', - 'depends': ['base', 'mail'], + 'depends': ['base', 'mail', 'base_branch_company'], 'data': ['security/sales_team_security.xml', 'security/ir.model.access.csv', 'data/sales_team_data.xml', diff --git a/addons/stock/__manifest__.py b/addons/stock/__manifest__.py index dee8cbe1..a5b03178 100644 --- a/addons/stock/__manifest__.py +++ b/addons/stock/__manifest__.py @@ -8,7 +8,7 @@ 'summary': 'Inventory, Logistics, Warehousing', 'description': "", 'website': 'https://flectrahq.com/page/warehouse', - 'depends': ['product', 'barcodes', 'web_planner'], + 'depends': ['product', 'barcodes', 'web_planner', 'base_branch_company'], 'category': 'Warehouse', 'sequence': 13, 'demo': [ diff --git a/addons/stock/models/stock_location.py b/addons/stock/models/stock_location.py index 6d45915a..86f9ff0a 100644 --- a/addons/stock/models/stock_location.py +++ b/addons/stock/models/stock_location.py @@ -135,7 +135,7 @@ class Location(models.Model): ('lot_stock_id', 'in', record.ids), ('wh_output_stock_loc_id', 'in', record.ids)]) for warehouse_id in warehouses_ids: - if record.branch_id and record.branch_id != warehouse_id.branch_id: + if record.branch_id and warehouse_id.branch_id and record.branch_id != warehouse_id.branch_id: raise ValidationError( _('Configuration Error of Branch:\n' 'The Location Branch (%s) and ' From 649abf961ed658e426b9f4173f17096a76431c8b Mon Sep 17 00:00:00 2001 From: Riddhi Kansara Date: Mon, 26 Nov 2018 16:57:23 +0530 Subject: [PATCH 3/3] [FIX]fix issue of set cover image for project module --- addons/project/views/project_views.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 7622d58b..9adc7977 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -333,7 +333,9 @@
- +
+ +