36 changed files with 4107 additions and 4053 deletions
@ -1,3 +1,22 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
from . import controllers |
from . import controllers |
@ -1,2 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
from . import move_line |
from . import move_line |
||||
from . import account_account_custom |
from . import account_account_custom |
||||
|
@ -1,19 +1,38 @@ |
|||||
from odoo import api, models, _ |
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, models |
||||
|
|
||||
|
|
||||
class PartnerAgeing(models.AbstractModel): |
class PartnerAgeing(models.AbstractModel): |
||||
_name = 'report.dynamic_accounts_report.partner_ageing' |
_name = 'report.dynamic_accounts_report.partner_ageing' |
||||
|
|
||||
@api.model |
@api.model |
||||
def _get_report_values(self, docids, data=None): |
def _get_report_values(self,docids, data=None): |
||||
|
print(data) |
||||
if self.env.context.get('ageing_pdf_report'): |
if self.env.context.get('ageing_pdf_report'): |
||||
|
|
||||
if data.get('report_data'): |
if data.get('report_data'): |
||||
data.update( |
data.update( |
||||
{'account_data': data.get('report_data')['report_lines'][0], |
{'account_data': data.get('report_data')['report_lines'][0], |
||||
'Filters': data.get('report_data')['filters'], |
'Filters': data.get('report_data')['filters'], |
||||
'company': self.env.company, |
'company': self.env.company, |
||||
|
|
||||
}) |
}) |
||||
|
|
||||
return data |
return data |
||||
|
@ -1,18 +1,42 @@ |
|||||
from odoo import api, models, _ |
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from odoo import api, models |
||||
|
|
||||
|
|
||||
class TrialBalance(models.AbstractModel): |
class TrialBalance(models.AbstractModel): |
||||
_name = 'report.dynamic_accounts_report.trial_balance' |
_name = 'report.dynamic_accounts_report.trial_balance' |
||||
|
|
||||
@api.model |
@api.model |
||||
def _get_report_values(self, docids, data=None): |
def _get_report_values(self,docids, data=None): |
||||
if self.env.context.get('trial_pdf_report'): |
if self.env.context.get('trial_pdf_report'): |
||||
|
|
||||
if data.get('report_data'): |
if data.get('report_data'): |
||||
data.update({'account_data': data.get('report_data')['report_lines'], |
data.update({'account_data': data.get('report_data' |
||||
|
)['report_lines'], |
||||
'Filters': data.get('report_data')['filters'], |
'Filters': data.get('report_data')['filters'], |
||||
'debit_total': data.get('report_data')['debit_total'], |
'debit_total': data.get('report_data' |
||||
'credit_total': data.get('report_data')['credit_total'], |
)['debit_total'], |
||||
|
'credit_total': data.get('report_data' |
||||
|
)['credit_total'], |
||||
'company': self.env.company, |
'company': self.env.company, |
||||
}) |
}) |
||||
return data |
return data |
||||
|
@ -1,438 +1,432 @@ |
|||||
odoo.define('dynamic_accounts_report.ageing', function (require) { |
odoo.define('dynamic_accounts_report.ageing', function(require) { |
||||
'use strict'; |
'use strict'; |
||||
var AbstractAction = require('web.AbstractAction'); |
var AbstractAction = require('web.AbstractAction'); |
||||
var core = require('web.core'); |
var core = require('web.core'); |
||||
var field_utils = require('web.field_utils'); |
var field_utils = require('web.field_utils'); |
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
var session = require('web.session'); |
var session = require('web.session'); |
||||
var utils = require('web.utils'); |
var utils = require('web.utils'); |
||||
var QWeb = core.qweb; |
var QWeb = core.qweb; |
||||
var _t = core._t; |
var _t = core._t; |
||||
|
|
||||
var datepicker = require('web.datepicker'); |
var datepicker = require('web.datepicker'); |
||||
var time = require('web.time'); |
var time = require('web.time'); |
||||
window.click_num = 0; |
window.click_num = 0; |
||||
var PartnerAgeing = AbstractAction.extend({ |
var PartnerAgeing = AbstractAction.extend({ |
||||
template: 'AgeingTemp', |
template: 'AgeingTemp', |
||||
events: { |
events: { |
||||
'click .parent-line': 'journal_line_click', |
'click .parent-line': 'journal_line_click', |
||||
'click .child_col1': 'journal_line_click', |
'click .child_col1': 'journal_line_click', |
||||
'click #apply_filter': 'apply_filter', |
'click #apply_filter': 'apply_filter', |
||||
'click #pdf': 'print_pdf', |
'click #pdf': 'print_pdf', |
||||
'click #xlsx': 'print_xlsx', |
'click #xlsx': 'print_xlsx', |
||||
'click .gl-line': 'show_drop_down', |
'click .gl-line': 'show_drop_down', |
||||
'click .view-account-move': 'view_acc_move', |
'click .view-account-move': 'view_acc_move', |
||||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
||||
}, |
}, |
||||
|
|
||||
init: function(parent, action) { |
init: function(parent, action) { |
||||
this._super(parent, action); |
this._super(parent, action); |
||||
this.currency=action.currency; |
this.currency = action.currency; |
||||
this.report_lines = action.report_lines; |
this.report_lines = action.report_lines; |
||||
|
|
||||
this.wizard_id = action.context.wizard | null; |
this.wizard_id = action.context.wizard | null; |
||||
|
|
||||
}, |
}, |
||||
|
|
||||
|
|
||||
start: function() { |
start: function() { |
||||
var self = this; |
var self = this; |
||||
self.initial_render = true; |
self.initial_render = true; |
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.partner.ageing', |
model: 'account.partner.ageing', |
||||
method: 'create', |
method: 'create', |
||||
args: [{ |
args: [{ |
||||
|
|
||||
}] |
}] |
||||
}).then(function(t_res) { |
}).then(function(t_res) { |
||||
self.wizard_id = t_res; |
self.wizard_id = t_res; |
||||
|
|
||||
self.load_data(self.initial_render); |
self.load_data(self.initial_render); |
||||
}) |
}) |
||||
}, |
}, |
||||
|
|
||||
_onCalendarIconClick: function (ev) { |
_onCalendarIconClick: function(ev) { |
||||
var $calendarInputGroup = $(ev.currentTarget); |
var $calendarInputGroup = $(ev.currentTarget); |
||||
|
|
||||
var calendarOptions = { |
var calendarOptions = { |
||||
|
|
||||
minDate: moment({ y: 1000 }), |
minDate: moment({ |
||||
maxDate: moment().add(200, 'y'), |
y: 1000 |
||||
calendarWeeks: true, |
}), |
||||
defaultDate: moment().format(), |
maxDate: moment().add(200, 'y'), |
||||
sideBySide: true, |
calendarWeeks: true, |
||||
buttons: { |
defaultDate: moment().format(), |
||||
showClear: true, |
sideBySide: true, |
||||
showClose: true, |
buttons: { |
||||
showToday: true, |
showClear: true, |
||||
}, |
showClose: true, |
||||
|
showToday: true, |
||||
icons : { |
}, |
||||
date: 'fa fa-calendar', |
|
||||
|
icons: { |
||||
}, |
date: 'fa fa-calendar', |
||||
locale : moment.locale(), |
|
||||
format : time.getLangDateFormat(), |
}, |
||||
widgetParent: 'body', |
locale: moment.locale(), |
||||
allowInputToggle: true, |
format: time.getLangDateFormat(), |
||||
}; |
widgetParent: 'body', |
||||
|
allowInputToggle: true, |
||||
$calendarInputGroup.datetimepicker(calendarOptions); |
}; |
||||
}, |
|
||||
|
$calendarInputGroup.datetimepicker(calendarOptions); |
||||
|
}, |
||||
load_data: function (initial_render = true) { |
|
||||
|
|
||||
var self = this; |
load_data: function(initial_render = true) { |
||||
|
|
||||
self.$(".categ").empty(); |
var self = this; |
||||
try{ |
|
||||
var self = this; |
self.$(".categ").empty(); |
||||
self._rpc({ |
try { |
||||
model: 'account.partner.ageing', |
var self = this; |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [[this.wizard_id]], |
model: 'account.partner.ageing', |
||||
}).then(function(datas) { |
method: 'view_report', |
||||
_.each(datas['report_lines'][0], function(rep_lines) { |
args: [ |
||||
rep_lines.total = self.format_currency(datas['currency'],rep_lines.total); |
[this.wizard_id] |
||||
rep_lines[4] = self.format_currency(datas['currency'],rep_lines[4]); |
], |
||||
rep_lines[3] = self.format_currency(datas['currency'],rep_lines[3]); |
}).then(function(datas) { |
||||
rep_lines[2] = self.format_currency(datas['currency'],rep_lines[2]); |
_.each(datas['report_lines'][0], function(rep_lines) { |
||||
rep_lines[1] = self.format_currency(datas['currency'],rep_lines[1]); |
rep_lines.total = self.format_currency(datas['currency'], rep_lines.total); |
||||
rep_lines[0] = self.format_currency(datas['currency'],rep_lines[0]); |
rep_lines[4] = self.format_currency(datas['currency'], rep_lines[4]); |
||||
|
rep_lines[3] = self.format_currency(datas['currency'], rep_lines[3]); |
||||
rep_lines['direction'] = self.format_currency(datas['currency'],rep_lines['direction']); |
rep_lines[2] = self.format_currency(datas['currency'], rep_lines[2]); |
||||
|
rep_lines[1] = self.format_currency(datas['currency'], rep_lines[1]); |
||||
}); |
rep_lines[0] = self.format_currency(datas['currency'], rep_lines[0]); |
||||
|
rep_lines['direction'] = self.format_currency(datas['currency'], rep_lines['direction']); |
||||
if (initial_render) { |
|
||||
self.$('.filter_view_tb').html(QWeb.render('AgeingFilterView', { |
}); |
||||
filter_data: datas['filters'], |
|
||||
})); |
if (initial_render) { |
||||
self.$el.find('.partners').select2({ |
self.$('.filter_view_tb').html(QWeb.render('AgeingFilterView', { |
||||
placeholder: ' Partners...', |
filter_data: datas['filters'], |
||||
}); |
})); |
||||
self.$el.find('.category').select2({ |
self.$el.find('.partners').select2({ |
||||
placeholder: ' Partner Category...', |
placeholder: ' Partners...', |
||||
}); |
}); |
||||
self.$el.find('.target_move').select2({ |
self.$el.find('.category').select2({ |
||||
placeholder: ' Target Move...', |
placeholder: ' Partner Category...', |
||||
}); |
}); |
||||
self.$el.find('.result_selection').select2({ |
self.$el.find('.target_move').select2({ |
||||
placeholder: ' Account Type...', |
placeholder: ' Target Move...', |
||||
}); |
}); |
||||
|
self.$el.find('.result_selection').select2({ |
||||
} |
placeholder: ' Account Type...', |
||||
var child=[]; |
}); |
||||
self.$('.table_view_tb').html(QWeb.render('Ageingtable', { |
|
||||
|
} |
||||
report_lines : datas['report_lines'], |
var child = []; |
||||
move_lines :datas['report_lines'][2], |
self.$('.table_view_tb').html(QWeb.render('Ageingtable', { |
||||
filter : datas['filters'], |
|
||||
currency : datas['currency'], |
report_lines: datas['report_lines'], |
||||
})); |
move_lines: datas['report_lines'][2], |
||||
|
filter: datas['filters'], |
||||
}); |
currency: datas['currency'], |
||||
|
})); |
||||
} |
|
||||
catch (el) { |
}); |
||||
window.location.href |
|
||||
} |
} catch (el) { |
||||
}, |
window.location.href |
||||
format_currency: function(currency, amount) { |
} |
||||
if (typeof(amount) != 'number') { |
}, |
||||
amount = parseFloat(amount); |
format_currency: function(currency, amount) { |
||||
} |
if (typeof(amount) != 'number') { |
||||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
amount = parseFloat(amount); |
||||
minimumFractionDigits: 2 |
} |
||||
}) |
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
||||
return formatted_value |
minimumFractionDigits: 2 |
||||
}, |
}) |
||||
|
return formatted_value |
||||
print_pdf: function(e) { |
}, |
||||
e.preventDefault(); |
|
||||
|
print_pdf: function(e) { |
||||
var self = this; |
e.preventDefault(); |
||||
self._rpc({ |
|
||||
model: 'account.partner.ageing', |
var self = this; |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [ |
model: 'account.partner.ageing', |
||||
[self.wizard_id] |
method: 'view_report', |
||||
], |
args: [ |
||||
}).then(function(data) { |
[self.wizard_id] |
||||
var action = { |
], |
||||
'type': 'ir.actions.report', |
}).then(function(data) { |
||||
'report_type': 'qweb-pdf', |
var action = { |
||||
'report_name': 'dynamic_accounts_report.partner_ageing', |
'type': 'ir.actions.report', |
||||
'report_file': 'dynamic_accounts_report.partner_ageing', |
'report_type': 'qweb-pdf', |
||||
'data': { |
'report_name': 'dynamic_accounts_report.partner_ageing', |
||||
'report_data': data |
'report_file': 'dynamic_accounts_report.partner_ageing', |
||||
}, |
'data': { |
||||
'context': { |
'report_data': data |
||||
'active_model': 'account.partner.ageing', |
}, |
||||
'landscape': 1, |
'context': { |
||||
'ageing_pdf_report': true |
'active_model': 'account.partner.ageing', |
||||
|
'landscape': 1, |
||||
}, |
'ageing_pdf_report': true |
||||
'display_name': 'Partner Ageing', |
|
||||
}; |
}, |
||||
|
'display_name': 'Partner Ageing', |
||||
return self.do_action(action); |
}; |
||||
}); |
|
||||
}, |
return self.do_action(action); |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
print_xlsx: function() { |
|
||||
var self = this; |
|
||||
self._rpc({ |
print_xlsx: function() { |
||||
model: 'account.partner.ageing', |
var self = this; |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [ |
model: 'account.partner.ageing', |
||||
[self.wizard_id] |
method: 'view_report', |
||||
], |
args: [ |
||||
}).then(function(data) { |
[self.wizard_id] |
||||
|
], |
||||
var action = { |
}).then(function(data) { |
||||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|
||||
'data': { |
var action = { |
||||
'model': 'account.partner.ageing', |
// 'type': 'ir_actions_dynamic_xlsx_download',
|
||||
'options': JSON.stringify(data['filters']), |
'data': { |
||||
'output_format': 'xlsx', |
'model': 'account.partner.ageing', |
||||
'report_data': JSON.stringify(data['report_lines']), |
'options': JSON.stringify(data['filters']), |
||||
'report_name': 'Partner Ageing', |
'output_format': 'xlsx', |
||||
'dfr_data': JSON.stringify(data), |
'report_data': JSON.stringify(data['report_lines']), |
||||
}, |
'report_name': 'Partner Ageing', |
||||
}; |
'dfr_data': JSON.stringify(data), |
||||
// return self.do_action(action);
|
}, |
||||
core.action_registry.map.t_b.prototype.downloadXlsx(action) |
}; |
||||
}); |
// return self.do_action(action);
|
||||
}, |
core.action_registry.map.t_b.prototype.downloadXlsx(action) |
||||
|
}); |
||||
|
}, |
||||
|
|
||||
|
|
||||
|
|
||||
create_lines_with_style: function(rec, attr, datas) { |
|
||||
var temp_str = ""; |
|
||||
var style_name = "border-bottom: 1px solid #e6e6e6;"; |
create_lines_with_style: function(rec, attr, datas) { |
||||
var attr_name = attr + " style="+style_name; |
var temp_str = ""; |
||||
|
var style_name = "border-bottom: 1px solid #e6e6e6;"; |
||||
|
var attr_name = attr + " style=" + style_name; |
||||
|
|
||||
temp_str += "<td class='child_col1' "+attr_name+" >"+rec['code'] +rec['name'] +"</td>"; |
|
||||
if(datas.currency[1]=='after'){ |
|
||||
temp_str += "<td class='child_col2' "+attr_name+" >"+rec['debit'].toFixed(2)+datas.currency[0]+"</td>"; |
temp_str += "<td class='child_col1' " + attr_name + " >" + rec['code'] + rec['name'] + "</td>"; |
||||
temp_str += "<td class='child_col3' "+attr_name+" >"+rec['credit'].toFixed(2) +datas.currency[0]+ "</td>"; |
if (datas.currency[1] == 'after') { |
||||
|
temp_str += "<td class='child_col2' " + attr_name + " >" + rec['debit'].toFixed(2) + datas.currency[0] + "</td>"; |
||||
} |
temp_str += "<td class='child_col3' " + attr_name + " >" + rec['credit'].toFixed(2) + datas.currency[0] + "</td>"; |
||||
else{ |
|
||||
temp_str += "<td class='child_col2' "+attr_name+" >"+datas.currency[0]+rec['debit'].toFixed(2) + "</td>"; |
} else { |
||||
temp_str += "<td class='child_col3' "+attr_name+">"+datas.currency[0]+rec['credit'].toFixed(2) + "</td>"; |
temp_str += "<td class='child_col2' " + attr_name + " >" + datas.currency[0] + rec['debit'].toFixed(2) + "</td>"; |
||||
|
temp_str += "<td class='child_col3' " + attr_name + ">" + datas.currency[0] + rec['credit'].toFixed(2) + "</td>"; |
||||
} |
|
||||
return temp_str; |
} |
||||
}, |
return temp_str; |
||||
|
}, |
||||
|
|
||||
journal_line_click: function (el){ |
|
||||
click_num++; |
journal_line_click: function(el) { |
||||
var self = this; |
click_num++; |
||||
var line = $(el.target).parent().data('id'); |
var self = this; |
||||
|
var line = $(el.target).parent().data('id'); |
||||
return self.do_action({ |
|
||||
type: 'ir.actions.act_window', |
return self.do_action({ |
||||
view_type: 'form', |
type: 'ir.actions.act_window', |
||||
view_mode: 'form', |
view_type: 'form', |
||||
res_model: 'account.move', |
view_mode: 'form', |
||||
views: [ |
res_model: 'account.move', |
||||
[false, 'form'] |
views: [ |
||||
], |
[false, 'form'] |
||||
res_id: line, |
], |
||||
target: 'current', |
res_id: line, |
||||
}); |
target: 'current', |
||||
|
}); |
||||
}, |
|
||||
|
}, |
||||
show_drop_down: function(event) { |
|
||||
event.preventDefault(); |
show_drop_down: function(event) { |
||||
var self = this; |
event.preventDefault(); |
||||
var account_id = $(event.currentTarget).data('account-id'); |
var self = this; |
||||
|
var account_id = $(event.currentTarget).data('account-id'); |
||||
var partner_id = $(event.currentTarget)[0].cells[0].innerText; |
|
||||
|
var partner_id = $(event.currentTarget)[0].cells[0].innerText; |
||||
var offset = 0; |
|
||||
var td = $(event.currentTarget).next('tr').find('td'); |
var offset = 0; |
||||
if (td.length == 1) { |
var td = $(event.currentTarget).next('tr').find('td'); |
||||
|
if (td.length == 1) { |
||||
self._rpc({ |
|
||||
model: 'account.partner.ageing', |
self._rpc({ |
||||
method: 'view_report', |
model: 'account.partner.ageing', |
||||
args: [ |
method: 'view_report', |
||||
[self.wizard_id] |
args: [ |
||||
], |
[self.wizard_id] |
||||
}).then(function(data) { |
], |
||||
|
}).then(function(data) { |
||||
_.each(data['report_lines'][0], function(rep_lines) { |
|
||||
_.each(rep_lines['child_lines'], function(child_line) { |
_.each(data['report_lines'][0], function(rep_lines) { |
||||
child_line.amount = self.format_currency(data['currency'],child_line.amount); |
_.each(rep_lines['child_lines'], function(child_line) { |
||||
|
child_line.amount = self.format_currency(data['currency'], child_line.amount); |
||||
}); |
|
||||
}); |
}); |
||||
|
}); |
||||
|
|
||||
for (var i = 0; i < data['report_lines'][0].length; i++) { |
|
||||
if (account_id == data['report_lines'][0][i]['partner_id'] ){ |
for (var i = 0; i < data['report_lines'][0].length; i++) { |
||||
$(event.currentTarget).next('tr').find('td').remove(); |
if (account_id == data['report_lines'][0][i]['partner_id']) { |
||||
$(event.currentTarget).next('tr').after( |
$(event.currentTarget).next('tr').find('td').remove(); |
||||
QWeb.render('SubSectional', { |
$(event.currentTarget).next('tr').after( |
||||
account_data: data['report_lines'][0][i]['child_lines'], |
QWeb.render('SubSectional', { |
||||
id : data['report_lines'][0][i]['partner_id'] |
account_data: data['report_lines'][0][i]['child_lines'], |
||||
})) |
id: data['report_lines'][0][i]['partner_id'] |
||||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
})) |
||||
'background-color': '#00ede8', |
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
||||
'font-weight': 'bold', |
'background-color': '#00ede8', |
||||
}); |
'font-weight': 'bold', |
||||
} |
}); |
||||
} |
} |
||||
|
} |
||||
}); |
|
||||
} |
}); |
||||
}, |
} |
||||
|
}, |
||||
view_acc_move: function(event) { |
|
||||
event.preventDefault(); |
view_acc_move: function(event) { |
||||
var self = this; |
event.preventDefault(); |
||||
var context = {}; |
var self = this; |
||||
var show_acc_move = function(res_model, res_id, view_id) { |
var context = {}; |
||||
var action = { |
var show_acc_move = function(res_model, res_id, view_id) { |
||||
type: 'ir.actions.act_window', |
var action = { |
||||
view_type: 'form', |
type: 'ir.actions.act_window', |
||||
view_mode: 'form', |
view_type: 'form', |
||||
res_model: res_model, |
view_mode: 'form', |
||||
views: [ |
res_model: res_model, |
||||
[view_id || false, 'form'] |
views: [ |
||||
], |
[view_id || false, 'form'] |
||||
res_id: res_id, |
], |
||||
target: 'current', |
res_id: res_id, |
||||
context: context, |
target: 'current', |
||||
}; |
context: context, |
||||
return self.do_action(action); |
}; |
||||
}; |
return self.do_action(action); |
||||
rpc.query({ |
}; |
||||
model: 'account.move', |
rpc.query({ |
||||
method: 'search_read', |
model: 'account.move', |
||||
domain: [ |
method: 'search_read', |
||||
['id', '=', $(event.currentTarget).data('move-id')] |
domain: [ |
||||
], |
['id', '=', $(event.currentTarget).data('move-id')] |
||||
fields: ['id'], |
], |
||||
limit: 1, |
fields: ['id'], |
||||
}) |
limit: 1, |
||||
.then(function(record) { |
}) |
||||
if (record.length > 0) { |
.then(function(record) { |
||||
show_acc_move('account.move', record[0].id); |
if (record.length > 0) { |
||||
} else { |
show_acc_move('account.move', record[0].id); |
||||
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
} else { |
||||
} |
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
||||
}); |
} |
||||
}, |
}); |
||||
|
}, |
||||
|
|
||||
apply_filter: function(event) { |
|
||||
event.preventDefault(); |
apply_filter: function(event) { |
||||
var self = this; |
event.preventDefault(); |
||||
self.initial_render = false; |
var self = this; |
||||
|
self.initial_render = false; |
||||
var filter_data_selected = {}; |
var filter_data_selected = {}; |
||||
|
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
||||
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
} |
||||
} |
var partner_ids = []; |
||||
|
var partner_text = []; |
||||
|
var span_res = document.getElementById("partner_res") |
||||
|
var partner_list = $(".partners").select2('data') |
||||
|
for (var i = 0; i < partner_list.length; i++) { |
||||
|
if (partner_list[i].element[0].selected === true) { |
||||
var partner_ids = []; |
partner_ids.push(parseInt(partner_list[i].id)) |
||||
var partner_text = []; |
if (partner_text.includes(partner_list[i].text) === false) { |
||||
var span_res = document.getElementById("partner_res") |
partner_text.push(partner_list[i].text) |
||||
var partner_list = $(".partners").select2('data') |
} |
||||
for (var i = 0; i < partner_list.length; i++) { |
span_res.value = partner_text |
||||
if(partner_list[i].element[0].selected === true) |
span_res.innerHTML = span_res.value; |
||||
{partner_ids.push(parseInt(partner_list[i].id)) |
} |
||||
if(partner_text.includes(partner_list[i].text) === false) |
} |
||||
{partner_text.push(partner_list[i].text) |
if (partner_list.length == 0) { |
||||
} |
span_res.value = "" |
||||
span_res.value = partner_text |
span_res.innerHTML = ""; |
||||
span_res.innerHTML=span_res.value; |
} |
||||
} |
filter_data_selected.partner_ids = partner_ids |
||||
} |
|
||||
if (partner_list.length == 0){ |
var partner_category_ids = []; |
||||
span_res.value = "" |
var partner_category_text = []; |
||||
span_res.innerHTML=""; |
var span_res = document.getElementById("category_res") |
||||
} |
var category_list = $(".category").select2('data') |
||||
filter_data_selected.partner_ids = partner_ids |
|
||||
|
for (var i = 0; i < category_list.length; i++) { |
||||
var partner_category_ids = []; |
if (category_list[i].element[0].selected === true) { |
||||
var partner_category_text = []; |
partner_category_ids.push(parseInt(category_list[i].id)) |
||||
var span_res = document.getElementById("category_res") |
if (partner_category_text.includes(category_list[i].text) === false) { |
||||
var category_list = $(".category").select2('data') |
partner_category_text.push(category_list[i].text) |
||||
|
} |
||||
for (var i = 0; i < category_list.length; i++) { |
span_res.value = partner_category_text |
||||
if(category_list[i].element[0].selected === true) |
span_res.innerHTML = span_res.value; |
||||
{partner_category_ids.push(parseInt(category_list[i].id)) |
} |
||||
if(partner_category_text.includes(category_list[i].text) === false) |
} |
||||
{partner_category_text.push(category_list[i].text) |
if (category_list.length == 0) { |
||||
} |
span_res.value = "" |
||||
span_res.value = partner_category_text |
span_res.innerHTML = ""; |
||||
span_res.innerHTML=span_res.value; |
} |
||||
} |
filter_data_selected.partner_category_ids = partner_category_ids |
||||
} |
|
||||
if (category_list.length == 0){ |
|
||||
span_res.value = "" |
if ($(".target_move").length) { |
||||
span_res.innerHTML=""; |
|
||||
} |
var post_res = document.getElementById("post_res") |
||||
filter_data_selected.partner_category_ids = partner_category_ids |
filter_data_selected.target_move = $(".target_move")[1].value |
||||
|
|
||||
|
post_res.value = $(".target_move")[1].value |
||||
if ($(".target_move").length) { |
post_res.innerHTML = post_res.value; |
||||
|
if ($(".target_move")[1].value == "") { |
||||
var post_res = document.getElementById("post_res") |
post_res.innerHTML = "posted"; |
||||
filter_data_selected.target_move = $(".target_move")[1].value |
|
||||
|
} |
||||
post_res.value = $(".target_move")[1].value |
} |
||||
post_res.innerHTML=post_res.value; |
|
||||
if ($(".target_move")[1].value == "") { |
if ($(".result_selection").length) { |
||||
post_res.innerHTML="posted"; |
var account_res = document.getElementById("account_res") |
||||
|
filter_data_selected.result_selection = $(".result_selection")[1].value |
||||
} |
account_res.value = $(".result_selection")[1].value |
||||
} |
account_res.innerHTML = account_res.value; |
||||
|
if ($(".result_selection")[1].value == "") { |
||||
if ($(".result_selection").length) { |
account_res.innerHTML = "customer"; |
||||
var account_res = document.getElementById("account_res") |
|
||||
filter_data_selected.result_selection = $(".result_selection")[1].value |
} |
||||
account_res.value = $(".result_selection")[1].value |
} |
||||
account_res.innerHTML=account_res.value; |
|
||||
if ($(".result_selection")[1].value == "") { |
|
||||
account_res.innerHTML="customer"; |
rpc.query({ |
||||
|
model: 'account.partner.ageing', |
||||
} |
method: 'write', |
||||
} |
args: [ |
||||
|
self.wizard_id, filter_data_selected |
||||
|
], |
||||
rpc.query({ |
}).then(function(res) { |
||||
model: 'account.partner.ageing', |
self.initial_render = false; |
||||
method: 'write', |
self.load_data(self.initial_render); |
||||
args: [ |
}); |
||||
self.wizard_id, filter_data_selected |
}, |
||||
], |
|
||||
}).then(function(res) { |
}); |
||||
self.initial_render = false; |
core.action_registry.add("p_a", PartnerAgeing); |
||||
self.load_data(self.initial_render); |
return PartnerAgeing; |
||||
}); |
|
||||
}, |
|
||||
|
|
||||
}); |
|
||||
core.action_registry.add("p_a", PartnerAgeing); |
|
||||
return PartnerAgeing; |
|
||||
}); |
}); |
@ -1,386 +1,391 @@ |
|||||
odoo.define('dynamic_cash_flow_statements.cash_flow', function (require) { |
odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { |
||||
'use strict'; |
'use strict'; |
||||
var AbstractAction = require('web.AbstractAction'); |
var AbstractAction = require('web.AbstractAction'); |
||||
var core = require('web.core'); |
var core = require('web.core'); |
||||
var field_utils = require('web.field_utils'); |
var field_utils = require('web.field_utils'); |
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
var session = require('web.session'); |
var session = require('web.session'); |
||||
var utils = require('web.utils'); |
var utils = require('web.utils'); |
||||
var QWeb = core.qweb; |
var QWeb = core.qweb; |
||||
var _t = core._t; |
var _t = core._t; |
||||
var framework = require('web.framework'); |
var framework = require('web.framework'); |
||||
|
|
||||
var datepicker = require('web.datepicker'); |
var datepicker = require('web.datepicker'); |
||||
var time = require('web.time'); |
var time = require('web.time'); |
||||
|
|
||||
window.click_num = 0; |
window.click_num = 0; |
||||
var CashFlow = AbstractAction.extend({ |
var CashFlow = AbstractAction.extend({ |
||||
template: 'CFTemp', |
template: 'CFTemp', |
||||
events: { |
events: { |
||||
'click .parent-line': 'journal_line_click', |
'click .parent-line': 'journal_line_click', |
||||
'click .child_col1': 'journal_line_click', |
'click .child_col1': 'journal_line_click', |
||||
'click #apply_filter': 'apply_filter', |
'click #apply_filter': 'apply_filter', |
||||
'click #pdf': 'print_pdf', |
'click #pdf': 'print_pdf', |
||||
'click #xlsx': 'print_xlsx', |
'click #xlsx': 'print_xlsx', |
||||
'click .cf-line': 'get_move_lines', |
'click .cf-line': 'get_move_lines', |
||||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
||||
}, |
}, |
||||
|
|
||||
init: function(parent, action) { |
init: function(parent, action) { |
||||
this._super(parent, action); |
this._super(parent, action); |
||||
this.currency=action.currency; |
this.currency = action.currency; |
||||
this.report_lines = action.report_lines; |
this.report_lines = action.report_lines; |
||||
this.wizard_id = action.context.wizard | null; |
this.wizard_id = action.context.wizard | null; |
||||
}, |
}, |
||||
|
|
||||
|
|
||||
start: function() { |
start: function() { |
||||
var self = this; |
var self = this; |
||||
self.initial_render = true; |
self.initial_render = true; |
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.cash.flow', |
model: 'account.cash.flow', |
||||
method: 'create', |
method: 'create', |
||||
args: [{ |
args: [{ |
||||
|
|
||||
}] |
}] |
||||
}).then(function(t_res) { |
}).then(function(t_res) { |
||||
self.wizard_id = t_res; |
self.wizard_id = t_res; |
||||
self.load_data(self.initial_render); |
self.load_data(self.initial_render); |
||||
}) |
}) |
||||
}, |
}, |
||||
_onCalendarIconClick: function (ev) { |
_onCalendarIconClick: function(ev) { |
||||
var $calendarInputGroup = $(ev.currentTarget); |
var $calendarInputGroup = $(ev.currentTarget); |
||||
|
|
||||
var calendarOptions = { |
var calendarOptions = { |
||||
|
|
||||
minDate: moment({ y: 1000 }), |
minDate: moment({ |
||||
maxDate: moment().add(200, 'y'), |
y: 1000 |
||||
calendarWeeks: true, |
}), |
||||
defaultDate: moment().format(), |
maxDate: moment().add(200, 'y'), |
||||
sideBySide: true, |
calendarWeeks: true, |
||||
buttons: { |
defaultDate: moment().format(), |
||||
showClear: true, |
sideBySide: true, |
||||
showClose: true, |
buttons: { |
||||
showToday: true, |
showClear: true, |
||||
}, |
showClose: true, |
||||
|
showToday: true, |
||||
icons : { |
}, |
||||
date: 'fa fa-calendar', |
|
||||
|
icons: { |
||||
}, |
date: 'fa fa-calendar', |
||||
locale : moment.locale(), |
|
||||
format : time.getLangDateFormat(), |
}, |
||||
widgetParent: 'body', |
locale: moment.locale(), |
||||
allowInputToggle: true, |
format: time.getLangDateFormat(), |
||||
}; |
widgetParent: 'body', |
||||
|
allowInputToggle: true, |
||||
$calendarInputGroup.datetimepicker(calendarOptions); |
}; |
||||
}, |
|
||||
|
$calendarInputGroup.datetimepicker(calendarOptions); |
||||
get_move_lines: function(event) { |
}, |
||||
event.preventDefault(); |
|
||||
var self = this; |
get_move_lines: function(event) { |
||||
var account_id = $(event.currentTarget).data('account-id'); |
event.preventDefault(); |
||||
var offset = 0; |
var self = this; |
||||
var td = $(event.currentTarget).next('tr').find('td'); |
var account_id = $(event.currentTarget).data('account-id'); |
||||
if (td.length == 1) { |
var offset = 0; |
||||
self._rpc({ |
var td = $(event.currentTarget).next('tr').find('td'); |
||||
model: 'account.cash.flow', |
if (td.length == 1) { |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [ |
model: 'account.cash.flow', |
||||
[self.wizard_id] |
method: 'view_report', |
||||
], |
args: [ |
||||
}).then(function(datas) { |
[self.wizard_id] |
||||
_.each(datas['journal_res'], function(journal_lines) { |
], |
||||
_.each(journal_lines['journal_lines'], function(rep_lines) { |
}).then(function(datas) { |
||||
rep_lines.total_debit = self.format_currency(datas['currency'],rep_lines.total_debit); |
_.each(datas['journal_res'], function(journal_lines) { |
||||
rep_lines.total_credit = self.format_currency(datas['currency'],rep_lines.total_credit); |
_.each(journal_lines['journal_lines'], function(rep_lines) { |
||||
rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance); |
rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit); |
||||
|
rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit); |
||||
|
rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance); |
||||
|
|
||||
|
|
||||
}); |
|
||||
|
|
||||
}); |
}); |
||||
_.each(datas['account_res'], function(journal_lines) { |
|
||||
_.each(journal_lines['journal_lines'], function(rep_lines) { |
}); |
||||
rep_lines.total_debit = self.format_currency(datas['currency'],rep_lines.total_debit); |
_.each(datas['account_res'], function(journal_lines) { |
||||
rep_lines.total_credit = self.format_currency(datas['currency'],rep_lines.total_credit); |
_.each(journal_lines['journal_lines'], function(rep_lines) { |
||||
rep_lines.total_balance = self.format_currency(datas['currency'],rep_lines.total_balance); |
rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit); |
||||
|
rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit); |
||||
|
rep_lines.total_balance = self.format_currency(datas['currency'], rep_lines.total_balance); |
||||
}); |
|
||||
_.each(journal_lines['move_lines'], function(move_lines) { |
|
||||
move_lines.total_debit = self.format_currency(datas['currency'],move_lines.total_debit); |
}); |
||||
move_lines.total_credit = self.format_currency(datas['currency'],move_lines.total_credit); |
_.each(journal_lines['move_lines'], function(move_lines) { |
||||
move_lines.balance = self.format_currency(datas['currency'],move_lines.balance); |
move_lines.total_debit = self.format_currency(datas['currency'], move_lines.total_debit); |
||||
|
move_lines.total_credit = self.format_currency(datas['currency'], move_lines.total_credit); |
||||
|
move_lines.balance = self.format_currency(datas['currency'], move_lines.balance); |
||||
|
|
||||
|
|
||||
}); |
|
||||
}); |
|
||||
|
}); |
||||
|
}); |
||||
if(datas['levels']== 'detailed'){ |
|
||||
$(event.currentTarget).next('tr').find('td ul').after( |
|
||||
QWeb.render('SubSectionCF', { |
if (datas['levels'] == 'detailed') { |
||||
count: 3, |
$(event.currentTarget).next('tr').find('td ul').after( |
||||
offset: 0, |
QWeb.render('SubSectionCF', { |
||||
account_data: datas['journal_res'], |
count: 3, |
||||
level:datas['levels'], |
offset: 0, |
||||
currency : datas['currency'], |
account_data: datas['journal_res'], |
||||
line_id:parseInt(event.currentTarget.attributes[3].value), |
level: datas['levels'], |
||||
})) |
currency: datas['currency'], |
||||
}else if(datas['levels']== 'very' || datas['levels']== false){ |
line_id: parseInt(event.currentTarget.attributes[3].value), |
||||
$(event.currentTarget).next('tr').find('td ul').after( |
})) |
||||
QWeb.render('ChildSubSectionCF', { |
} else if (datas['levels'] == 'very' || datas['levels'] == false) { |
||||
count: 3, |
$(event.currentTarget).next('tr').find('td ul').after( |
||||
offset: 0, |
QWeb.render('ChildSubSectionCF', { |
||||
account_data: datas['account_res'], |
count: 3, |
||||
level:datas['levels'], |
offset: 0, |
||||
currency : datas['currency'], |
account_data: datas['account_res'], |
||||
line_id:parseInt(event.currentTarget.attributes[3].value), |
level: datas['levels'], |
||||
})) |
currency: datas['currency'], |
||||
} |
line_id: parseInt(event.currentTarget.attributes[3].value), |
||||
|
})) |
||||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
} |
||||
'background-color': '#00ede8', |
|
||||
'font-weight': 'bold', |
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
||||
}); |
'background-color': '#00ede8', |
||||
}) |
'font-weight': 'bold', |
||||
} |
}); |
||||
}, |
}) |
||||
|
} |
||||
|
}, |
||||
load_data: function (initial_render = true) { |
|
||||
var self = this; |
|
||||
self.$(".categ").empty(); |
load_data: function(initial_render = true) { |
||||
try{ |
var self = this; |
||||
var self = this; |
self.$(".categ").empty(); |
||||
self._rpc({ |
try { |
||||
model: 'account.cash.flow', |
var self = this; |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [[this.wizard_id]], |
model: 'account.cash.flow', |
||||
}).then(function(datas) { |
method: 'view_report', |
||||
|
args: [ |
||||
|
[this.wizard_id] |
||||
_.each(datas['fetched_data'], function(rep_lines) { |
], |
||||
rep_lines.total_debit = self.format_currency(datas['currency'],rep_lines.total_debit); |
}).then(function(datas) { |
||||
rep_lines.total_credit = self.format_currency(datas['currency'],rep_lines.total_credit); |
|
||||
rep_lines.total_balance = self.format_currency(datas['currency'],rep_lines.total_balance); |
|
||||
|
_.each(datas['fetched_data'], function(rep_lines) { |
||||
|
rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit); |
||||
|
rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit); |
||||
|
rep_lines.total_balance = self.format_currency(datas['currency'], rep_lines.total_balance); |
||||
}); |
|
||||
if (initial_render) { |
|
||||
self.$('.filter_view_tb').html(QWeb.render('CashFilterView', { |
|
||||
filter_data: datas['filters'], |
|
||||
})); |
}); |
||||
self.$el.find('.journals').select2({ |
if (initial_render) { |
||||
placeholder: 'Select Journals...', |
self.$('.filter_view_tb').html(QWeb.render('CashFilterView', { |
||||
}); |
filter_data: datas['filters'], |
||||
self.$el.find('.target_move').select2({ |
})); |
||||
placeholder: 'Target Move...', |
self.$el.find('.journals').select2({ |
||||
}); |
placeholder: 'Select Journals...', |
||||
self.$el.find('.levels').select2({ |
}); |
||||
placeholder: 'Levels...', |
self.$el.find('.target_move').select2({ |
||||
}); |
placeholder: 'Target Move...', |
||||
} |
}); |
||||
var child=[]; |
self.$el.find('.levels').select2({ |
||||
|
placeholder: 'Levels...', |
||||
self.$('.table_view_tb').html(QWeb.render('CashTable', { |
}); |
||||
|
} |
||||
account_data: datas['fetched_data'], |
var child = []; |
||||
level:datas['levels'], |
|
||||
currency : datas['currency'], |
self.$('.table_view_tb').html(QWeb.render('CashTable', { |
||||
})); |
|
||||
|
account_data: datas['fetched_data'], |
||||
}); |
level: datas['levels'], |
||||
|
currency: datas['currency'], |
||||
} |
})); |
||||
catch (el) { |
|
||||
window.location.href |
}); |
||||
} |
|
||||
}, |
} catch (el) { |
||||
|
window.location.href |
||||
format_currency: function(currency, amount) { |
} |
||||
if (typeof(amount) != 'number') { |
}, |
||||
amount = parseFloat(amount); |
|
||||
} |
format_currency: function(currency, amount) { |
||||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
if (typeof(amount) != 'number') { |
||||
minimumFractionDigits: 2 |
amount = parseFloat(amount); |
||||
}) |
} |
||||
return formatted_value |
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
||||
}, |
minimumFractionDigits: 2 |
||||
|
}) |
||||
show_gl: function(e) { |
return formatted_value |
||||
var self = this; |
}, |
||||
var account_id = $(e.target).attr('data-account-id'); |
|
||||
var options = { |
show_gl: function(e) { |
||||
account_ids: [account_id], |
var self = this; |
||||
} |
var account_id = $(e.target).attr('data-account-id'); |
||||
|
var options = { |
||||
var action = { |
account_ids: [account_id], |
||||
type: 'ir.actions.client', |
} |
||||
name: 'GL View', |
|
||||
tag: 'g_l', |
var action = { |
||||
target: 'new', |
type: 'ir.actions.client', |
||||
|
name: 'GL View', |
||||
domain: [['account_ids','=', account_id]], |
tag: 'g_l', |
||||
|
target: 'new', |
||||
|
|
||||
} |
domain: [ |
||||
return this.do_action(action); |
['account_ids', '=', account_id] |
||||
|
], |
||||
}, |
|
||||
print_pdf: function(e) { |
|
||||
e.preventDefault(); |
} |
||||
var self = this; |
return this.do_action(action); |
||||
self._rpc({ |
|
||||
model: 'account.cash.flow', |
}, |
||||
method: 'view_report', |
print_pdf: function(e) { |
||||
args: [ |
e.preventDefault(); |
||||
[self.wizard_id] |
var self = this; |
||||
], |
self._rpc({ |
||||
}).then(function(data) { |
model: 'account.cash.flow', |
||||
var action = { |
method: 'view_report', |
||||
'type': 'ir.actions.report', |
args: [ |
||||
'report_type': 'qweb-pdf', |
[self.wizard_id] |
||||
'report_name': 'dynamic_accounts_report.cash_flow', |
], |
||||
'report_file': 'dynamic_accounts_report.cash_flow', |
}).then(function(data) { |
||||
'data': { |
var action = { |
||||
'report_data': data |
'type': 'ir.actions.report', |
||||
}, |
'report_type': 'qweb-pdf', |
||||
'context': { |
'report_name': 'dynamic_accounts_report.cash_flow', |
||||
'active_model': 'account.cash.flow', |
'report_file': 'dynamic_accounts_report.cash_flow', |
||||
'landscape': 1, |
'data': { |
||||
'trial_pdf_report': true |
'report_data': data |
||||
}, |
}, |
||||
'display_name': 'Cash Flow Statements', |
'context': { |
||||
}; |
'active_model': 'account.cash.flow', |
||||
return self.do_action(action); |
'landscape': 1, |
||||
}); |
'trial_pdf_report': true |
||||
}, |
}, |
||||
|
'display_name': 'Cash Flow Statements', |
||||
|
}; |
||||
|
return self.do_action(action); |
||||
print_xlsx: function() { |
}); |
||||
var self = this; |
}, |
||||
self._rpc({ |
|
||||
model: 'account.cash.flow', |
|
||||
method: 'view_report', |
|
||||
args: [ |
print_xlsx: function() { |
||||
[self.wizard_id] |
var self = this; |
||||
], |
self._rpc({ |
||||
}).then(function(data) { |
model: 'account.cash.flow', |
||||
var action = { |
method: 'view_report', |
||||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
args: [ |
||||
'data': { |
[self.wizard_id] |
||||
'model': 'account.cash.flow', |
], |
||||
'options': JSON.stringify(data['filters']), |
}).then(function(data) { |
||||
'output_format': 'xlsx', |
var action = { |
||||
'report_data': JSON.stringify(data['report_lines']), |
// 'type': 'ir_actions_dynamic_xlsx_download',
|
||||
'report_name': 'Cash Flow Statements', |
'data': { |
||||
'dfr_data': JSON.stringify(data), |
'model': 'account.cash.flow', |
||||
}, |
'options': JSON.stringify(data['filters']), |
||||
}; |
'output_format': 'xlsx', |
||||
// return self.do_action(action);
|
'report_data': JSON.stringify(data['report_lines']), |
||||
self.downloadXlsx(action) |
'report_name': 'Cash Flow Statements', |
||||
}); |
'dfr_data': JSON.stringify(data), |
||||
}, |
}, |
||||
downloadXlsx: function (action){ |
}; |
||||
framework.blockUI(); |
// return self.do_action(action);
|
||||
session.get_file({ |
self.downloadXlsx(action) |
||||
url: '/dynamic_xlsx_reports', |
}); |
||||
data: action.data, |
}, |
||||
complete: framework.unblockUI, |
downloadXlsx: function(action) { |
||||
error: (error) => this.call('crash_manager', 'rpc_error', error), |
framework.blockUI(); |
||||
}); |
session.get_file({ |
||||
}, |
url: '/dynamic_xlsx_reports', |
||||
|
data: action.data, |
||||
journal_line_click: function (el){ |
complete: framework.unblockUI, |
||||
click_num++; |
error: (error) => this.call('crash_manager', 'rpc_error', error), |
||||
var self = this; |
}); |
||||
var line = $(el.target).parent().data('id'); |
}, |
||||
return self.do_action({ |
|
||||
type: 'ir.actions.act_window', |
journal_line_click: function(el) { |
||||
view_type: 'form', |
click_num++; |
||||
view_mode: 'form', |
var self = this; |
||||
res_model: 'account.move', |
var line = $(el.target).parent().data('id'); |
||||
views: [ |
return self.do_action({ |
||||
[false, 'form'] |
type: 'ir.actions.act_window', |
||||
], |
view_type: 'form', |
||||
res_id: line, |
view_mode: 'form', |
||||
target: 'current', |
res_model: 'account.move', |
||||
}); |
views: [ |
||||
|
[false, 'form'] |
||||
}, |
], |
||||
|
res_id: line, |
||||
|
target: 'current', |
||||
apply_filter: function(event) { |
}); |
||||
|
|
||||
event.preventDefault(); |
}, |
||||
var self = this; |
|
||||
self.initial_render = false; |
|
||||
|
apply_filter: function(event) { |
||||
var filter_data_selected = {}; |
|
||||
|
event.preventDefault(); |
||||
|
var self = this; |
||||
|
self.initial_render = false; |
||||
if ($(".levels").length){ |
|
||||
var level_res = document.getElementById("level_res") |
var filter_data_selected = {}; |
||||
filter_data_selected.levels = $(".levels")[1].value |
|
||||
level_res.value = $(".levels")[1].value |
|
||||
level_res.innerHTML=level_res.value; |
|
||||
if ($(".levels").value==""){ |
if ($(".levels").length) { |
||||
type_res.innerHTML="summary"; |
var level_res = document.getElementById("level_res") |
||||
filter_data_selected.type = "Summary" |
filter_data_selected.levels = $(".levels")[1].value |
||||
} |
level_res.value = $(".levels")[1].value |
||||
} |
level_res.innerHTML = level_res.value; |
||||
|
if ($(".levels").value == "") { |
||||
// if ($("#date_from").val()) {
|
type_res.innerHTML = "summary"; |
||||
// var dateString = $("#date_from").val();
|
filter_data_selected.type = "Summary" |
||||
// filter_data_selected.date_from = dateString;
|
} |
||||
// }
|
} |
||||
// if ($("#date_to").val()) {
|
|
||||
// var dateString = $("#date_to").val();
|
// if ($("#date_from").val()) {
|
||||
// filter_data_selected.date_to = dateString;
|
// var dateString = $("#date_from").val();
|
||||
// }
|
// filter_data_selected.date_from = dateString;
|
||||
|
// }
|
||||
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
// if ($("#date_to").val()) {
|
||||
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
// var dateString = $("#date_to").val();
|
||||
} |
// filter_data_selected.date_to = dateString;
|
||||
|
// }
|
||||
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
|
||||
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
||||
} |
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
|
} |
||||
if ($(".target_move").length) { |
|
||||
var post_res = document.getElementById("post_res") |
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
||||
filter_data_selected.target_move = $(".target_move")[1].value |
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
post_res.value = $(".target_move")[1].value |
} |
||||
post_res.innerHTML=post_res.value; |
|
||||
if ($(".target_move")[1].value == "") { |
if ($(".target_move").length) { |
||||
post_res.innerHTML="posted"; |
var post_res = document.getElementById("post_res") |
||||
|
filter_data_selected.target_move = $(".target_move")[1].value |
||||
} |
post_res.value = $(".target_move")[1].value |
||||
} |
post_res.innerHTML = post_res.value; |
||||
rpc.query({ |
if ($(".target_move")[1].value == "") { |
||||
model: 'account.cash.flow', |
post_res.innerHTML = "posted"; |
||||
method: 'write', |
|
||||
args: [ |
} |
||||
self.wizard_id, filter_data_selected |
} |
||||
], |
rpc.query({ |
||||
}).then(function(res) { |
model: 'account.cash.flow', |
||||
self.initial_render = false; |
method: 'write', |
||||
self.load_data(self.initial_render); |
args: [ |
||||
}); |
self.wizard_id, filter_data_selected |
||||
}, |
], |
||||
|
}).then(function(res) { |
||||
}); |
self.initial_render = false; |
||||
core.action_registry.add("c_f", CashFlow); |
self.load_data(self.initial_render); |
||||
return CashFlow; |
}); |
||||
|
}, |
||||
|
|
||||
|
}); |
||||
|
core.action_registry.add("c_f", CashFlow); |
||||
|
return CashFlow; |
||||
}); |
}); |
@ -1,439 +1,439 @@ |
|||||
odoo.define('dynamic_partner_daybook.daybook', function (require) { |
odoo.define('dynamic_partner_daybook.daybook', function(require) { |
||||
'use strict'; |
'use strict'; |
||||
var AbstractAction = require('web.AbstractAction'); |
var AbstractAction = require('web.AbstractAction'); |
||||
var core = require('web.core'); |
var core = require('web.core'); |
||||
var field_utils = require('web.field_utils'); |
var field_utils = require('web.field_utils'); |
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
var session = require('web.session'); |
var session = require('web.session'); |
||||
var utils = require('web.utils'); |
var utils = require('web.utils'); |
||||
var QWeb = core.qweb; |
var QWeb = core.qweb; |
||||
var _t = core._t; |
var _t = core._t; |
||||
|
|
||||
var datepicker = require('web.datepicker'); |
var datepicker = require('web.datepicker'); |
||||
var time = require('web.time'); |
var time = require('web.time'); |
||||
var framework = require('web.framework'); |
var framework = require('web.framework'); |
||||
|
|
||||
window.click_num = 0; |
window.click_num = 0; |
||||
var DayBook = AbstractAction.extend({ |
var DayBook = AbstractAction.extend({ |
||||
template: 'DaybookTemp', |
template: 'DaybookTemp', |
||||
events: { |
events: { |
||||
'click .parent-line': 'journal_line_click', |
'click .parent-line': 'journal_line_click', |
||||
'click .child_col1': 'journal_line_click', |
'click .child_col1': 'journal_line_click', |
||||
'click #apply_filter': 'apply_filter', |
'click #apply_filter': 'apply_filter', |
||||
'click #pdf': 'print_pdf', |
'click #pdf': 'print_pdf', |
||||
'click #xlsx': 'print_xlsx', |
'click #xlsx': 'print_xlsx', |
||||
'click .db-line': 'show_drop_down', |
'click .db-line': 'show_drop_down', |
||||
'click .view-account-move': 'view_acc_move', |
'click .view-account-move': 'view_acc_move', |
||||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
||||
}, |
}, |
||||
|
|
||||
init: function(parent, action) { |
init: function(parent, action) { |
||||
this._super(parent, action); |
this._super(parent, action); |
||||
this.currency=action.currency; |
this.currency = action.currency; |
||||
this.report_lines = action.report_lines; |
this.report_lines = action.report_lines; |
||||
this.wizard_id = action.context.wizard | null; |
this.wizard_id = action.context.wizard | null; |
||||
}, |
}, |
||||
|
|
||||
|
|
||||
start: function() { |
start: function() { |
||||
var self = this; |
var self = this; |
||||
self.initial_render = true; |
self.initial_render = true; |
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.day.book', |
model: 'account.day.book', |
||||
method: 'create', |
method: 'create', |
||||
args: [{ |
args: [{ |
||||
|
|
||||
}] |
}] |
||||
}).then(function(t_res) { |
}).then(function(t_res) { |
||||
self.wizard_id = t_res; |
self.wizard_id = t_res; |
||||
self.load_data(self.initial_render); |
self.load_data(self.initial_render); |
||||
}) |
}) |
||||
}, |
}, |
||||
|
|
||||
_onCalendarIconClick: function (ev) { |
_onCalendarIconClick: function(ev) { |
||||
var $calendarInputGroup = $(ev.currentTarget); |
var $calendarInputGroup = $(ev.currentTarget); |
||||
|
|
||||
var calendarOptions = { |
var calendarOptions = { |
||||
|
|
||||
minDate: moment({ y: 1000 }), |
minDate: moment({ |
||||
maxDate: moment().add(200, 'y'), |
y: 1000 |
||||
calendarWeeks: true, |
}), |
||||
defaultDate: moment().format(), |
maxDate: moment().add(200, 'y'), |
||||
sideBySide: true, |
calendarWeeks: true, |
||||
buttons: { |
defaultDate: moment().format(), |
||||
showClear: true, |
sideBySide: true, |
||||
showClose: true, |
buttons: { |
||||
showToday: true, |
showClear: true, |
||||
}, |
showClose: true, |
||||
|
showToday: true, |
||||
icons : { |
}, |
||||
date: 'fa fa-calendar', |
|
||||
|
icons: { |
||||
}, |
date: 'fa fa-calendar', |
||||
locale : moment.locale(), |
|
||||
format : time.getLangDateFormat(), |
}, |
||||
widgetParent: 'body', |
locale: moment.locale(), |
||||
allowInputToggle: true, |
format: time.getLangDateFormat(), |
||||
}; |
widgetParent: 'body', |
||||
|
allowInputToggle: true, |
||||
$calendarInputGroup.datetimepicker(calendarOptions); |
}; |
||||
}, |
|
||||
|
$calendarInputGroup.datetimepicker(calendarOptions); |
||||
|
}, |
||||
load_data: function (initial_render = true) { |
|
||||
var self = this; |
|
||||
self.$(".categ").empty(); |
load_data: function(initial_render = true) { |
||||
try{ |
var self = this; |
||||
var self = this; |
self.$(".categ").empty(); |
||||
self._rpc({ |
try { |
||||
model: 'account.day.book', |
var self = this; |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [[this.wizard_id]], |
model: 'account.day.book', |
||||
}).then(function(datas) { |
method: 'view_report', |
||||
_.each(datas['report_lines'], function(rep_lines) { |
args: [ |
||||
rep_lines.debit = self.format_currency(datas['currency'],rep_lines.debit); |
[this.wizard_id] |
||||
rep_lines.credit = self.format_currency(datas['currency'],rep_lines.credit); |
], |
||||
rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance); |
}).then(function(datas) { |
||||
|
_.each(datas['report_lines'], function(rep_lines) { |
||||
}); |
rep_lines.debit = self.format_currency(datas['currency'], rep_lines.debit); |
||||
|
rep_lines.credit = self.format_currency(datas['currency'], rep_lines.credit); |
||||
if (initial_render) { |
rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance); |
||||
|
|
||||
self.$('.filter_view_db').html(QWeb.render('DayFilterView', { |
}); |
||||
filter_data: datas['filters'], |
|
||||
})); |
if (initial_render) { |
||||
self.$el.find('.journals').select2({ |
|
||||
placeholder: ' Journals...', |
self.$('.filter_view_db').html(QWeb.render('DayFilterView', { |
||||
}); |
filter_data: datas['filters'], |
||||
self.$el.find('.account-partner').select2({ |
})); |
||||
placeholder: ' Accounts...', |
self.$el.find('.journals').select2({ |
||||
}); |
placeholder: ' Journals...', |
||||
self.$el.find('.target_move').select2({ |
}); |
||||
placeholder: 'Target Move...', |
self.$el.find('.account-partner').select2({ |
||||
}); |
placeholder: ' Accounts...', |
||||
|
}); |
||||
|
self.$el.find('.target_move').select2({ |
||||
} |
placeholder: 'Target Move...', |
||||
var child=[]; |
}); |
||||
|
|
||||
self.$('.table_view_db').html(QWeb.render('Daytable', { |
|
||||
|
} |
||||
report_lines : datas['report_lines'], |
var child = []; |
||||
filter : datas['filters'], |
|
||||
currency : datas['currency'], |
self.$('.table_view_db').html(QWeb.render('Daytable', { |
||||
})); |
|
||||
|
report_lines: datas['report_lines'], |
||||
}); |
filter: datas['filters'], |
||||
|
currency: datas['currency'], |
||||
} |
})); |
||||
catch (el) { |
|
||||
window.location.href |
}); |
||||
} |
|
||||
}, |
} catch (el) { |
||||
|
window.location.href |
||||
|
} |
||||
format_currency: function(currency, amount) { |
}, |
||||
if (typeof(amount) != 'number') { |
|
||||
amount = parseFloat(amount); |
|
||||
} |
format_currency: function(currency, amount) { |
||||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
if (typeof(amount) != 'number') { |
||||
minimumFractionDigits: 2 |
amount = parseFloat(amount); |
||||
}) |
} |
||||
return formatted_value |
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
||||
}, |
minimumFractionDigits: 2 |
||||
|
}) |
||||
print_pdf: function(e) { |
return formatted_value |
||||
e.preventDefault(); |
}, |
||||
|
|
||||
var self = this; |
print_pdf: function(e) { |
||||
self._rpc({ |
e.preventDefault(); |
||||
model: 'account.day.book', |
|
||||
method: 'view_report', |
var self = this; |
||||
args: [ |
self._rpc({ |
||||
[self.wizard_id] |
model: 'account.day.book', |
||||
], |
method: 'view_report', |
||||
}).then(function(data) { |
args: [ |
||||
|
[self.wizard_id] |
||||
var action = { |
], |
||||
'type': 'ir.actions.report', |
}).then(function(data) { |
||||
'report_type': 'qweb-pdf', |
|
||||
'report_name': 'dynamic_accounts_report.day_book', |
var action = { |
||||
'report_file': 'dynamic_accounts_report.day_book', |
'type': 'ir.actions.report', |
||||
'data': { |
'report_type': 'qweb-pdf', |
||||
'report_data': data |
'report_name': 'dynamic_accounts_report.day_book', |
||||
}, |
'report_file': 'dynamic_accounts_report.day_book', |
||||
'context': { |
'data': { |
||||
'active_model': 'account.day.book', |
'report_data': data |
||||
'landscape': 1, |
}, |
||||
'daybook_pdf_report': true |
'context': { |
||||
}, |
'active_model': 'account.day.book', |
||||
'display_name': 'Day Book', |
'landscape': 1, |
||||
}; |
'daybook_pdf_report': true |
||||
|
}, |
||||
return self.do_action(action); |
'display_name': 'Day Book', |
||||
}); |
}; |
||||
}, |
|
||||
|
return self.do_action(action); |
||||
print_xlsx: function() { |
}); |
||||
var self = this; |
}, |
||||
self._rpc({ |
|
||||
model: 'account.day.book', |
print_xlsx: function() { |
||||
method: 'view_report', |
var self = this; |
||||
args: [ |
self._rpc({ |
||||
[self.wizard_id] |
model: 'account.day.book', |
||||
], |
method: 'view_report', |
||||
}).then(function(data) { |
args: [ |
||||
var action = { |
[self.wizard_id] |
||||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
], |
||||
'data': { |
}).then(function(data) { |
||||
'model': 'account.day.book', |
var action = { |
||||
'options': JSON.stringify(data['filters']), |
// 'type': 'ir_actions_dynamic_xlsx_download',
|
||||
'output_format': 'xlsx', |
'data': { |
||||
'report_data': JSON.stringify(data['report_lines']), |
'model': 'account.day.book', |
||||
'report_name': 'Day Book', |
'options': JSON.stringify(data['filters']), |
||||
'dfr_data': JSON.stringify(data), |
'output_format': 'xlsx', |
||||
}, |
'report_data': JSON.stringify(data['report_lines']), |
||||
}; |
'report_name': 'Day Book', |
||||
// return self.do_action(action);
|
'dfr_data': JSON.stringify(data), |
||||
self.downloadXlsx(action) |
}, |
||||
}); |
}; |
||||
}, |
// return self.do_action(action);
|
||||
downloadXlsx: function (action){ |
self.downloadXlsx(action) |
||||
framework.blockUI(); |
}); |
||||
session.get_file({ |
}, |
||||
url: '/dynamic_xlsx_reports', |
downloadXlsx: function(action) { |
||||
data: action.data, |
framework.blockUI(); |
||||
complete: framework.unblockUI, |
session.get_file({ |
||||
error: (error) => this.call('crash_manager', 'rpc_error', error), |
url: '/dynamic_xlsx_reports', |
||||
}); |
data: action.data, |
||||
}, |
complete: framework.unblockUI, |
||||
|
error: (error) => this.call('crash_manager', 'rpc_error', error), |
||||
create_lines_with_style: function(rec, attr, datas) { |
}); |
||||
|
}, |
||||
var temp_str = ""; |
|
||||
var style_name = "border-bottom: 1px solid #e6e6e6;"; |
create_lines_with_style: function(rec, attr, datas) { |
||||
var attr_name = attr + " style="+style_name; |
|
||||
temp_str += "<td class='child_col1' "+attr_name+" >"+rec['code'] +rec['name'] +"</td>"; |
var temp_str = ""; |
||||
if(datas.currency[1]=='after'){ |
var style_name = "border-bottom: 1px solid #e6e6e6;"; |
||||
temp_str += "<td class='child_col2' "+attr_name+" >"+rec['debit'].toFixed(2)+datas.currency[0]+"</td>"; |
var attr_name = attr + " style=" + style_name; |
||||
temp_str += "<td class='child_col3' "+attr_name+" >"+rec['credit'].toFixed(2) +datas.currency[0]+ "</td>"; |
temp_str += "<td class='child_col1' " + attr_name + " >" + rec['code'] + rec['name'] + "</td>"; |
||||
} |
if (datas.currency[1] == 'after') { |
||||
else{ |
temp_str += "<td class='child_col2' " + attr_name + " >" + rec['debit'].toFixed(2) + datas.currency[0] + "</td>"; |
||||
temp_str += "<td class='child_col2' "+attr_name+" >"+datas.currency[0]+rec['debit'].toFixed(2) + "</td>"; |
temp_str += "<td class='child_col3' " + attr_name + " >" + rec['credit'].toFixed(2) + datas.currency[0] + "</td>"; |
||||
temp_str += "<td class='child_col3' "+attr_name+">"+datas.currency[0]+rec['credit'].toFixed(2) + "</td>"; |
} else { |
||||
} |
temp_str += "<td class='child_col2' " + attr_name + " >" + datas.currency[0] + rec['debit'].toFixed(2) + "</td>"; |
||||
return temp_str; |
temp_str += "<td class='child_col3' " + attr_name + ">" + datas.currency[0] + rec['credit'].toFixed(2) + "</td>"; |
||||
}, |
} |
||||
|
return temp_str; |
||||
|
}, |
||||
journal_line_click: function (el){ |
|
||||
click_num++; |
|
||||
var self = this; |
journal_line_click: function(el) { |
||||
var line = $(el.target).parent().data('id'); |
click_num++; |
||||
return self.do_action({ |
var self = this; |
||||
type: 'ir.actions.act_window', |
var line = $(el.target).parent().data('id'); |
||||
view_type: 'form', |
return self.do_action({ |
||||
view_mode: 'form', |
type: 'ir.actions.act_window', |
||||
res_model: 'account.move', |
view_type: 'form', |
||||
views: [ |
view_mode: 'form', |
||||
[false, 'form'] |
res_model: 'account.move', |
||||
], |
views: [ |
||||
res_id: line, |
[false, 'form'] |
||||
target: 'current', |
], |
||||
}); |
res_id: line, |
||||
|
target: 'current', |
||||
}, |
}); |
||||
|
|
||||
show_drop_down: function(event) { |
}, |
||||
event.preventDefault(); |
|
||||
var self = this; |
show_drop_down: function(event) { |
||||
var account_id = $(event.currentTarget).data('account-id'); |
event.preventDefault(); |
||||
var offset = 0; |
var self = this; |
||||
var td = $(event.currentTarget).next('tr').find('td'); |
var account_id = $(event.currentTarget).data('account-id'); |
||||
if (td.length == 1) { |
var offset = 0; |
||||
|
var td = $(event.currentTarget).next('tr').find('td'); |
||||
self._rpc({ |
if (td.length == 1) { |
||||
model: 'account.day.book', |
|
||||
method: 'view_report', |
self._rpc({ |
||||
args: [ |
model: 'account.day.book', |
||||
[self.wizard_id] |
method: 'view_report', |
||||
], |
args: [ |
||||
}).then(function(data) { |
[self.wizard_id] |
||||
_.each(data['report_lines'], function(rep_lines) { |
], |
||||
_.each(rep_lines['child_lines'], function(move_line) { |
}).then(function(data) { |
||||
|
_.each(data['report_lines'], function(rep_lines) { |
||||
move_line.debit = self.format_currency(data['currency'],move_line.debit); |
_.each(rep_lines['child_lines'], function(move_line) { |
||||
move_line.credit = self.format_currency(data['currency'],move_line.credit); |
|
||||
move_line.balance = self.format_currency(data['currency'],move_line.balance); |
move_line.debit = self.format_currency(data['currency'], move_line.debit); |
||||
|
move_line.credit = self.format_currency(data['currency'], move_line.credit); |
||||
|
move_line.balance = self.format_currency(data['currency'], move_line.balance); |
||||
}); |
|
||||
}); |
|
||||
for (var i = 0; i < data['report_lines'].length; i++) { |
}); |
||||
|
}); |
||||
if (account_id == data['report_lines'][i]['id'] ){ |
for (var i = 0; i < data['report_lines'].length; i++) { |
||||
$(event.currentTarget).next('tr').find('td').remove(); |
|
||||
$(event.currentTarget).next('tr').after( |
if (account_id == data['report_lines'][i]['id']) { |
||||
QWeb.render('SubSectiondb', { |
$(event.currentTarget).next('tr').find('td').remove(); |
||||
|
$(event.currentTarget).next('tr').after( |
||||
account_data: data['report_lines'][i]['child_lines'], |
QWeb.render('SubSectiondb', { |
||||
currency_symbol : data.currency[0], |
|
||||
id : data['report_lines'][i]['id'], |
account_data: data['report_lines'][i]['child_lines'], |
||||
currency_position : data.currency[1], |
currency_symbol: data.currency[0], |
||||
})) |
id: data['report_lines'][i]['id'], |
||||
|
currency_position: data.currency[1], |
||||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
})) |
||||
'background-color': '#00ede8', |
|
||||
'font-weight': 'bold', |
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
||||
}); |
'background-color': '#00ede8', |
||||
} |
'font-weight': 'bold', |
||||
} |
}); |
||||
|
} |
||||
}); |
} |
||||
} |
|
||||
}, |
}); |
||||
|
} |
||||
view_acc_move: function(event) { |
}, |
||||
|
|
||||
event.preventDefault(); |
view_acc_move: function(event) { |
||||
var self = this; |
|
||||
var context = {}; |
event.preventDefault(); |
||||
var show_acc_move = function(res_model, res_id, view_id) { |
var self = this; |
||||
var action = { |
var context = {}; |
||||
type: 'ir.actions.act_window', |
var show_acc_move = function(res_model, res_id, view_id) { |
||||
view_type: 'form', |
var action = { |
||||
view_mode: 'form', |
type: 'ir.actions.act_window', |
||||
res_model: res_model, |
view_type: 'form', |
||||
views: [ |
view_mode: 'form', |
||||
[view_id || false, 'form'] |
res_model: res_model, |
||||
], |
views: [ |
||||
res_id: res_id, |
[view_id || false, 'form'] |
||||
target: 'current', |
], |
||||
context: context, |
res_id: res_id, |
||||
}; |
target: 'current', |
||||
return self.do_action(action); |
context: context, |
||||
}; |
}; |
||||
rpc.query({ |
return self.do_action(action); |
||||
model: 'account.move', |
}; |
||||
method: 'search_read', |
rpc.query({ |
||||
domain: [ |
model: 'account.move', |
||||
['id', '=', $(event.currentTarget).data('move-id')] |
method: 'search_read', |
||||
], |
domain: [ |
||||
fields: ['id'], |
['id', '=', $(event.currentTarget).data('move-id')] |
||||
limit: 1, |
], |
||||
}) |
fields: ['id'], |
||||
.then(function(record) { |
limit: 1, |
||||
|
}) |
||||
if (record.length > 0) { |
.then(function(record) { |
||||
show_acc_move('account.move', record[0].id); |
|
||||
} else { |
if (record.length > 0) { |
||||
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
show_acc_move('account.move', record[0].id); |
||||
} |
} else { |
||||
}); |
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
||||
}, |
} |
||||
|
}); |
||||
|
}, |
||||
apply_filter: function(event) { |
|
||||
|
|
||||
event.preventDefault(); |
apply_filter: function(event) { |
||||
var self = this; |
event.preventDefault(); |
||||
self.initial_render = false; |
var self = this; |
||||
|
self.initial_render = false; |
||||
var filter_data_selected = {}; |
|
||||
|
var filter_data_selected = {}; |
||||
|
|
||||
var account_ids = []; |
|
||||
var account_text = []; |
var account_ids = []; |
||||
|
var account_text = []; |
||||
var account_res = document.getElementById("acc_res") |
|
||||
|
var account_res = document.getElementById("acc_res") |
||||
var account_list = $(".account-partner").select2('data') |
var account_list = $(".account-partner").select2('data') |
||||
for (var i = 0; i < account_list.length; i++) { |
for (var i = 0; i < account_list.length; i++) { |
||||
if(account_list[i].element[0].selected === true){ |
if (account_list[i].element[0].selected === true) { |
||||
|
|
||||
account_ids.push(parseInt(account_list[i].id)) |
account_ids.push(parseInt(account_list[i].id)) |
||||
if(account_text.includes(account_list[i].text) === false){ |
if (account_text.includes(account_list[i].text) === false) { |
||||
account_text.push(account_list[i].text) |
account_text.push(account_list[i].text) |
||||
} |
} |
||||
account_res.value = account_text |
account_res.value = account_text |
||||
account_res.innerHTML=account_res.value; |
account_res.innerHTML = account_res.value; |
||||
} |
} |
||||
} |
} |
||||
if (account_list.length == 0){ |
if (account_list.length == 0) { |
||||
account_res.value = "" |
account_res.value = "" |
||||
account_res.innerHTML=""; |
account_res.innerHTML = ""; |
||||
|
|
||||
} |
} |
||||
|
|
||||
filter_data_selected.account_ids = account_ids |
filter_data_selected.account_ids = account_ids |
||||
|
|
||||
|
|
||||
|
|
||||
var journal_ids = []; |
var journal_ids = []; |
||||
var journal_text = []; |
var journal_text = []; |
||||
var journal_res = document.getElementById("journal_res") |
var journal_res = document.getElementById("journal_res") |
||||
var journal_list = $(".journals").select2('data') |
var journal_list = $(".journals").select2('data') |
||||
for (var i = 0; i < journal_list.length; i++) { |
for (var i = 0; i < journal_list.length; i++) { |
||||
if(journal_list[i].element[0].selected === true){ |
if (journal_list[i].element[0].selected === true) { |
||||
|
|
||||
journal_ids.push(parseInt(journal_list[i].id)) |
journal_ids.push(parseInt(journal_list[i].id)) |
||||
if(journal_text.includes(journal_list[i].text) === false){ |
if (journal_text.includes(journal_list[i].text) === false) { |
||||
journal_text.push(journal_list[i].text) |
journal_text.push(journal_list[i].text) |
||||
} |
} |
||||
journal_res.value = journal_text |
journal_res.value = journal_text |
||||
journal_res.innerHTML=journal_res.value; |
journal_res.innerHTML = journal_res.value; |
||||
} |
} |
||||
} |
} |
||||
if (journal_list.length == 0){ |
if (journal_list.length == 0) { |
||||
journal_res.value = "" |
journal_res.value = "" |
||||
journal_res.innerHTML=""; |
journal_res.innerHTML = ""; |
||||
|
|
||||
} |
} |
||||
filter_data_selected.journal_ids = journal_ids |
filter_data_selected.journal_ids = journal_ids |
||||
|
|
||||
// if ($("#date_from").val()) {
|
// if ($("#date_from").val()) {
|
||||
// var dateString = $("#date_from").val();
|
// var dateString = $("#date_from").val();
|
||||
//
|
//
|
||||
// filter_data_selected.date_from = dateString;
|
// filter_data_selected.date_from = dateString;
|
||||
// }
|
// }
|
||||
// if ($("#date_to").val()) {
|
// if ($("#date_to").val()) {
|
||||
// var dateString = $("#date_to").val();
|
// var dateString = $("#date_to").val();
|
||||
// filter_data_selected.date_to = dateString;
|
// filter_data_selected.date_to = dateString;
|
||||
// }
|
// }
|
||||
|
|
||||
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
||||
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
} |
} |
||||
|
|
||||
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
||||
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
} |
} |
||||
|
|
||||
if ($(".target_move").length) { |
if ($(".target_move").length) { |
||||
|
|
||||
var post_res = document.getElementById("post_res") |
var post_res = document.getElementById("post_res") |
||||
filter_data_selected.target_move = $(".target_move")[1].value |
filter_data_selected.target_move = $(".target_move")[1].value |
||||
post_res.value = $(".target_move")[1].value |
post_res.value = $(".target_move")[1].value |
||||
post_res.innerHTML=post_res.value; |
post_res.innerHTML = post_res.value; |
||||
if ($(".target_move")[1].value == "") { |
if ($(".target_move")[1].value == "") { |
||||
post_res.innerHTML="posted"; |
post_res.innerHTML = "posted"; |
||||
|
|
||||
} |
} |
||||
} |
} |
||||
|
|
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.day.book', |
model: 'account.day.book', |
||||
method: 'write', |
method: 'write', |
||||
args: [ |
args: [ |
||||
self.wizard_id, filter_data_selected |
self.wizard_id, filter_data_selected |
||||
], |
], |
||||
}).then(function(res) { |
}).then(function(res) { |
||||
self.initial_render = false; |
self.initial_render = false; |
||||
self.load_data(self.initial_render); |
self.load_data(self.initial_render); |
||||
}); |
}); |
||||
}, |
}, |
||||
|
|
||||
}); |
}); |
||||
core.action_registry.add("d_b", DayBook); |
core.action_registry.add("d_b", DayBook); |
||||
return DayBook; |
return DayBook; |
||||
}); |
}); |
@ -1,509 +1,471 @@ |
|||||
odoo.define('dynamic_accounts_report.general_ledger', function (require) { |
odoo.define('dynamic_accounts_report.general_ledger', function(require) { |
||||
'use strict'; |
'use strict'; |
||||
var AbstractAction = require('web.AbstractAction'); |
var AbstractAction = require('web.AbstractAction'); |
||||
var core = require('web.core'); |
var core = require('web.core'); |
||||
var field_utils = require('web.field_utils'); |
var field_utils = require('web.field_utils'); |
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
var session = require('web.session'); |
var session = require('web.session'); |
||||
var utils = require('web.utils'); |
var utils = require('web.utils'); |
||||
var QWeb = core.qweb; |
var QWeb = core.qweb; |
||||
var _t = core._t; |
var _t = core._t; |
||||
var trial = require('dynamic_accounts_report.trial_balance'); |
var trial = require('dynamic_accounts_report.trial_balance'); |
||||
var framework = require('web.framework'); |
var framework = require('web.framework'); |
||||
|
|
||||
var datepicker = require('web.datepicker'); |
var datepicker = require('web.datepicker'); |
||||
var time = require('web.time'); |
var time = require('web.time'); |
||||
|
window.click_num = 0; |
||||
window.click_num = 0; |
var GeneralLedger = AbstractAction.extend({ |
||||
var GeneralLedger = AbstractAction.extend({ |
template: 'GeneralTemp', |
||||
template: 'GeneralTemp', |
events: { |
||||
events: { |
'click .parent-line': 'journal_line_click', |
||||
'click .parent-line': 'journal_line_click', |
'click .child_col1': 'journal_line_click', |
||||
'click .child_col1': 'journal_line_click', |
'click #apply_filter': 'apply_filter', |
||||
'click #apply_filter': 'apply_filter', |
'click #pdf': 'print_pdf', |
||||
'click #pdf': 'print_pdf', |
'click #xlsx': 'print_xlsx', |
||||
'click #xlsx': 'print_xlsx', |
'click .gl-line': 'show_drop_down', |
||||
'click .gl-line': 'show_drop_down', |
'click .view-account-move': 'view_acc_move', |
||||
'click .view-account-move': 'view_acc_move', |
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
||||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
}, |
||||
}, |
init: function(parent, action) { |
||||
|
this._super(parent, action); |
||||
init: function(parent, action) { |
this.currency = action.currency; |
||||
this._super(parent, action); |
this.report_lines = action.report_lines; |
||||
this.currency=action.currency; |
this.wizard_id = action.context.wizard | null; |
||||
this.report_lines = action.report_lines; |
}, |
||||
this.wizard_id = action.context.wizard | null; |
start: function() { |
||||
}, |
var self = this; |
||||
|
self.initial_render = true; |
||||
|
if (this.searchModel.config.domain.length != 0) { |
||||
start: function() { |
rpc.query({ |
||||
var self = this; |
model: 'account.general.ledger', |
||||
self.initial_render = true; |
method: 'create', |
||||
if (this.searchModel.config.domain.length != 0) { |
args: [{ |
||||
rpc.query({ |
account_ids: [this.searchModel.config.domain[0][2]] |
||||
model: 'account.general.ledger', |
}] |
||||
method: 'create', |
}).then(function(t_res) { |
||||
args: [{ |
self.wizard_id = t_res; |
||||
account_ids : [this.searchModel.config.domain[0][2]] |
self.load_data(self.initial_render); |
||||
}] |
}) |
||||
}).then(function(t_res) { |
} else { |
||||
self.wizard_id = t_res; |
rpc.query({ |
||||
self.load_data(self.initial_render); |
model: 'account.general.ledger', |
||||
}) |
method: 'create', |
||||
}else{ |
args: [{}] |
||||
rpc.query({ |
}).then(function(t_res) { |
||||
model: 'account.general.ledger', |
self.wizard_id = t_res; |
||||
method: 'create', |
self.load_data(self.initial_render); |
||||
args: [{ |
}) |
||||
|
} |
||||
}] |
}, |
||||
}).then(function(t_res) { |
|
||||
self.wizard_id = t_res; |
_onCalendarIconClick: function(ev) { |
||||
self.load_data(self.initial_render); |
var $calendarInputGroup = $(ev.currentTarget); |
||||
}) |
var calendarOptions = { |
||||
} |
minDate: moment({ |
||||
}, |
y: 1000 |
||||
|
}), |
||||
|
maxDate: moment().add(200, 'y'), |
||||
_onCalendarIconClick: function (ev) { |
calendarWeeks: true, |
||||
var $calendarInputGroup = $(ev.currentTarget); |
defaultDate: moment().format(), |
||||
|
sideBySide: true, |
||||
var calendarOptions = { |
buttons: { |
||||
|
showClear: true, |
||||
minDate: moment({ y: 1000 }), |
showClose: true, |
||||
maxDate: moment().add(200, 'y'), |
showToday: true, |
||||
calendarWeeks: true, |
}, |
||||
defaultDate: moment().format(), |
icons: { |
||||
sideBySide: true, |
date: 'fa fa-calendar', |
||||
buttons: { |
}, |
||||
showClear: true, |
locale: moment.locale(), |
||||
showClose: true, |
format: time.getLangDateFormat(), |
||||
showToday: true, |
widgetParent: 'body', |
||||
}, |
allowInputToggle: true, |
||||
|
}; |
||||
icons : { |
|
||||
date: 'fa fa-calendar', |
$calendarInputGroup.datetimepicker(calendarOptions); |
||||
|
}, |
||||
}, |
|
||||
locale : moment.locale(), |
load_data: function(initial_render = true) { |
||||
format : time.getLangDateFormat(), |
var self = this; |
||||
widgetParent: 'body', |
self.$(".categ").empty(); |
||||
allowInputToggle: true, |
try { |
||||
}; |
var self = this; |
||||
|
var action_title = self._title |
||||
$calendarInputGroup.datetimepicker(calendarOptions); |
self._rpc({ |
||||
}, |
model: 'account.general.ledger', |
||||
|
method: 'view_report', |
||||
|
args: [ |
||||
load_data: function (initial_render = true) { |
[this.wizard_id], action_title |
||||
var self = this; |
], |
||||
self.$(".categ").empty(); |
}).then(function(datas) { |
||||
try{ |
// _.each(datas['report_lines'], function(rep_lines) {
|
||||
var self = this; |
// rep_lines.debit = self.format_currency(datas['currency'],rep_lines.debit);
|
||||
var action_title = self._title |
// rep_lines.credit = self.format_currency(datas['currency'],rep_lines.credit);
|
||||
self._rpc({ |
// rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance);
|
||||
model: 'account.general.ledger', |
// });
|
||||
method: 'view_report', |
|
||||
args: [[this.wizard_id], action_title], |
if (initial_render) { |
||||
}).then(function(datas) { |
self.$('.filter_view_tb').html(QWeb.render('GLFilterView', { |
||||
// _.each(datas['report_lines'], function(rep_lines) {
|
filter_data: datas['filters'], |
||||
// rep_lines.debit = self.format_currency(datas['currency'],rep_lines.debit);
|
title: datas['name'], |
||||
// rep_lines.credit = self.format_currency(datas['currency'],rep_lines.credit);
|
// eng_title : datas['eng_title'],
|
||||
// rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance);
|
})); |
||||
//
|
self.$el.find('.journals').select2({ |
||||
//
|
placeholder: ' Journals...', |
||||
//
|
}); |
||||
//
|
self.$el.find('.account-partner').select2({ |
||||
// });
|
placeholder: ' Accounts...', |
||||
|
}); |
||||
if (initial_render) { |
self.$el.find('.account-tag').select2({ |
||||
self.$('.filter_view_tb').html(QWeb.render('GLFilterView', { |
placeholder: ' Account Tag...', |
||||
filter_data: datas['filters'], |
}); |
||||
title : datas['name'], |
self.$el.find('.analytics').select2({ |
||||
// eng_title : datas['eng_title'],
|
placeholder: 'Analytic Accounts...', |
||||
})); |
}); |
||||
self.$el.find('.journals').select2({ |
self.$el.find('.target_move').select2({ |
||||
placeholder: ' Journals...', |
placeholder: 'Target Move...', |
||||
}); |
}); |
||||
self.$el.find('.account-partner').select2({ |
} |
||||
placeholder: ' Accounts...', |
var child = []; |
||||
}); |
self.$('.table_view_tb').html(QWeb.render('GLTable', { |
||||
self.$el.find('.analytics').select2({ |
report_lines: datas['report_lines'], |
||||
placeholder: 'Analytic Accounts...', |
filter: datas['filters'], |
||||
}); |
currency: datas['currency'], |
||||
// self.$el.find('.analytic_tags').select2({
|
credit_total: datas['credit_total'], |
||||
// placeholder: 'Analytic Tags...',
|
debit_total: datas['debit_total'], |
||||
// });
|
debit_balance: datas['debit_balance'] |
||||
self.$el.find('.target_move').select2({ |
})); |
||||
placeholder: 'Target Move...', |
}); |
||||
}); |
} catch (el) { |
||||
|
window.location.href |
||||
} |
} |
||||
var child=[]; |
}, |
||||
self.$('.table_view_tb').html(QWeb.render('GLTable', { |
|
||||
|
print_pdf: function(e) { |
||||
report_lines : datas['report_lines'], |
e.preventDefault(); |
||||
filter : datas['filters'], |
var self = this; |
||||
currency : datas['currency'], |
var action_title = self._title |
||||
credit_total : datas['credit_total'], |
self._rpc({ |
||||
debit_total : datas['debit_total'], |
model: 'account.general.ledger', |
||||
debit_balance : datas['debit_balance'] |
method: 'view_report', |
||||
})); |
args: [ |
||||
|
[self.wizard_id], action_title |
||||
}); |
], |
||||
|
}).then(function(data) { |
||||
} |
var action = { |
||||
catch (el) { |
'type': 'ir.actions.report', |
||||
window.location.href |
'report_type': 'qweb-pdf', |
||||
} |
'report_name': 'dynamic_accounts_report.general_ledger', |
||||
}, |
'report_file': 'dynamic_accounts_report.general_ledger', |
||||
|
'data': { |
||||
print_pdf: function(e) { |
'report_data': data |
||||
e.preventDefault(); |
}, |
||||
var self = this; |
'context': { |
||||
var action_title = self._title |
'active_model': 'account.general.ledger', |
||||
self._rpc({ |
'landscape': 1, |
||||
model: 'account.general.ledger', |
'trial_pdf_report': true |
||||
method: 'view_report', |
}, |
||||
args: [ |
'display_name': action_title, |
||||
[self.wizard_id], action_title |
}; |
||||
], |
return self.do_action(action); |
||||
}).then(function(data) { |
}); |
||||
var action = { |
}, |
||||
'type': 'ir.actions.report', |
|
||||
'report_type': 'qweb-pdf', |
print_xlsx: function() { |
||||
'report_name': 'dynamic_accounts_report.general_ledger', |
var self = this; |
||||
'report_file': 'dynamic_accounts_report.general_ledger', |
var action_title = self._title |
||||
'data': { |
self._rpc({ |
||||
'report_data': data |
model: 'account.general.ledger', |
||||
}, |
method: 'view_report', |
||||
'context': { |
args: [ |
||||
'active_model': 'account.general.ledger', |
[self.wizard_id], action_title |
||||
'landscape': 1, |
], |
||||
'trial_pdf_report': true |
}).then(function(data) { |
||||
}, |
var action = { |
||||
'display_name': action_title, |
// 'type': 'ir_actions_dynamic_xlsx_download',
|
||||
}; |
'data': { |
||||
return self.do_action(action); |
'model': 'account.general.ledger', |
||||
}); |
'options': JSON.stringify(data['filters']), |
||||
}, |
'output_format': 'xlsx', |
||||
|
'report_data': JSON.stringify(data['report_lines']), |
||||
print_xlsx: function() { |
'report_name': action_title, |
||||
var self = this; |
'dfr_data': JSON.stringify(data), |
||||
var action_title = self._title |
}, |
||||
self._rpc({ |
}; |
||||
model: 'account.general.ledger', |
// return self.do_action(action);
|
||||
method: 'view_report', |
self.downloadXlsx(action) |
||||
args: [ |
}); |
||||
[self.wizard_id], action_title |
}, |
||||
], |
|
||||
}).then(function(data) { |
downloadXlsx: function(action) { |
||||
var action = { |
framework.blockUI(); |
||||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
session.get_file({ |
||||
'data': { |
url: '/dynamic_xlsx_reports', |
||||
'model': 'account.general.ledger', |
data: action.data, |
||||
'options': JSON.stringify(data['filters']), |
complete: framework.unblockUI, |
||||
'output_format': 'xlsx', |
error: (error) => this.call('crash_manager', 'rpc_error', error), |
||||
'report_data': JSON.stringify(data['report_lines']), |
}); |
||||
'report_name': action_title, |
}, |
||||
'dfr_data': JSON.stringify(data), |
|
||||
}, |
create_lines_with_style: function(rec, attr, datas) { |
||||
}; |
var temp_str = ""; |
||||
// return self.do_action(action);
|
var style_name = "border-bottom: 1px solid #e6e6e6;"; |
||||
self.downloadXlsx(action) |
var attr_name = attr + " style=" + style_name; |
||||
}); |
|
||||
}, |
temp_str += "<td class='child_col1' " + attr_name + " >" + rec['code'] + rec['name'] + "</td>"; |
||||
|
if (datas.currency[1] == 'after') { |
||||
downloadXlsx: function (action){ |
temp_str += "<td class='child_col2' " + attr_name + " >" + rec['debit'].toFixed(2) + datas.currency[0] + "</td>"; |
||||
framework.blockUI(); |
temp_str += "<td class='child_col3' " + attr_name + " >" + rec['credit'].toFixed(2) + datas.currency[0] + "</td>"; |
||||
session.get_file({ |
} else { |
||||
url: '/dynamic_xlsx_reports', |
temp_str += "<td class='child_col2' " + attr_name + " >" + datas.currency[0] + rec['debit'].toFixed(2) + "</td>"; |
||||
data: action.data, |
temp_str += "<td class='child_col3' " + attr_name + ">" + datas.currency[0] + rec['credit'].toFixed(2) + "</td>"; |
||||
complete: framework.unblockUI, |
|
||||
error: (error) => this.call('crash_manager', 'rpc_error', error), |
} |
||||
}); |
return temp_str; |
||||
}, |
}, |
||||
|
|
||||
|
journal_line_click: function(el) { |
||||
|
click_num++; |
||||
create_lines_with_style: function(rec, attr, datas) { |
var self = this; |
||||
var temp_str = ""; |
var line = $(el.target).parent().data('id'); |
||||
var style_name = "border-bottom: 1px solid #e6e6e6;"; |
return self.do_action({ |
||||
var attr_name = attr + " style="+style_name; |
type: 'ir.actions.act_window', |
||||
|
view_type: 'form', |
||||
temp_str += "<td class='child_col1' "+attr_name+" >"+rec['code'] +rec['name'] +"</td>"; |
view_mode: 'form', |
||||
if(datas.currency[1]=='after'){ |
res_model: 'account.move', |
||||
temp_str += "<td class='child_col2' "+attr_name+" >"+rec['debit'].toFixed(2)+datas.currency[0]+"</td>"; |
views: [ |
||||
temp_str += "<td class='child_col3' "+attr_name+" >"+rec['credit'].toFixed(2) +datas.currency[0]+ "</td>"; |
[false, 'form'] |
||||
} |
], |
||||
else{ |
res_id: line, |
||||
temp_str += "<td class='child_col2' "+attr_name+" >"+datas.currency[0]+rec['debit'].toFixed(2) + "</td>"; |
target: 'current', |
||||
temp_str += "<td class='child_col3' "+attr_name+">"+datas.currency[0]+rec['credit'].toFixed(2) + "</td>"; |
}); |
||||
|
|
||||
} |
}, |
||||
return temp_str; |
|
||||
}, |
format_currency: function(currency, amount) { |
||||
|
if (typeof(amount) != 'number') { |
||||
|
amount = parseFloat(amount); |
||||
journal_line_click: function (el){ |
} |
||||
click_num++; |
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
||||
var self = this; |
minimumFractionDigits: 2 |
||||
var line = $(el.target).parent().data('id'); |
}) |
||||
return self.do_action({ |
return formatted_value |
||||
type: 'ir.actions.act_window', |
}, |
||||
view_type: 'form', |
|
||||
view_mode: 'form', |
show_drop_down: function(event) { |
||||
res_model: 'account.move', |
event.preventDefault(); |
||||
views: [ |
var self = this; |
||||
[false, 'form'] |
var account_id = $(event.currentTarget).data('account-id'); |
||||
], |
var offset = 0; |
||||
res_id: line, |
var td = $(event.currentTarget).next('tr').find('td'); |
||||
target: 'current', |
if (td.length == 1) { |
||||
}); |
var action_title = self._title |
||||
|
self._rpc({ |
||||
}, |
model: 'account.general.ledger', |
||||
format_currency: function(currency, amount) { |
method: 'get_accounts_line', |
||||
if (typeof(amount) != 'number') { |
args: [ |
||||
amount = parseFloat(amount); |
[self.wizard_id], account_id, action_title |
||||
} |
], |
||||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
}).then(function(data) { |
||||
minimumFractionDigits: 2 |
// _.each(data['report_lines'], function(rep_lines) {
|
||||
}) |
// _.each(rep_lines['move_lines'], function(move_line) {
|
||||
return formatted_value |
//
|
||||
}, |
// move_line.debit = self.format_currency(data['currency'],move_line.debit);
|
||||
|
// move_line.credit = self.format_currency(data['currency'],move_line.credit);
|
||||
show_drop_down: function(event) { |
// move_line.balance = self.format_currency(data['currency'],move_line.balance);
|
||||
event.preventDefault(); |
//
|
||||
var self = this; |
//
|
||||
var account_id = $(event.currentTarget).data('account-id'); |
// });
|
||||
var offset = 0; |
// });
|
||||
var td = $(event.currentTarget).next('tr').find('td'); |
|
||||
if (td.length == 1) { |
for (var i = 0; i < data['report_lines'].length; i++) { |
||||
var action_title = self._title |
|
||||
self._rpc({ |
if (account_id == data['report_lines'][i]['id']) { |
||||
model: 'account.general.ledger', |
$(event.currentTarget).next('tr').find('td').remove(); |
||||
method: 'get_accounts_line', |
$(event.currentTarget).next('tr').after( |
||||
args: [ |
QWeb.render('SubSection', { |
||||
[self.wizard_id], account_id, action_title |
account_data: data['report_lines'][i]['move_lines'], |
||||
], |
currency_symbol: data.currency[0], |
||||
}).then(function(data) { |
id: data['report_lines'][i]['id'], |
||||
// _.each(data['report_lines'], function(rep_lines) {
|
currency_position: data.currency[1], |
||||
// _.each(rep_lines['move_lines'], function(move_line) {
|
|
||||
//
|
})) |
||||
// move_line.debit = self.format_currency(data['currency'],move_line.debit);
|
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
||||
// move_line.credit = self.format_currency(data['currency'],move_line.credit);
|
'background-color': '#00ede8', |
||||
// move_line.balance = self.format_currency(data['currency'],move_line.balance);
|
'font-weight': 'bold', |
||||
//
|
}); |
||||
//
|
} |
||||
// });
|
} |
||||
// });
|
|
||||
|
}); |
||||
for (var i = 0; i < data['report_lines'].length; i++) { |
} |
||||
|
}, |
||||
if (account_id == data['report_lines'][i]['id'] ){ |
|
||||
$(event.currentTarget).next('tr').find('td').remove(); |
view_acc_move: function(event) { |
||||
$(event.currentTarget).next('tr').after( |
event.preventDefault(); |
||||
QWeb.render('SubSection', { |
var self = this; |
||||
account_data: data['report_lines'][i]['move_lines'], |
var context = {}; |
||||
currency_symbol : data.currency[0], |
var show_acc_move = function(res_model, res_id, view_id) { |
||||
id : data['report_lines'][i]['id'], |
var action = { |
||||
currency_position : data.currency[1], |
type: 'ir.actions.act_window', |
||||
|
view_type: 'form', |
||||
})) |
view_mode: 'form', |
||||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
res_model: res_model, |
||||
'background-color': '#00ede8', |
views: [ |
||||
'font-weight': 'bold', |
[view_id || false, 'form'] |
||||
}); |
], |
||||
} |
res_id: res_id, |
||||
} |
target: 'current', |
||||
|
context: context, |
||||
}); |
}; |
||||
} |
return self.do_action(action); |
||||
}, |
}; |
||||
|
rpc.query({ |
||||
view_acc_move: function(event) { |
model: 'account.move', |
||||
event.preventDefault(); |
method: 'search_read', |
||||
var self = this; |
domain: [ |
||||
var context = {}; |
['id', '=', $(event.currentTarget).data('move-id')] |
||||
var show_acc_move = function(res_model, res_id, view_id) { |
], |
||||
var action = { |
fields: ['id'], |
||||
type: 'ir.actions.act_window', |
limit: 1, |
||||
view_type: 'form', |
}) |
||||
view_mode: 'form', |
.then(function(record) { |
||||
res_model: res_model, |
if (record.length > 0) { |
||||
views: [ |
show_acc_move('account.move', record[0].id); |
||||
[view_id || false, 'form'] |
} else { |
||||
], |
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
||||
res_id: res_id, |
} |
||||
target: 'current', |
}); |
||||
context: context, |
}, |
||||
}; |
|
||||
return self.do_action(action); |
apply_filter: function(event) { |
||||
}; |
event.preventDefault(); |
||||
rpc.query({ |
var self = this; |
||||
model: 'account.move', |
self.initial_render = false; |
||||
method: 'search_read', |
var filter_data_selected = {}; |
||||
domain: [ |
|
||||
['id', '=', $(event.currentTarget).data('move-id')] |
//Account filter
|
||||
], |
var account_ids = []; |
||||
fields: ['id'], |
var account_text = []; |
||||
limit: 1, |
var account_res = document.getElementById("account_res") |
||||
}) |
var account_list = $(".account-partner").select2('data') |
||||
.then(function(record) { |
for (var i = 0; i < account_list.length; i++) { |
||||
if (record.length > 0) { |
if (account_list[i].element[0].selected === true) { |
||||
show_acc_move('account.move', record[0].id); |
account_ids.push(parseInt(account_list[i].id)) |
||||
} else { |
if (account_text.includes(account_list[i].text) === false) { |
||||
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
account_text.push(account_list[i].text) |
||||
} |
} |
||||
}); |
account_res.value = account_text |
||||
}, |
account_res.innerHTML = account_res.value; |
||||
|
} |
||||
apply_filter: function(event) { |
} |
||||
event.preventDefault(); |
if (account_list.length == 0) { |
||||
var self = this; |
account_res.value = "" |
||||
self.initial_render = false; |
account_res.innerHTML = ""; |
||||
|
} |
||||
var filter_data_selected = {}; |
filter_data_selected.account_ids = account_ids |
||||
|
|
||||
|
//Account Tag filter
|
||||
var account_ids = []; |
var account_tag_ids = []; |
||||
var account_text = []; |
var account_tag_text = []; |
||||
|
var account_tag_res = document.getElementById("acc_tag_res") |
||||
var account_res = document.getElementById("acc_res") |
|
||||
var account_list = $(".account-partner").select2('data') |
var account_tag_list = $(".account-tag").select2('data') |
||||
for (var i = 0; i < account_list.length; i++) { |
for (var i = 0; i < account_tag_list.length; i++) { |
||||
if(account_list[i].element[0].selected === true){ |
if (account_tag_list[i].element[0].selected === true) { |
||||
account_ids.push(parseInt(account_list[i].id)) |
|
||||
if(account_text.includes(account_list[i].text) === false){ |
account_tag_ids.push(parseInt(account_tag_list[i].id)) |
||||
account_text.push(account_list[i].text) |
if (account_tag_text.includes(account_tag_list[i].text) === false) { |
||||
} |
account_tag_text.push(account_tag_list[i].text) |
||||
account_res.value = account_text |
} |
||||
account_res.innerHTML=account_res.value; |
|
||||
} |
account_tag_res.value = account_tag_text |
||||
} |
account_tag_res.innerHTML = account_tag_res.value; |
||||
if (account_list.length == 0){ |
} |
||||
account_res.value = "" |
} |
||||
account_res.innerHTML=""; |
if (account_tag_list.length == 0) { |
||||
|
account_tag_res.value = "" |
||||
} |
account_tag_res.innerHTML = ""; |
||||
filter_data_selected.account_ids = account_ids |
|
||||
|
} |
||||
|
filter_data_selected.account_tag_ids = account_tag_ids |
||||
if(!(this._title == 'Bank Book' || this._title == 'Cash Book')){ |
|
||||
|
//Journal Filter
|
||||
var journal_ids = []; |
if (!(this._title == 'Bank Book' || this._title == 'Cash Book')) { |
||||
var journal_text = []; |
var journal_ids = []; |
||||
var journal_res = document.getElementById("journal_res") |
var journal_text = []; |
||||
var journal_list = $(".journals").select2('data') |
var journal_res = document.getElementById("journal_res") |
||||
|
var journal_list = $(".journals").select2('data') |
||||
for (var i = 0; i < journal_list.length; i++) { |
for (var i = 0; i < journal_list.length; i++) { |
||||
if(journal_list[i].element[0].selected === true){ |
if (journal_list[i].element[0].selected === true) { |
||||
|
journal_ids.push(parseInt(journal_list[i].id)) |
||||
journal_ids.push(parseInt(journal_list[i].id)) |
if (journal_text.includes(journal_list[i].text) === false) { |
||||
if(journal_text.includes(journal_list[i].text) === false){ |
journal_text.push(journal_list[i].text) |
||||
journal_text.push(journal_list[i].text) |
} |
||||
} |
journal_res.value = journal_text |
||||
journal_res.value = journal_text |
journal_res.innerHTML = journal_res.value; |
||||
journal_res.innerHTML=journal_res.value; |
} |
||||
} |
} |
||||
} |
if (journal_list.length == 0) { |
||||
if (journal_list.length == 0){ |
journal_res.value = "" |
||||
journal_res.value = "" |
journal_res.innerHTML = ""; |
||||
journal_res.innerHTML=""; |
} |
||||
|
filter_data_selected.journal_ids = journal_ids |
||||
} |
} |
||||
filter_data_selected.journal_ids = journal_ids |
|
||||
|
//Analytic Filter
|
||||
} |
var analytic_ids = []; |
||||
|
var analytic_text = []; |
||||
|
var analytic_res = document.getElementById("analytic_res") |
||||
|
var analytic_list = $(".analytics").select2('data') |
||||
// var analytic_ids = []
|
for (var i = 0; i < analytic_list.length; i++) { |
||||
// var analytic_text = [];
|
if (analytic_list[i].element[0].selected === true) { |
||||
//// var analytic_res = document.getElementById("analytic_res")
|
analytic_ids.push(parseInt(analytic_list[i].id)) |
||||
// var analytic_list = $(".analytics").select2('data')
|
if (analytic_text.includes(analytic_list[i].text) === false) { |
||||
//
|
analytic_text.push(analytic_list[i].text) |
||||
// for (var i = 0; i < analytic_list.length; i++) {
|
} |
||||
// if(analytic_list[i].element[0].selected === true){
|
analytic_res.value = analytic_text |
||||
//
|
analytic_res.innerHTML = analytic_res.value; |
||||
// analytic_ids.push(parseInt(analytic_list[i].id))
|
} |
||||
// if(analytic_text.includes(analytic_list[i].text) === false){
|
} |
||||
// analytic_text.push(analytic_list[i].text)
|
if (analytic_list.length == 0) { |
||||
// }
|
analytic_res.value = "" |
||||
// analytic_res.value = analytic_text
|
analytic_res.innerHTML = ""; |
||||
// analytic_res.innerHTML=analytic_res.value;
|
} |
||||
// }
|
filter_data_selected.analytic_ids = analytic_ids |
||||
// }
|
|
||||
// if (analytic_list.length == 0){
|
//Date range filter
|
||||
// analytic_res.value = ""
|
if (this.$el.find('.datetimepicker-input[name="gen_date_from"]').val()) { |
||||
// analytic_res.innerHTML="";
|
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="gen_date_from"]').val(), |
||||
//
|
time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
// }
|
} |
||||
// filter_data_selected.analytic_ids = analytic_ids
|
if (this.$el.find('.datetimepicker-input[name="gen_date_to"]').val()) { |
||||
//
|
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="gen_date_to"]').val(), |
||||
// var analytic_tag_ids = []
|
time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
// var analytic_tag_text = [];
|
} |
||||
// var analytic_tag_res = document.getElementById("analytic_tag_res")
|
|
||||
// var analytic_tag_list = $(".analytic_tags").select2('data')
|
//Target Move Filter
|
||||
// for (var i = 0; i < analytic_tag_list.length; i++) {
|
if ($(".target_move").length) { |
||||
// if(analytic_tag_list[i].element[0].selected === true){
|
var post_res = document.getElementById("post_res") |
||||
//
|
filter_data_selected.target_move = $(".target_move")[1].value |
||||
// analytic_tag_ids.push(parseInt(analytic_tag_list[i].id))
|
post_res.value = $(".target_move")[1].value |
||||
// if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){
|
post_res.innerHTML = post_res.value; |
||||
// analytic_tag_text.push(analytic_tag_list[i].text)
|
if ($(".target_move")[1].value == "") { |
||||
// }
|
post_res.innerHTML = "posted"; |
||||
// analytic_tag_res.value = analytic_tag_text
|
} |
||||
// analytic_tag_res.innerHTML=analytic_tag_res.value;
|
} |
||||
// }
|
rpc.query({ |
||||
// }
|
model: 'account.general.ledger', |
||||
// if (analytic_tag_list.length == 0){
|
method: 'write', |
||||
// analytic_tag_res.value = ""
|
args: [ |
||||
// analytic_tag_res.innerHTML="";
|
self.wizard_id, filter_data_selected |
||||
//
|
], |
||||
// }
|
}).then(function(res) { |
||||
// filter_data_selected.analytic_tag_ids = analytic_tag_ids
|
self.initial_render = false; |
||||
|
self.load_data(self.initial_render); |
||||
// if ($("#date_from").val()) {
|
}); |
||||
//
|
}, |
||||
// var dateString = $("#date_from").val();
|
}); |
||||
// filter_data_selected.date_from = dateString;
|
core.action_registry.add("g_l", GeneralLedger); |
||||
// }
|
return GeneralLedger; |
||||
// if ($("#date_to").val()) {
|
|
||||
// var dateString = $("#date_to").val();
|
|
||||
// filter_data_selected.date_to = dateString;
|
|
||||
// }
|
|
||||
|
|
||||
if (this.$el.find('.datetimepicker-input[name="gen_date_from"]').val()) { |
|
||||
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="gen_date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
|
||||
} |
|
||||
|
|
||||
if (this.$el.find('.datetimepicker-input[name="gen_date_to"]').val()) { |
|
||||
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="gen_date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
|
||||
} |
|
||||
|
|
||||
if ($(".target_move").length) { |
|
||||
var post_res = document.getElementById("post_res") |
|
||||
filter_data_selected.target_move = $(".target_move")[1].value |
|
||||
post_res.value = $(".target_move")[1].value |
|
||||
post_res.innerHTML=post_res.value; |
|
||||
if ($(".target_move")[1].value == "") { |
|
||||
post_res.innerHTML="posted"; |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
rpc.query({ |
|
||||
model: 'account.general.ledger', |
|
||||
method: 'write', |
|
||||
args: [ |
|
||||
self.wizard_id, filter_data_selected |
|
||||
], |
|
||||
}).then(function(res) { |
|
||||
self.initial_render = false; |
|
||||
self.load_data(self.initial_render); |
|
||||
}); |
|
||||
}, |
|
||||
|
|
||||
}); |
|
||||
core.action_registry.add("g_l", GeneralLedger); |
|
||||
return GeneralLedger; |
|
||||
}); |
}); |
@ -1,473 +1,461 @@ |
|||||
odoo.define('dynamic_accounts_report.partner_ledger', function (require) { |
odoo.define('dynamic_accounts_report.partner_ledger', function(require) { |
||||
'use strict'; |
'use strict'; |
||||
var AbstractAction = require('web.AbstractAction'); |
var AbstractAction = require('web.AbstractAction'); |
||||
var core = require('web.core'); |
var core = require('web.core'); |
||||
var field_utils = require('web.field_utils'); |
var field_utils = require('web.field_utils'); |
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
var session = require('web.session'); |
var session = require('web.session'); |
||||
var utils = require('web.utils'); |
var utils = require('web.utils'); |
||||
var QWeb = core.qweb; |
var QWeb = core.qweb; |
||||
var _t = core._t; |
var _t = core._t; |
||||
|
var datepicker = require('web.datepicker'); |
||||
var datepicker = require('web.datepicker'); |
var time = require('web.time'); |
||||
var time = require('web.time'); |
var framework = require('web.framework'); |
||||
|
|
||||
window.click_num = 0; |
window.click_num = 0; |
||||
var PartnerLedger = AbstractAction.extend({ |
var PartnerLedger = AbstractAction.extend({ |
||||
template: 'PartnerTemp', |
template: 'PartnerTemp', |
||||
events: { |
events: { |
||||
'click .parent-line': 'journal_line_click', |
'click .parent-line': 'journal_line_click', |
||||
'click .child_col1': 'journal_line_click', |
'click .child_col1': 'journal_line_click', |
||||
'click #apply_filter': 'apply_filter', |
'click #apply_filter': 'apply_filter', |
||||
'click #pdf': 'print_pdf', |
'click #pdf': 'print_pdf', |
||||
'click #xlsx': 'print_xlsx', |
'click #xlsx': 'print_xlsx', |
||||
'click .pl-line': 'show_drop_down', |
'click .pl-line': 'show_drop_down', |
||||
'click .view-account-move': 'view_acc_move', |
'click .view-account-move': 'view_acc_move', |
||||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
||||
|
|
||||
}, |
}, |
||||
|
|
||||
init: function(parent, action) { |
init: function(parent, action) { |
||||
this._super(parent, action); |
this._super(parent, action); |
||||
this.currency=action.currency; |
this.currency = action.currency; |
||||
this.report_lines = action.report_lines; |
this.report_lines = action.report_lines; |
||||
this.wizard_id = action.context.wizard | null; |
this.wizard_id = action.context.wizard | null; |
||||
}, |
}, |
||||
|
|
||||
start: function() { |
start: function() { |
||||
var self = this; |
var self = this; |
||||
self.initial_render = true; |
self.initial_render = true; |
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.partner.ledger', |
model: 'account.partner.ledger', |
||||
method: 'create', |
method: 'create', |
||||
args: [{ |
args: [{}] |
||||
}] |
}).then(function(t_res) { |
||||
}).then(function(t_res) { |
self.wizard_id = t_res; |
||||
self.wizard_id = t_res; |
self.load_data(self.initial_render); |
||||
self.load_data(self.initial_render); |
}) |
||||
}) |
}, |
||||
}, |
|
||||
|
_onCalendarIconClick: function(ev) { |
||||
_onCalendarIconClick: function (ev) { |
var $calendarInputGroup = $(ev.currentTarget); |
||||
var $calendarInputGroup = $(ev.currentTarget); |
|
||||
|
var calendarOptions = { |
||||
var calendarOptions = { |
|
||||
|
minDate: moment({ |
||||
minDate: moment({ y: 1000 }), |
y: 1000 |
||||
maxDate: moment().add(200, 'y'), |
}), |
||||
calendarWeeks: true, |
maxDate: moment().add(200, 'y'), |
||||
defaultDate: moment().format(), |
calendarWeeks: true, |
||||
sideBySide: true, |
defaultDate: moment().format(), |
||||
buttons: { |
sideBySide: true, |
||||
showClear: true, |
buttons: { |
||||
showClose: true, |
showClear: true, |
||||
showToday: true, |
showClose: true, |
||||
}, |
showToday: true, |
||||
|
}, |
||||
icons : { |
|
||||
date: 'fa fa-calendar', |
icons: { |
||||
|
date: 'fa fa-calendar', |
||||
}, |
|
||||
locale : moment.locale(), |
}, |
||||
format : time.getLangDateFormat(), |
locale: moment.locale(), |
||||
widgetParent: 'body', |
format: time.getLangDateFormat(), |
||||
allowInputToggle: true, |
widgetParent: 'body', |
||||
}; |
allowInputToggle: true, |
||||
|
}; |
||||
$calendarInputGroup.datetimepicker(calendarOptions); |
|
||||
}, |
$calendarInputGroup.datetimepicker(calendarOptions); |
||||
|
}, |
||||
load_data: function (initial_render = true) { |
|
||||
var self = this; |
load_data: function(initial_render = true) { |
||||
self.$(".categ").empty(); |
var self = this; |
||||
try{ |
self.$(".categ").empty(); |
||||
var self = this; |
try { |
||||
self._rpc({ |
var self = this; |
||||
model: 'account.partner.ledger', |
self._rpc({ |
||||
method: 'view_report', |
model: 'account.partner.ledger', |
||||
args: [[this.wizard_id]], |
method: 'view_report', |
||||
}).then(function(datas) { |
args: [ |
||||
_.each(datas['report_lines'], function(rep_lines) { |
[this.wizard_id] |
||||
rep_lines.debit = self.format_currency(datas['currency'],rep_lines.debit); |
], |
||||
rep_lines.credit = self.format_currency(datas['currency'],rep_lines.credit); |
}).then(function(datas) { |
||||
rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance); |
_.each(datas['report_lines'], function(rep_lines) { |
||||
|
rep_lines.debit = self.format_currency(datas['currency'], rep_lines.debit); |
||||
|
rep_lines.credit = self.format_currency(datas['currency'], rep_lines.credit); |
||||
|
rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance) |
||||
|
}); |
||||
}); |
if (initial_render) { |
||||
|
self.$('.filter_view_tb').html(QWeb.render('PLFilterView', { |
||||
|
filter_data: datas['filters'], |
||||
|
})); |
||||
if (initial_render) { |
self.$el.find('.journals').select2({ |
||||
self.$('.filter_view_tb').html(QWeb.render('PLFilterView', { |
placeholder: ' Journals...', |
||||
filter_data: datas['filters'], |
}); |
||||
})); |
|
||||
self.$el.find('.journals').select2({ |
self.$el.find('.account-partner').select2({ |
||||
placeholder: ' Journals...', |
placeholder: ' Accounts...', |
||||
}); |
}); |
||||
|
self.$el.find('.partners').select2({ |
||||
self.$el.find('.account-partner').select2({ |
placeholder: 'Partners...', |
||||
placeholder: ' Accounts...', |
}); |
||||
}); |
self.$el.find('.reconciled').select2({ |
||||
self.$el.find('.partners').select2({ |
placeholder: 'Reconciled status...', |
||||
placeholder: 'Partners...', |
}); |
||||
}); |
self.$el.find('.type').select2({ |
||||
self.$el.find('.reconciled').select2({ |
placeholder: 'Account Type...', |
||||
placeholder: 'Reconciled status...', |
}); |
||||
}); |
self.$el.find('.category').select2({ |
||||
self.$el.find('.type').select2({ |
placeholder: 'Partner Tag...', |
||||
placeholder: 'Account Type...', |
}); |
||||
}); |
self.$el.find('.acc').select2({ |
||||
self.$el.find('.category').select2({ |
placeholder: 'Select Acc...', |
||||
placeholder: 'Partner Tag...', |
}); |
||||
}); |
self.$el.find('.target_move').select2({ |
||||
self.$el.find('.acc').select2({ |
placeholder: 'Target Move...', |
||||
placeholder: 'Select Acc...', |
}); |
||||
}); |
} |
||||
self.$el.find('.target_move').select2({ |
var child = []; |
||||
placeholder: 'Target Move...', |
self.$('.table_view_tb').html(QWeb.render('PLTable', { |
||||
}); |
report_lines: datas['report_lines'], |
||||
} |
filter: datas['filters'], |
||||
var child=[]; |
currency: datas['currency'], |
||||
self.$('.table_view_tb').html(QWeb.render('PLTable', { |
credit_total: datas['credit_total'], |
||||
report_lines : datas['report_lines'], |
debit_total: datas['debit_total'], |
||||
filter : datas['filters'], |
debit_balance: datas['debit_balance'] |
||||
currency : datas['currency'], |
})); |
||||
credit_total : datas['credit_total'], |
}); |
||||
debit_total : datas['debit_total'], |
|
||||
debit_balance : datas['debit_balance'] |
} catch (el) { |
||||
})); |
window.location.href |
||||
}); |
} |
||||
|
}, |
||||
} |
|
||||
catch (el) { |
format_currency: function(currency, amount) { |
||||
window.location.href |
if (typeof(amount) != 'number') { |
||||
} |
amount = parseFloat(amount); |
||||
}, |
} |
||||
|
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
||||
|
minimumFractionDigits: 2 |
||||
|
}) |
||||
format_currency: function(currency, amount) { |
return formatted_value |
||||
if (typeof(amount) != 'number') { |
}, |
||||
amount = parseFloat(amount); |
|
||||
} |
print_pdf: function(e) { |
||||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
e.preventDefault(); |
||||
minimumFractionDigits: 2 |
var self = this; |
||||
}) |
self._rpc({ |
||||
return formatted_value |
model: 'account.partner.ledger', |
||||
}, |
method: 'view_report', |
||||
|
args: [ |
||||
print_pdf: function(e) { |
[self.wizard_id] |
||||
e.preventDefault(); |
], |
||||
var self = this; |
}).then(function(data) { |
||||
self._rpc({ |
var action = { |
||||
model: 'account.partner.ledger', |
'type': 'ir.actions.report', |
||||
method: 'view_report', |
'report_type': 'qweb-pdf', |
||||
args: [ |
'report_name': 'dynamic_accounts_report.partner_ledger', |
||||
[self.wizard_id] |
'report_file': 'dynamic_accounts_report.partner_ledger', |
||||
], |
'data': { |
||||
}).then(function(data) { |
'report_data': data |
||||
var action = { |
}, |
||||
'type': 'ir.actions.report', |
'context': { |
||||
'report_type': 'qweb-pdf', |
'active_model': 'account.partner.ledger', |
||||
'report_name': 'dynamic_accounts_report.partner_ledger', |
'landscape': 1, |
||||
'report_file': 'dynamic_accounts_report.partner_ledger', |
'partner_ledger_pdf_report': true |
||||
'data': { |
}, |
||||
'report_data': data |
'display_name': 'Partner Ledger', |
||||
}, |
}; |
||||
'context': { |
return self.do_action(action); |
||||
'active_model': 'account.partner.ledger', |
}); |
||||
'landscape': 1, |
}, |
||||
'partner_ledger_pdf_report': true |
|
||||
}, |
print_xlsx: function() { |
||||
'display_name': 'Partner Ledger', |
var self = this; |
||||
}; |
var action_title = self._title |
||||
return self.do_action(action); |
self._rpc({ |
||||
}); |
model: 'account.partner.ledger', |
||||
}, |
method: 'view_report', |
||||
|
args: [ |
||||
|
[self.wizard_id] |
||||
|
], |
||||
print_xlsx: function() { |
}).then(function(data) { |
||||
var self = this; |
var action = { |
||||
self._rpc({ |
// 'type': 'ir_actions_dynamic_xlsx_download',
|
||||
model: 'account.partner.ledger', |
'data': { |
||||
method: 'view_report', |
'model': 'account.partner.ledger', |
||||
args: [ |
'options': JSON.stringify(data['filters']), |
||||
[self.wizard_id] |
'output_format': 'xlsx', |
||||
], |
'report_data': JSON.stringify(data['report_lines']), |
||||
}).then(function(data) { |
'report_name': action_title, |
||||
var action = { |
'dfr_data': JSON.stringify(data), |
||||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
}, |
||||
'data': { |
}; |
||||
'model': 'account.partner.ledger', |
// return self.do_action(action);
|
||||
'options': JSON.stringify(data['filters']), |
// core.action_registry.map.t_b.prototype.downloadXlsx(action)
|
||||
'output_format': 'xlsx', |
self.downloadXlsx(action) |
||||
'report_data': JSON.stringify(data['report_lines']), |
}); |
||||
'report_name': 'Partner Ledger', |
}, |
||||
'dfr_data': JSON.stringify(data), |
downloadXlsx: function(action) { |
||||
}, |
framework.blockUI(); |
||||
}; |
session.get_file({ |
||||
// return self.do_action(action);
|
url: '/dynamic_xlsx_reports', |
||||
core.action_registry.map.t_b.prototype.downloadXlsx(action) |
data: action.data, |
||||
}); |
complete: framework.unblockUI, |
||||
}, |
error: (error) => this.call('crash_manager', 'rpc_error', error), |
||||
|
}); |
||||
journal_line_click: function (el){ |
}, |
||||
click_num++; |
|
||||
var self = this; |
journal_line_click: function(el) { |
||||
var line = $(el.target).parent().data('id'); |
click_num++; |
||||
return self.do_action({ |
var self = this; |
||||
type: 'ir.actions.act_window', |
var line = $(el.target).parent().data('id'); |
||||
view_type: 'form', |
return self.do_action({ |
||||
view_mode: 'form', |
type: 'ir.actions.act_window', |
||||
res_model: 'account.move', |
view_type: 'form', |
||||
views: [ |
view_mode: 'form', |
||||
[false, 'form'] |
res_model: 'account.move', |
||||
], |
views: [ |
||||
res_id: line, |
[false, 'form'] |
||||
target: 'current', |
], |
||||
}); |
res_id: line, |
||||
}, |
target: 'current', |
||||
|
}); |
||||
show_drop_down: function(event) { |
}, |
||||
event.preventDefault(); |
|
||||
var self = this; |
show_drop_down: function(event) { |
||||
var account_id = $(event.currentTarget).data('account-id'); |
event.preventDefault(); |
||||
var offset = 0; |
var self = this; |
||||
var td = $(event.currentTarget).next('tr').find('td'); |
var account_id = $(event.currentTarget).data('account-id'); |
||||
if (td.length == 1) { |
var offset = 0; |
||||
self._rpc({ |
var td = $(event.currentTarget).next('tr').find('td'); |
||||
model: 'account.partner.ledger', |
if (td.length == 1) { |
||||
method: 'view_report', |
self._rpc({ |
||||
args: [ |
model: 'account.partner.ledger', |
||||
[self.wizard_id] |
method: 'view_report', |
||||
], |
args: [ |
||||
}).then(function(data) { |
[self.wizard_id] |
||||
_.each(data['report_lines'], function(rep_lines) { |
], |
||||
_.each(rep_lines['move_lines'], function(move_line) { |
}).then(function(data) { |
||||
|
_.each(data['report_lines'], function(rep_lines) { |
||||
move_line.debit = self.format_currency(data['currency'],move_line.debit); |
_.each(rep_lines['move_lines'], function(move_line) { |
||||
move_line.credit = self.format_currency(data['currency'],move_line.credit); |
|
||||
move_line.balance = self.format_currency(data['currency'],move_line.balance); |
move_line.debit = self.format_currency(data['currency'], move_line.debit); |
||||
|
move_line.credit = self.format_currency(data['currency'], move_line.credit); |
||||
|
move_line.balance = self.format_currency(data['currency'], move_line.balance); |
||||
}); |
}); |
||||
}); |
}); |
||||
for (var i = 0; i < data['report_lines'].length; i++) { |
for (var i = 0; i < data['report_lines'].length; i++) { |
||||
|
|
||||
if (account_id == data['report_lines'][i]['id'] ){ |
if (account_id == data['report_lines'][i]['id']) { |
||||
$(event.currentTarget).next('tr').find('td').remove(); |
$(event.currentTarget).next('tr').find('td').remove(); |
||||
$(event.currentTarget).next('tr').after( |
$(event.currentTarget).next('tr').after( |
||||
QWeb.render('SubSectionPL', { |
QWeb.render('SubSectionPL', { |
||||
account_data: data['report_lines'][i]['move_lines'], |
account_data: data['report_lines'][i]['move_lines'], |
||||
id : data['report_lines'][i]['id'] |
id: data['report_lines'][i]['id'] |
||||
})) |
})) |
||||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
||||
'background-color': '#00ede8', |
'background-color': '#00ede8', |
||||
'font-weight': 'bold', |
'font-weight': 'bold', |
||||
}); |
}); |
||||
} |
} |
||||
} |
} |
||||
}); |
}); |
||||
} |
} |
||||
}, |
}, |
||||
|
|
||||
view_acc_move: function(event) { |
view_acc_move: function(event) { |
||||
event.preventDefault(); |
event.preventDefault(); |
||||
var self = this; |
var self = this; |
||||
var context = {}; |
var context = {}; |
||||
var show_acc_move = function(res_model, res_id, view_id) { |
var show_acc_move = function(res_model, res_id, view_id) { |
||||
var action = { |
var action = { |
||||
type: 'ir.actions.act_window', |
type: 'ir.actions.act_window', |
||||
view_type: 'form', |
view_type: 'form', |
||||
view_mode: 'form', |
view_mode: 'form', |
||||
res_model: res_model, |
res_model: res_model, |
||||
views: [ |
views: [ |
||||
[view_id || false, 'form'] |
[view_id || false, 'form'] |
||||
], |
], |
||||
res_id: res_id, |
res_id: res_id, |
||||
target: 'current', |
target: 'current', |
||||
context: context, |
context: context, |
||||
}; |
}; |
||||
return self.do_action(action); |
return self.do_action(action); |
||||
}; |
}; |
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.move', |
model: 'account.move', |
||||
method: 'search_read', |
method: 'search_read', |
||||
domain: [ |
domain: [ |
||||
['id', '=', $(event.currentTarget).data('move-id')] |
['id', '=', $(event.currentTarget).data('move-id')] |
||||
], |
], |
||||
fields: ['id'], |
fields: ['id'], |
||||
limit: 1, |
limit: 1, |
||||
}) |
}) |
||||
.then(function(record) { |
.then(function(record) { |
||||
if (record.length > 0) { |
if (record.length > 0) { |
||||
show_acc_move('account.move', record[0].id); |
show_acc_move('account.move', record[0].id); |
||||
} else { |
} else { |
||||
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
show_acc_move('account.move', $(event.currentTarget).data('move-id')); |
||||
} |
} |
||||
}); |
}); |
||||
}, |
}, |
||||
|
|
||||
apply_filter: function(event) { |
apply_filter: function(event) { |
||||
event.preventDefault(); |
event.preventDefault(); |
||||
var self = this; |
var self = this; |
||||
self.initial_render = false; |
self.initial_render = false; |
||||
var filter_data_selected = {}; |
var filter_data_selected = {}; |
||||
|
|
||||
var account_ids = []; |
//Account filter
|
||||
var account_text = []; |
var account_ids = []; |
||||
var span_res = document.getElementById("account_res") |
var account_text = []; |
||||
var account_list = $(".account-partner").select2('data') |
var span_res = document.getElementById("account_res") |
||||
for (var i = 0; i < account_list.length; i++) { |
var account_list = $(".account-partner").select2('data') |
||||
if(account_list[i].element[0].selected === true) |
for (var i = 0; i < account_list.length; i++) { |
||||
{account_ids.push(parseInt(account_list[i].id)) |
if (account_list[i].element[0].selected === true) { |
||||
if(account_text.includes(account_list[i].text) === false) |
account_ids.push(parseInt(account_list[i].id)) |
||||
{account_text.push(account_list[i].text) |
if (account_text.includes(account_list[i].text) === false) { |
||||
} |
account_text.push(account_list[i].text) |
||||
span_res.value = account_text |
} |
||||
span_res.innerHTML=span_res.value; |
span_res.value = account_text |
||||
} |
span_res.innerHTML = span_res.value; |
||||
} |
} |
||||
if (account_list.length == 0){ |
} |
||||
span_res.value = "" |
if (account_list.length == 0) { |
||||
span_res.innerHTML=""; } |
span_res.value = "" |
||||
filter_data_selected.account_ids = account_ids |
span_res.innerHTML = ""; |
||||
|
} |
||||
|
filter_data_selected.account_ids = account_ids |
||||
var journal_ids = []; |
|
||||
var journal_text = []; |
//Journal Filter
|
||||
var journal_res = document.getElementById("journal_res") |
var journal_ids = []; |
||||
var journal_list = $(".journals").select2('data') |
var journal_text = []; |
||||
for (var i = 0; i < journal_list.length; i++) { |
var journal_res = document.getElementById("journal_res") |
||||
if(journal_list[i].element[0].selected === true){ |
var journal_list = $(".journals").select2('data') |
||||
journal_ids.push(parseInt(journal_list[i].id)) |
for (var i = 0; i < journal_list.length; i++) { |
||||
if(journal_text.includes(journal_list[i].text) === false){ |
if (journal_list[i].element[0].selected === true) { |
||||
journal_text.push(journal_list[i].text) |
journal_ids.push(parseInt(journal_list[i].id)) |
||||
} |
if (journal_text.includes(journal_list[i].text) === false) { |
||||
journal_res.value = journal_text |
journal_text.push(journal_list[i].text) |
||||
journal_res.innerHTML=journal_res.value; |
} |
||||
} |
journal_res.value = journal_text |
||||
} |
journal_res.innerHTML = journal_res.value; |
||||
if (journal_list.length == 0){ |
} |
||||
journal_res.value = "" |
} |
||||
journal_res.innerHTML=""; |
if (journal_list.length == 0) { |
||||
} |
journal_res.value = "" |
||||
filter_data_selected.journal_ids = journal_ids |
journal_res.innerHTML = ""; |
||||
|
} |
||||
var partner_ids = []; |
filter_data_selected.journal_ids = journal_ids |
||||
var partner_text = []; |
|
||||
var span_res = document.getElementById("partner_res") |
//Partner Filter
|
||||
var partner_list = $(".partners").select2('data') |
var partner_ids = []; |
||||
for (var i = 0; i < partner_list.length; i++) { |
var partner_text = []; |
||||
if(partner_list[i].element[0].selected === true) |
var span_res = document.getElementById("partner_res") |
||||
{partner_ids.push(parseInt(partner_list[i].id)) |
var partner_list = $(".partners").select2('data') |
||||
if(partner_text.includes(partner_list[i].text) === false) |
for (var i = 0; i < partner_list.length; i++) { |
||||
{partner_text.push(partner_list[i].text) |
if (partner_list[i].element[0].selected === true) { |
||||
} |
partner_ids.push(parseInt(partner_list[i].id)) |
||||
span_res.value = partner_text |
if (partner_text.includes(partner_list[i].text) === false) { |
||||
span_res.innerHTML=span_res.value; |
partner_text.push(partner_list[i].text) |
||||
} |
} |
||||
} |
span_res.value = partner_text |
||||
if (partner_list.length == 0){ |
span_res.innerHTML = span_res.value; |
||||
span_res.value = "" |
} |
||||
span_res.innerHTML=""; |
} |
||||
} |
if (partner_list.length == 0) { |
||||
filter_data_selected.partner_ids = partner_ids |
span_res.value = "" |
||||
|
span_res.innerHTML = ""; |
||||
var account_type_id = []; |
} |
||||
var account_type_ids_text = []; |
filter_data_selected.partner_ids = partner_ids |
||||
var span_res = document.getElementById("type_res") |
|
||||
var type_list = $(".type").select2('data') |
//Account Type Filter
|
||||
for (var i = 0; i < type_list.length; i++) { |
if ($(".type").length) { |
||||
if(type_list[i].element[0].selected === true) |
var type_res = document.getElementById("type_res") |
||||
{account_type_id.push(parseInt(type_list[i].id)) |
filter_data_selected.account_type = $(".type")[1].value |
||||
if(account_type_ids_text.includes(type_list[i].text) === false) |
type_res.value = $(".type")[1].value |
||||
{account_type_ids_text.push(type_list[i].text) |
type_res.innerHTML = account_type.value; |
||||
} |
if ($(".type").value == "") { |
||||
span_res.value = account_type_ids_text |
type_res.innerHTML = "asset_receivable"; |
||||
span_res.innerHTML=span_res.value; |
filter_data_selected.account_type = "asset_receivable" |
||||
} |
} |
||||
} |
} |
||||
if (type_list.length == 0){ |
|
||||
span_res.value = "" |
//Partner Category Filter
|
||||
span_res.innerHTML=""; |
var partner_category_ids = []; |
||||
} |
var partner_category_text = []; |
||||
filter_data_selected.account_type_id = account_type_id |
var span_res = document.getElementById("category_res") |
||||
|
var category_list = $(".category").select2('data') |
||||
var partner_category_ids = []; |
for (var i = 0; i < category_list.length; i++) { |
||||
var partner_category_text = []; |
if (category_list[i].element[0].selected === true) { |
||||
var span_res = document.getElementById("category_res") |
partner_category_ids.push(parseInt(category_list[i].id)) |
||||
var category_list = $(".category").select2('data') |
if (partner_category_text.includes(category_list[i].text) === false) { |
||||
for (var i = 0; i < category_list.length; i++) { |
partner_category_text.push(category_list[i].text) |
||||
if(category_list[i].element[0].selected === true) |
} |
||||
{partner_category_ids.push(parseInt(category_list[i].id)) |
span_res.value = partner_category_text |
||||
if(partner_category_text.includes(category_list[i].text) === false) |
span_res.innerHTML = span_res.value; |
||||
{partner_category_text.push(category_list[i].text) |
} |
||||
} |
} |
||||
span_res.value = partner_category_text |
if (category_list.length == 0) { |
||||
span_res.innerHTML=span_res.value; |
span_res.value = "" |
||||
} |
span_res.innerHTML = ""; |
||||
} |
} |
||||
if (category_list.length == 0){ |
filter_data_selected.partner_category_ids = partner_category_ids |
||||
span_res.value = "" |
|
||||
span_res.innerHTML=""; |
//Date range filter
|
||||
} |
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
||||
filter_data_selected.partner_category_ids = partner_category_ids |
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
|
} |
||||
// if ($("#date_from").val()) {
|
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
||||
// var dateString = $("#date_from").val();
|
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
// filter_data_selected.date_from = dateString;
|
} |
||||
// }
|
|
||||
// if ($("#date_to").val()) {
|
//Reconciled Filter
|
||||
// var dateString = $("#date_to").val();
|
if ($(".reconciled").length) { |
||||
// filter_data_selected.date_to = dateString;
|
var reconciled_res = document.getElementById("reconciled_res") |
||||
// }
|
filter_data_selected.reconciled = $(".reconciled")[1].value |
||||
|
reconciled_res.value = $(".reconciled")[1].value |
||||
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
reconciled_res.innerHTML = reconciled_res.value; |
||||
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
if ($(".reconciled").value == "") { |
||||
} |
reconciled_res.innerHTML = "unreconciled"; |
||||
|
filter_data_selected.reconciled = "unreconciled" |
||||
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
} |
||||
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
} |
||||
} |
|
||||
|
//Target Move Filter
|
||||
if ($(".reconciled").length){ |
if ($(".target_move").length) { |
||||
var reconciled_res = document.getElementById("reconciled_res") |
var post_res = document.getElementById("post_res") |
||||
filter_data_selected.reconciled = $(".reconciled")[1].value |
filter_data_selected.target_move = $(".target_move")[1].value |
||||
reconciled_res.value = $(".reconciled")[1].value |
post_res.value = $(".target_move")[1].value |
||||
reconciled_res.innerHTML=reconciled_res.value; |
post_res.innerHTML = post_res.value; |
||||
if ($(".reconciled").value==""){ |
if ($(".target_move")[1].value == "") { |
||||
reconciled_res.innerHTML="unreconciled"; |
post_res.innerHTML = "posted"; |
||||
filter_data_selected.reconciled = "unreconciled" |
} |
||||
} |
} |
||||
} |
rpc.query({ |
||||
|
model: 'account.partner.ledger', |
||||
if ($(".target_move").length) { |
method: 'write', |
||||
var post_res = document.getElementById("post_res") |
args: [ |
||||
filter_data_selected.target_move = $(".target_move")[1].value |
self.wizard_id, filter_data_selected |
||||
post_res.value = $(".target_move")[1].value |
], |
||||
post_res.innerHTML=post_res.value; |
}).then(function(res) { |
||||
if ($(".target_move")[1].value == "") { |
self.initial_render = false; |
||||
post_res.innerHTML="posted"; |
self.load_data(self.initial_render); |
||||
|
}); |
||||
} |
}, |
||||
} |
|
||||
rpc.query({ |
}); |
||||
model: 'account.partner.ledger', |
core.action_registry.add("p_l", PartnerLedger); |
||||
method: 'write', |
return PartnerLedger; |
||||
args: [ |
|
||||
self.wizard_id, filter_data_selected |
|
||||
], |
|
||||
}).then(function(res) { |
|
||||
self.initial_render = false; |
|
||||
self.load_data(self.initial_render); |
|
||||
}); |
|
||||
}, |
|
||||
|
|
||||
}); |
|
||||
core.action_registry.add("p_l", PartnerLedger); |
|
||||
return PartnerLedger; |
|
||||
}); |
}); |
@ -1,338 +1,336 @@ |
|||||
odoo.define('dynamic_accounts_report.trial_balance', function (require) { |
odoo.define('dynamic_accounts_report.trial_balance', function(require) { |
||||
'use strict'; |
'use strict'; |
||||
var AbstractAction = require('web.AbstractAction'); |
var AbstractAction = require('web.AbstractAction'); |
||||
var core = require('web.core'); |
var core = require('web.core'); |
||||
var field_utils = require('web.field_utils'); |
var field_utils = require('web.field_utils'); |
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
var session = require('web.session'); |
var session = require('web.session'); |
||||
var utils = require('web.utils'); |
var utils = require('web.utils'); |
||||
|
|
||||
var QWeb = core.qweb; |
var QWeb = core.qweb; |
||||
var _t = core._t; |
var _t = core._t; |
||||
var framework = require('web.framework'); |
var framework = require('web.framework'); |
||||
|
|
||||
|
|
||||
var datepicker = require('web.datepicker'); |
var datepicker = require('web.datepicker'); |
||||
var time = require('web.time'); |
var time = require('web.time'); |
||||
|
|
||||
// import framework from 'web.framework';
|
// import framework from 'web.framework';
|
||||
// import { download } from "@web/core/network/download";
|
// import { download } from "@web/core/network/download";
|
||||
|
|
||||
|
|
||||
// import { registry } from "@web/core/registry";
|
// import { registry } from "@web/core/registry";
|
||||
// const serviceRegistry = registry.category("services");
|
// const serviceRegistry = registry.category("services");
|
||||
|
|
||||
window.click_num = 0; |
window.click_num = 0; |
||||
var TrialBalance = AbstractAction.extend({ |
var TrialBalance = AbstractAction.extend({ |
||||
template: 'TrialTemp', |
template: 'TrialTemp', |
||||
events: { |
events: { |
||||
'click .parent-line': 'journal_line_click', |
'click .parent-line': 'journal_line_click', |
||||
'click .child_col1': 'journal_line_click', |
'click .child_col1': 'journal_line_click', |
||||
'click #apply_filter': 'apply_filter', |
'click #apply_filter': 'apply_filter', |
||||
'click #pdf': 'print_pdf', |
'click #pdf': 'print_pdf', |
||||
'click #xlsx': 'print_xlsx', |
'click #xlsx': 'print_xlsx', |
||||
'click .show-gl': 'show_gl', |
'click .show-gl': 'show_gl', |
||||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
||||
}, |
}, |
||||
|
|
||||
init: function(parent, action) { |
init: function(parent, action) { |
||||
this._super(parent, action); |
this._super(parent, action); |
||||
this.currency=action.currency; |
this.currency = action.currency; |
||||
this.report_lines = action.report_lines; |
this.report_lines = action.report_lines; |
||||
this.wizard_id = action.context.wizard | null; |
this.wizard_id = action.context.wizard | null; |
||||
}, |
}, |
||||
|
|
||||
|
|
||||
start: function() { |
start: function() { |
||||
var self = this; |
var self = this; |
||||
self.initial_render = true; |
self.initial_render = true; |
||||
rpc.query({ |
rpc.query({ |
||||
model: 'account.trial.balance', |
model: 'account.trial.balance', |
||||
method: 'create', |
method: 'create', |
||||
args: [{ |
args: [{ |
||||
|
|
||||
}] |
}] |
||||
}).then(function(t_res) { |
}).then(function(t_res) { |
||||
self.wizard_id = t_res; |
self.wizard_id = t_res; |
||||
self.load_data(self.initial_render); |
self.load_data(self.initial_render); |
||||
}) |
}) |
||||
}, |
}, |
||||
|
|
||||
|
|
||||
load_data: function (initial_render = true) { |
load_data: function(initial_render = true) { |
||||
var self = this; |
var self = this; |
||||
self.$(".categ").empty(); |
self.$(".categ").empty(); |
||||
try{ |
try { |
||||
var self = this; |
var self = this; |
||||
self._rpc({ |
self._rpc({ |
||||
model: 'account.trial.balance', |
model: 'account.trial.balance', |
||||
method: 'view_report', |
method: 'view_report', |
||||
args: [[this.wizard_id]], |
args: [ |
||||
}).then(function(datas) { |
[this.wizard_id] |
||||
|
], |
||||
|
}).then(function(datas) { |
||||
|
|
||||
_.each(datas['report_lines'], function(rep_lines) { |
|
||||
rep_lines.debit = self.format_currency(datas['currency'],rep_lines.debit); |
|
||||
rep_lines.credit = self.format_currency(datas['currency'],rep_lines.credit); |
_.each(datas['report_lines'], function(rep_lines) { |
||||
rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance); |
rep_lines.debit = self.format_currency(datas['currency'], rep_lines.debit); |
||||
|
rep_lines.credit = self.format_currency(datas['currency'], rep_lines.credit); |
||||
|
rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance); |
||||
|
|
||||
}); |
|
||||
if (initial_render) { |
|
||||
self.$('.filter_view_tb').html(QWeb.render('TrialFilterView', { |
}); |
||||
filter_data: datas['filters'], |
if (initial_render) { |
||||
})); |
self.$('.filter_view_tb').html(QWeb.render('TrialFilterView', { |
||||
self.$el.find('.journals').select2({ |
filter_data: datas['filters'], |
||||
placeholder: 'Select Journals...', |
})); |
||||
}); |
self.$el.find('.journals').select2({ |
||||
self.$el.find('.target_move').select2({ |
placeholder: 'Select Journals...', |
||||
placeholder: 'Target Move...', |
}); |
||||
}); |
self.$el.find('.target_move').select2({ |
||||
// self.$el.find('#start_dateee').select2({
|
placeholder: 'Target Move...', |
||||
// placeholder: 'Date.',
|
}); |
||||
// });
|
// self.$el.find('#start_dateee').select2({
|
||||
} |
// placeholder: 'Date.',
|
||||
var child=[]; |
// });
|
||||
|
} |
||||
self.$('.table_view_tb').html(QWeb.render('TrialTable', { |
var child = []; |
||||
|
|
||||
report_lines : datas['report_lines'], |
self.$('.table_view_tb').html(QWeb.render('TrialTable', { |
||||
filter : datas['filters'], |
|
||||
currency : datas['currency'], |
report_lines: datas['report_lines'], |
||||
credit_total : self.format_currency(datas['currency'],datas['debit_total']), |
filter: datas['filters'], |
||||
debit_total : self.format_currency(datas['currency'],datas['debit_total']), |
currency: datas['currency'], |
||||
})); |
credit_total: self.format_currency(datas['currency'], datas['debit_total']), |
||||
|
debit_total: self.format_currency(datas['currency'], datas['debit_total']), |
||||
}); |
})); |
||||
|
|
||||
} |
}); |
||||
catch (el) { |
|
||||
window.location.href |
} catch (el) { |
||||
} |
window.location.href |
||||
}, |
} |
||||
|
}, |
||||
show_gl: function(e) { |
|
||||
var self = this; |
show_gl: function(e) { |
||||
var account_id = $(e.target).attr('data-account-id'); |
var self = this; |
||||
var options = { |
var account_id = $(e.target).attr('data-account-id'); |
||||
account_ids: [account_id], |
var options = { |
||||
} |
account_ids: [account_id], |
||||
|
} |
||||
var action = { |
|
||||
type: 'ir.actions.client', |
var action = { |
||||
name: 'GL View', |
type: 'ir.actions.client', |
||||
tag: 'g_l', |
name: 'GL View', |
||||
target: 'new', |
tag: 'g_l', |
||||
|
target: 'new', |
||||
domain: [['account_ids','=', account_id]], |
|
||||
|
domain: [ |
||||
|
['account_ids', '=', account_id] |
||||
} |
], |
||||
return this.do_action(action); |
|
||||
|
|
||||
}, |
} |
||||
|
return this.do_action(action); |
||||
print_pdf: function(e) { |
|
||||
e.preventDefault(); |
}, |
||||
var self = this; |
|
||||
self._rpc({ |
print_pdf: function(e) { |
||||
model: 'account.trial.balance', |
e.preventDefault(); |
||||
method: 'view_report', |
var self = this; |
||||
args: [ |
self._rpc({ |
||||
[self.wizard_id] |
model: 'account.trial.balance', |
||||
], |
method: 'view_report', |
||||
}).then(function(data) { |
args: [ |
||||
var action = { |
[self.wizard_id] |
||||
'type': 'ir.actions.report', |
], |
||||
'report_type': 'qweb-pdf', |
}).then(function(data) { |
||||
'report_name': 'dynamic_accounts_report.trial_balance', |
var action = { |
||||
'report_file': 'dynamic_accounts_report.trial_balance', |
'type': 'ir.actions.report', |
||||
'data': { |
'report_type': 'qweb-pdf', |
||||
'report_data': data |
'report_name': 'dynamic_accounts_report.trial_balance', |
||||
}, |
'report_file': 'dynamic_accounts_report.trial_balance', |
||||
'context': { |
'data': { |
||||
'active_model': 'account.trial.balance', |
'report_data': data |
||||
'landscape': 1, |
}, |
||||
'trial_pdf_report': true |
'context': { |
||||
}, |
'active_model': 'account.trial.balance', |
||||
'display_name': 'Trial Balance', |
'landscape': 1, |
||||
}; |
'trial_pdf_report': true |
||||
return self.do_action(action); |
}, |
||||
}); |
'display_name': 'Trial Balance', |
||||
}, |
}; |
||||
|
return self.do_action(action); |
||||
_onCalendarIconClick: function (ev) { |
}); |
||||
var $calendarInputGroup = $(ev.currentTarget); |
}, |
||||
|
|
||||
var calendarOptions = { |
_onCalendarIconClick: function(ev) { |
||||
|
var $calendarInputGroup = $(ev.currentTarget); |
||||
// minDate: moment({ y: 1000 }),
|
|
||||
// maxDate: moment().add(200, 'y'),
|
var calendarOptions = { |
||||
// calendarWeeks: true,
|
|
||||
// defaultDate: moment().format(),
|
// minDate: moment({ y: 1000 }),
|
||||
// sideBySide: true,
|
// maxDate: moment().add(200, 'y'),
|
||||
// buttons: {
|
// calendarWeeks: true,
|
||||
// showClear: true,
|
// defaultDate: moment().format(),
|
||||
// showClose: true,
|
// sideBySide: true,
|
||||
// showToday: true,
|
// buttons: {
|
||||
// },
|
// showClear: true,
|
||||
|
// showClose: true,
|
||||
icons : { |
// showToday: true,
|
||||
date: 'fa fa-calendar', |
// },
|
||||
|
|
||||
}, |
icons: { |
||||
locale : moment.locale(), |
date: 'fa fa-calendar', |
||||
format : time.getLangDateFormat(), |
|
||||
widgetParent: 'body', |
}, |
||||
allowInputToggle: true, |
locale: moment.locale(), |
||||
}; |
format: time.getLangDateFormat(), |
||||
|
widgetParent: 'body', |
||||
$calendarInputGroup.datetimepicker(calendarOptions); |
allowInputToggle: true, |
||||
}, |
}; |
||||
|
|
||||
|
$calendarInputGroup.datetimepicker(calendarOptions); |
||||
|
}, |
||||
format_currency: function(currency, amount) { |
|
||||
if (typeof(amount) != 'number') { |
|
||||
amount = parseFloat(amount); |
|
||||
} |
format_currency: function(currency, amount) { |
||||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
if (typeof(amount) != 'number') { |
||||
minimumFractionDigits: 2 |
amount = parseFloat(amount); |
||||
}) |
} |
||||
return formatted_value |
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
||||
}, |
minimumFractionDigits: 2 |
||||
|
}) |
||||
print_xlsx: function() { |
return formatted_value |
||||
var self = this; |
}, |
||||
self._rpc({ |
|
||||
model: 'account.trial.balance', |
print_xlsx: function() { |
||||
method: 'view_report', |
var self = this; |
||||
args: [ |
self._rpc({ |
||||
[self.wizard_id] |
model: 'account.trial.balance', |
||||
], |
method: 'view_report', |
||||
}).then(function(data) { |
args: [ |
||||
var action = { |
[self.wizard_id] |
||||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
], |
||||
'data': { |
}).then(function(data) { |
||||
'model': 'account.trial.balance', |
var action = { |
||||
'options': JSON.stringify(data['filters']), |
// 'type': 'ir_actions_dynamic_xlsx_download',
|
||||
'output_format': 'xlsx', |
'data': { |
||||
'report_data': JSON.stringify(data['report_lines']), |
'model': 'account.trial.balance', |
||||
'report_name': 'Trial Balance', |
'options': JSON.stringify(data['filters']), |
||||
'dfr_data': JSON.stringify(data), |
'output_format': 'xlsx', |
||||
}, |
'report_data': JSON.stringify(data['report_lines']), |
||||
}; |
'report_name': 'Trial Balance', |
||||
|
'dfr_data': JSON.stringify(data), |
||||
// return self.do_action(action);
|
}, |
||||
self.downloadXlsx(action); |
}; |
||||
}); |
|
||||
}, |
// return self.do_action(action);
|
||||
|
self.downloadXlsx(action); |
||||
downloadXlsx: function (action){ |
}); |
||||
framework.blockUI(); |
}, |
||||
session.get_file({ |
|
||||
url: '/dynamic_xlsx_reports', |
downloadXlsx: function(action) { |
||||
data: action.data, |
framework.blockUI(); |
||||
complete: framework.unblockUI, |
session.get_file({ |
||||
error: (error) => this.call('crash_manager', 'rpc_error', error), |
url: '/dynamic_xlsx_reports', |
||||
}); |
data: action.data, |
||||
}, |
complete: framework.unblockUI, |
||||
|
error: (error) => this.call('crash_manager', 'rpc_error', error), |
||||
journal_line_click: function (el){ |
}); |
||||
click_num++; |
}, |
||||
var self = this; |
|
||||
var line = $(el.target).parent().data('id'); |
journal_line_click: function(el) { |
||||
return self.do_action({ |
click_num++; |
||||
type: 'ir.actions.act_window', |
var self = this; |
||||
view_type: 'form', |
var line = $(el.target).parent().data('id'); |
||||
view_mode: 'form', |
return self.do_action({ |
||||
res_model: 'account.move', |
type: 'ir.actions.act_window', |
||||
views: [ |
view_type: 'form', |
||||
[false, 'form'] |
view_mode: 'form', |
||||
], |
res_model: 'account.move', |
||||
res_id: line, |
views: [ |
||||
target: 'current', |
[false, 'form'] |
||||
}); |
], |
||||
|
res_id: line, |
||||
}, |
target: 'current', |
||||
|
}); |
||||
|
|
||||
apply_filter: function(event) { |
}, |
||||
|
|
||||
event.preventDefault(); |
|
||||
var self = this; |
apply_filter: function(event) { |
||||
self.initial_render = false; |
event.preventDefault(); |
||||
|
var self = this; |
||||
|
self.initial_render = false; |
||||
|
var filter_data_selected = {}; |
||||
|
var journal_ids = []; |
||||
var filter_data_selected = {}; |
var journal_text = []; |
||||
var journal_ids = []; |
var journal_res = document.getElementById("journal_res") |
||||
var journal_text = []; |
var journal_list = $(".journals").select2('data') |
||||
var journal_res = document.getElementById("journal_res") |
|
||||
var journal_list = $(".journals").select2('data') |
for (var i = 0; i < journal_list.length; i++) { |
||||
|
if (journal_list[i].element[0].selected === true) { |
||||
for (var i = 0; i < journal_list.length; i++) { |
|
||||
if(journal_list[i].element[0].selected === true){ |
journal_ids.push(parseInt(journal_list[i].id)) |
||||
|
if (journal_text.includes(journal_list[i].text) === false) { |
||||
journal_ids.push(parseInt(journal_list[i].id)) |
journal_text.push(journal_list[i].text) |
||||
if(journal_text.includes(journal_list[i].text) === false){ |
} |
||||
journal_text.push(journal_list[i].text) |
journal_res.value = journal_text |
||||
} |
journal_res.innerHTML = journal_res.value; |
||||
journal_res.value = journal_text |
} |
||||
journal_res.innerHTML=journal_res.value; |
} |
||||
} |
if (journal_list.length == 0) { |
||||
} |
journal_res.value = "" |
||||
if (journal_list.length == 0){ |
journal_res.innerHTML = ""; |
||||
journal_res.value = "" |
|
||||
journal_res.innerHTML=""; |
} |
||||
|
filter_data_selected.journal_ids = journal_ids |
||||
} |
|
||||
filter_data_selected.journal_ids = journal_ids |
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
||||
|
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
if (this.$el.find('.datetimepicker-input[name="date_from"]').val()) { |
} |
||||
filter_data_selected.date_from = moment(this.$el.find('.datetimepicker-input[name="date_from"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
|
||||
} |
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
||||
|
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
||||
if (this.$el.find('.datetimepicker-input[name="date_to"]').val()) { |
} |
||||
filter_data_selected.date_to = moment(this.$el.find('.datetimepicker-input[name="date_to"]').val(), time.getLangDateFormat()).locale('en').format('YYYY-MM-DD'); |
// if ($("#date_from").val()) {
|
||||
} |
// var dateString = $("#date_from").val();
|
||||
// if ($("#date_from").val()) {
|
// filter_data_selected.date_from = dateString;
|
||||
// var dateString = $("#date_from").val();
|
// }
|
||||
// filter_data_selected.date_from = dateString;
|
|
||||
// }
|
|
||||
|
// if ($("#date_to").val()) {
|
||||
|
// var dateString = $("#date_to").val();
|
||||
// if ($("#date_to").val()) {
|
// filter_data_selected.date_to = dateString;
|
||||
// var dateString = $("#date_to").val();
|
// }
|
||||
// filter_data_selected.date_to = dateString;
|
|
||||
// }
|
if ($(".target_move").length) { |
||||
|
var post_res = document.getElementById("post_res") |
||||
if ($(".target_move").length) { |
filter_data_selected.target_move = $(".target_move")[1].value |
||||
var post_res = document.getElementById("post_res") |
post_res.value = $(".target_move")[1].value |
||||
filter_data_selected.target_move = $(".target_move")[1].value |
post_res.innerHTML = post_res.value; |
||||
post_res.value = $(".target_move")[1].value |
if ($(".target_move")[1].value == "") { |
||||
post_res.innerHTML=post_res.value; |
post_res.innerHTML = "posted"; |
||||
if ($(".target_move")[1].value == "") { |
|
||||
post_res.innerHTML="posted"; |
} |
||||
|
} |
||||
} |
rpc.query({ |
||||
} |
model: 'account.trial.balance', |
||||
rpc.query({ |
method: 'write', |
||||
model: 'account.trial.balance', |
args: [ |
||||
method: 'write', |
self.wizard_id, filter_data_selected |
||||
args: [ |
], |
||||
self.wizard_id, filter_data_selected |
}).then(function(res) { |
||||
], |
self.initial_render = false; |
||||
}).then(function(res) { |
self.load_data(self.initial_render); |
||||
self.initial_render = false; |
}); |
||||
self.load_data(self.initial_render); |
}, |
||||
}); |
|
||||
}, |
}); |
||||
|
core.action_registry.add("t_b", TrialBalance); |
||||
}); |
return TrialBalance; |
||||
core.action_registry.add("t_b", TrialBalance); |
|
||||
return TrialBalance; |
|
||||
}); |
}); |
Loading…
Reference in new issue