Merge branch '1.0' into i18n_fr_stable

This commit is contained in:
Fabien BOURGEOIS 2018-11-27 09:15:53 +01:00
commit 3aa92f0ce8
19 changed files with 111 additions and 32 deletions

View File

@ -12,7 +12,7 @@ Core mechanisms for the accounting modules. To display the menuitems, install th
'category': 'Accounting', 'category': 'Accounting',
'website': 'https://flectrahq.com/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'], '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': [ 'data': [
'security/account_security.xml', 'security/account_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@ -7,7 +7,7 @@
'version': '1.1', 'version': '1.1',
'website' : 'https://flectrahq.com/accounting', 'website' : 'https://flectrahq.com/accounting',
'category': 'Hidden/Dependency', 'category': 'Hidden/Dependency',
'depends' : ['base', 'decimal_precision', 'mail'], 'depends' : ['base', 'decimal_precision', 'mail', 'base_branch_company'],
'description': """ 'description': """
Module for defining analytic accounting object. Module for defining analytic accounting object.
=============================================== ===============================================

View File

@ -92,6 +92,19 @@ class Users(models.Model):
_inherit = "res.users" _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 @api.model
def branch_default_get(self, user): def branch_default_get(self, user):
if not user: if not user:

View File

@ -134,7 +134,7 @@ class ResConfigSettings(models.TransientModel):
if self.activator_key and self.contract_id: if self.activator_key and self.contract_id:
try: try:
set_param = self.env['ir.config_parameter'].sudo().set_param 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) binary = base64.decodestring(binary)
enc = json.dumps(decrypt(binary, self.contract_id)) enc = json.dumps(decrypt(binary, self.contract_id))
if enc: if enc:

View File

@ -22,6 +22,7 @@
'web_tour', 'web_tour',
'contacts', 'contacts',
'digest', 'digest',
'base_branch_company'
], ],
'data': [ 'data': [
'security/crm_security.xml', 'security/crm_security.xml',

View File

@ -19,7 +19,8 @@
'web', 'web',
'web_planner', 'web_planner',
'web_tour', 'web_tour',
'digest' 'digest',
'base_branch_company'
], ],
'description': "", 'description': "",
'data': [ 'data': [

View File

@ -333,7 +333,9 @@
<a class="o_kanban_manage_toggle_button o_left" href="#" groups="project.group_project_manager"><i class="fa fa-ellipsis-v" /></a> <a class="o_kanban_manage_toggle_button o_left" href="#" groups="project.group_project_manager"><i class="fa fa-ellipsis-v" /></a>
<span class="o_right"><field name="is_favorite" widget="boolean_favorite" nolabel="1" force_save="1" /></span> <span class="o_right"><field name="is_favorite" widget="boolean_favorite" nolabel="1" force_save="1" /></span>
</div> </div>
<div t-if="record.displayed_image_id.value">
<field name="displayed_image_id" widget="attachment_image"/>
</div>
<div class="o_project_kanban_boxes"> <div class="o_project_kanban_boxes">
<a class="o_project_kanban_box" name="%(act_project_project_2_project_task_all)d" type="action"> <a class="o_project_kanban_box" name="%(act_project_project_2_project_task_all)d" type="action">
<div> <div>

View File

@ -9,7 +9,7 @@
'sequence': 40, 'sequence': 40,
'summary': 'A module for Scrum implementation', 'summary': 'A module for Scrum implementation',
'depends': [ 'depends': [
'project', 'resource' 'project', 'resource', 'base_branch_company'
], ],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@ -10,7 +10,7 @@
'summary': 'Purchase Orders, Receipts, Vendor Bills', 'summary': 'Purchase Orders, Receipts, Vendor Bills',
'description': "", 'description': "",
'website': 'https://flectrahq.com/purchase', 'website': 'https://flectrahq.com/purchase',
'depends': ['stock_account'], 'depends': ['stock_account', 'base_branch_company'],
'data': [ 'data': [
'security/purchase_security.xml', 'security/purchase_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@ -13,6 +13,7 @@
'depends': [ 'depends': [
'purchase', 'purchase',
'purchase_requisition', 'purchase_requisition',
'base_branch_company'
], ],
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@ -10,7 +10,7 @@
'description': """ 'description': """
This module contains all the common features of Sales Management and eCommerce. 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': [ 'data': [
'security/sale_security.xml', 'security/sale_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',

View File

@ -11,7 +11,7 @@ Using this application you can manage Sales Channels with CRM and/or Sales
=========================================================================== ===========================================================================
""", """,
'website': 'https://flectrahq.com/page/crm', 'website': 'https://flectrahq.com/page/crm',
'depends': ['base', 'mail'], 'depends': ['base', 'mail', 'base_branch_company'],
'data': ['security/sales_team_security.xml', 'data': ['security/sales_team_security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'data/sales_team_data.xml', 'data/sales_team_data.xml',

View File

@ -8,7 +8,7 @@
'summary': 'Inventory, Logistics, Warehousing', 'summary': 'Inventory, Logistics, Warehousing',
'description': "", 'description': "",
'website': 'https://flectrahq.com/page/warehouse', 'website': 'https://flectrahq.com/page/warehouse',
'depends': ['product', 'barcodes', 'web_planner'], 'depends': ['product', 'barcodes', 'web_planner', 'base_branch_company'],
'category': 'Warehouse', 'category': 'Warehouse',
'sequence': 13, 'sequence': 13,
'demo': [ 'demo': [

View File

@ -135,7 +135,7 @@ class Location(models.Model):
('lot_stock_id', 'in', record.ids), ('lot_stock_id', 'in', record.ids),
('wh_output_stock_loc_id', 'in', record.ids)]) ('wh_output_stock_loc_id', 'in', record.ids)])
for warehouse_id in warehouses_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( raise ValidationError(
_('Configuration Error of Branch:\n' _('Configuration Error of Branch:\n'
'The Location Branch (%s) and ' 'The Location Branch (%s) and '

View File

@ -1867,7 +1867,8 @@ class ReportController(http.Controller):
class LicensingController(http.Controller): class LicensingController(http.Controller):
@http.route('/flectra/licensing', type='http', auth="user") @http.route('/flectra/licensing', type='http', auth="user")
def download(self, binary='', **kwargs): def download(self, contract_id=None, type=None, binary='', **kwargs):
if type == 'offline':
filename = '%s.%s' % (FILENAME, EXT) filename = '%s.%s' % (FILENAME, EXT)
content = binary content = binary
return request.make_response( return request.make_response(
@ -1877,3 +1878,33 @@ class LicensingController(http.Controller):
('Content-Disposition', content_disposition(filename)) ('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)))

View File

@ -61,17 +61,28 @@ class Http(models.AbstractModel):
currencies = Currency.search([]).read(['symbol', 'position', 'decimal_places']) 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} 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: if ir_module_module_ids:
contract_key = contract_key or ''
contracted_module_list = ir_module_module_ids.mapped('name') 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 return contracts
@api.model @api.model
def contract_validate_file(self, contract_id): def contract_validate_file(self, contract_id, type):
contracts = []
if contract_id:
ir_module_module_ids = self.env['ir.module.module'].sudo().search( ir_module_module_ids = self.env['ir.module.module'].sudo().search(
[('contract_certificate', '!=', False), ('state', '=', 'installed')]) [('contract_certificate', '!=', False), ('state', '=', 'installed')])
contracts = self.get_contracted_modules(contract_id,ir_module_module_ids) contracts = self.get_contracted_modules(type, contract_id, ir_module_module_ids)
return json.dumps(base64.encodestring(contracts).decode('ascii')) return json.dumps(base64.encodestring(contracts).decode('ascii'))
def check_validate_date(self, config): def check_validate_date(self, config):

View File

@ -24,15 +24,16 @@ flectra.define('FlectraLicensing.DialogRegisterContract', function (require) {
save: function () { save: function () {
var contract_id = this.$el.find('#contract_id').val(); var contract_id = this.$el.find('#contract_id').val();
var self = this; var self = this;
if (!contract_id) { var type = this.$el.find("input[name='activate']:checked").val();
if (!contract_id || !type) {
return; return;
} }
rpc.query({ rpc.query({
model: 'ir.http', model: 'ir.http',
method: 'contract_validate_file', method: 'contract_validate_file',
args: [contract_id] args: [contract_id,type]
}).done(function (bin) { }).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(); self.close();
}); });
} }

View File

@ -244,7 +244,17 @@ return AbstractWebClient.extend({
session.get_file({ session.get_file({
url: '/flectra/licensing', url: '/flectra/licensing',
data: { 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'} overlayCSS: {cursor: 'auto'}
}); });
self.contract_expired(); self.contract_expired();
}, 15000); }, 150000);
}, },
}); });

View File

@ -122,6 +122,14 @@
<div t-name="FlectraLicense.dialog_contract_registration" > <div t-name="FlectraLicense.dialog_contract_registration" >
<div id="register_contract_form"> <div id="register_contract_form">
<div class="form-group"> <div class="form-group">
<div>
<label for="activate_online">
<input id="activate_online" type="radio" name="activate" value="online">Online</input>
</label>
<label for="activate_offline">
<input id="activate_offline" type="radio" name="activate" value="offline" checked="">Offline</input>
</label>
</div>
<label for="contract_id">Contract ID</label> <label for="contract_id">Contract ID</label>
<input type="text" class="form-control" id="contract_id" placeholder="Contract ID"/> <input type="text" class="form-control" id="contract_id" placeholder="Contract ID"/>
<input type="hidden" value=""/> <input type="hidden" value=""/>