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 '
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 @@