36 changed files with 4107 additions and 4053 deletions
@ -1,3 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import controllers |
|||
############################################################################# |
|||
# |
|||
# 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 |
|||
|
@ -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 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): |
|||
_name = 'report.dynamic_accounts_report.partner_ageing' |
|||
|
|||
@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 data.get('report_data'): |
|||
data.update( |
|||
{'account_data': data.get('report_data')['report_lines'][0], |
|||
'Filters': data.get('report_data')['filters'], |
|||
'company': self.env.company, |
|||
|
|||
}) |
|||
|
|||
return data |
|||
|
@ -1,17 +1,39 @@ |
|||
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 DayBook(models.AbstractModel): |
|||
_name = 'report.dynamic_accounts_report.day_book' |
|||
|
|||
@api.model |
|||
def _get_report_values(self, docids, data=None): |
|||
def _get_report_values(self,docids, data=None): |
|||
|
|||
if self.env.context.get('daybook_pdf_report'): |
|||
|
|||
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'], |
|||
'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): |
|||
_name = 'report.dynamic_accounts_report.trial_balance' |
|||
|
|||
@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 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'], |
|||
'debit_total': data.get('report_data')['debit_total'], |
|||
'credit_total': data.get('report_data')['credit_total'], |
|||
'debit_total': data.get('report_data' |
|||
)['debit_total'], |
|||
'credit_total': data.get('report_data' |
|||
)['credit_total'], |
|||
'company': self.env.company, |
|||
}) |
|||
return data |
|||
|
@ -1,438 +1,432 @@ |
|||
odoo.define('dynamic_accounts_report.ageing', function (require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
window.click_num = 0; |
|||
var PartnerAgeing = AbstractAction.extend({ |
|||
template: 'AgeingTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .gl-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency=action.currency; |
|||
this.report_lines = action.report_lines; |
|||
|
|||
this.wizard_id = action.context.wizard | null; |
|||
|
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.partner.ageing', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
|
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
_onCalendarIconClick: function (ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ y: 1000 }), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons : { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale : moment.locale(), |
|||
format : time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
load_data: function (initial_render = true) { |
|||
|
|||
var self = this; |
|||
|
|||
self.$(".categ").empty(); |
|||
try{ |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [[this.wizard_id]], |
|||
}).then(function(datas) { |
|||
_.each(datas['report_lines'][0], function(rep_lines) { |
|||
rep_lines.total = self.format_currency(datas['currency'],rep_lines.total); |
|||
rep_lines[4] = self.format_currency(datas['currency'],rep_lines[4]); |
|||
rep_lines[3] = self.format_currency(datas['currency'],rep_lines[3]); |
|||
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'], |
|||
})); |
|||
self.$el.find('.partners').select2({ |
|||
placeholder: ' Partners...', |
|||
}); |
|||
self.$el.find('.category').select2({ |
|||
placeholder: ' Partner Category...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
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'], |
|||
move_lines :datas['report_lines'][2], |
|||
filter : datas['filters'], |
|||
currency : datas['currency'], |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} |
|||
catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
|
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.partner_ageing', |
|||
'report_file': 'dynamic_accounts_report.partner_ageing', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.partner.ageing', |
|||
'landscape': 1, |
|||
'ageing_pdf_report': true |
|||
|
|||
}, |
|||
'display_name': 'Partner Ageing', |
|||
}; |
|||
|
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
|
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
|
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.partner.ageing', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'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) |
|||
}); |
|||
}, |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
create_lines_with_style: function(rec, attr, datas) { |
|||
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_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>"; |
|||
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; |
|||
var line = $(el.target).parent().data('id'); |
|||
|
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
|
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var account_id = $(event.currentTarget).data('account-id'); |
|||
|
|||
var partner_id = $(event.currentTarget)[0].cells[0].innerText; |
|||
|
|||
var offset = 0; |
|||
var td = $(event.currentTarget).next('tr').find('td'); |
|||
if (td.length == 1) { |
|||
|
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
|
|||
_.each(data['report_lines'][0], function(rep_lines) { |
|||
_.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'] ){ |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSectional', { |
|||
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', |
|||
'font-weight': 'bold', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
|
|||
var filter_data_selected = {}; |
|||
|
|||
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'); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
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) |
|||
{partner_ids.push(parseInt(partner_list[i].id)) |
|||
if(partner_text.includes(partner_list[i].text) === false) |
|||
{partner_text.push(partner_list[i].text) |
|||
} |
|||
span_res.value = partner_text |
|||
span_res.innerHTML=span_res.value; |
|||
} |
|||
} |
|||
if (partner_list.length == 0){ |
|||
span_res.value = "" |
|||
span_res.innerHTML=""; |
|||
} |
|||
filter_data_selected.partner_ids = partner_ids |
|||
|
|||
var partner_category_ids = []; |
|||
var partner_category_text = []; |
|||
var span_res = document.getElementById("category_res") |
|||
var category_list = $(".category").select2('data') |
|||
|
|||
for (var i = 0; i < category_list.length; i++) { |
|||
if(category_list[i].element[0].selected === true) |
|||
{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) |
|||
} |
|||
span_res.value = partner_category_text |
|||
span_res.innerHTML=span_res.value; |
|||
} |
|||
} |
|||
if (category_list.length == 0){ |
|||
span_res.value = "" |
|||
span_res.innerHTML=""; |
|||
} |
|||
filter_data_selected.partner_category_ids = partner_category_ids |
|||
|
|||
|
|||
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"; |
|||
|
|||
} |
|||
} |
|||
|
|||
if ($(".result_selection").length) { |
|||
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 |
|||
], |
|||
}).then(function(res) { |
|||
self.initial_render = false; |
|||
self.load_data(self.initial_render); |
|||
}); |
|||
}, |
|||
|
|||
}); |
|||
core.action_registry.add("p_a", PartnerAgeing); |
|||
return PartnerAgeing; |
|||
odoo.define('dynamic_accounts_report.ageing', function(require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
window.click_num = 0; |
|||
var PartnerAgeing = AbstractAction.extend({ |
|||
template: 'AgeingTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .gl-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency = action.currency; |
|||
this.report_lines = action.report_lines; |
|||
|
|||
this.wizard_id = action.context.wizard | null; |
|||
|
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.partner.ageing', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
|
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
_onCalendarIconClick: function(ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ |
|||
y: 1000 |
|||
}), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons: { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale: moment.locale(), |
|||
format: time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
load_data: function(initial_render = true) { |
|||
|
|||
var self = this; |
|||
|
|||
self.$(".categ").empty(); |
|||
try { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[this.wizard_id] |
|||
], |
|||
}).then(function(datas) { |
|||
_.each(datas['report_lines'][0], function(rep_lines) { |
|||
rep_lines.total = self.format_currency(datas['currency'], rep_lines.total); |
|||
rep_lines[4] = self.format_currency(datas['currency'], rep_lines[4]); |
|||
rep_lines[3] = self.format_currency(datas['currency'], rep_lines[3]); |
|||
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'], |
|||
})); |
|||
self.$el.find('.partners').select2({ |
|||
placeholder: ' Partners...', |
|||
}); |
|||
self.$el.find('.category').select2({ |
|||
placeholder: ' Partner Category...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
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'], |
|||
move_lines: datas['report_lines'][2], |
|||
filter: datas['filters'], |
|||
currency: datas['currency'], |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
|
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.partner_ageing', |
|||
'report_file': 'dynamic_accounts_report.partner_ageing', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.partner.ageing', |
|||
'landscape': 1, |
|||
'ageing_pdf_report': true |
|||
|
|||
}, |
|||
'display_name': 'Partner Ageing', |
|||
}; |
|||
|
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
|
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
|
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.partner.ageing', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'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) |
|||
}); |
|||
}, |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
create_lines_with_style: function(rec, attr, datas) { |
|||
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_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>"; |
|||
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; |
|||
var line = $(el.target).parent().data('id'); |
|||
|
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
|
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var account_id = $(event.currentTarget).data('account-id'); |
|||
|
|||
var partner_id = $(event.currentTarget)[0].cells[0].innerText; |
|||
|
|||
var offset = 0; |
|||
var td = $(event.currentTarget).next('tr').find('td'); |
|||
if (td.length == 1) { |
|||
|
|||
self._rpc({ |
|||
model: 'account.partner.ageing', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
|
|||
_.each(data['report_lines'][0], function(rep_lines) { |
|||
_.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']) { |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSectional', { |
|||
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', |
|||
'font-weight': 'bold', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
var filter_data_selected = {}; |
|||
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'); |
|||
} |
|||
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) { |
|||
partner_ids.push(parseInt(partner_list[i].id)) |
|||
if (partner_text.includes(partner_list[i].text) === false) { |
|||
partner_text.push(partner_list[i].text) |
|||
} |
|||
span_res.value = partner_text |
|||
span_res.innerHTML = span_res.value; |
|||
} |
|||
} |
|||
if (partner_list.length == 0) { |
|||
span_res.value = "" |
|||
span_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.partner_ids = partner_ids |
|||
|
|||
var partner_category_ids = []; |
|||
var partner_category_text = []; |
|||
var span_res = document.getElementById("category_res") |
|||
var category_list = $(".category").select2('data') |
|||
|
|||
for (var i = 0; i < category_list.length; i++) { |
|||
if (category_list[i].element[0].selected === true) { |
|||
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) |
|||
} |
|||
span_res.value = partner_category_text |
|||
span_res.innerHTML = span_res.value; |
|||
} |
|||
} |
|||
if (category_list.length == 0) { |
|||
span_res.value = "" |
|||
span_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.partner_category_ids = partner_category_ids |
|||
|
|||
|
|||
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"; |
|||
|
|||
} |
|||
} |
|||
|
|||
if ($(".result_selection").length) { |
|||
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 |
|||
], |
|||
}).then(function(res) { |
|||
self.initial_render = false; |
|||
self.load_data(self.initial_render); |
|||
}); |
|||
}, |
|||
|
|||
}); |
|||
core.action_registry.add("p_a", PartnerAgeing); |
|||
return PartnerAgeing; |
|||
}); |
@ -1,386 +1,391 @@ |
|||
odoo.define('dynamic_cash_flow_statements.cash_flow', function (require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var framework = require('web.framework'); |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
|
|||
window.click_num = 0; |
|||
var CashFlow = AbstractAction.extend({ |
|||
template: 'CFTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .cf-line': 'get_move_lines', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency=action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.cash.flow', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
_onCalendarIconClick: function (ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ y: 1000 }), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons : { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale : moment.locale(), |
|||
format : time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
get_move_lines: function(event) { |
|||
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) { |
|||
self._rpc({ |
|||
model: 'account.cash.flow', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(datas) { |
|||
_.each(datas['journal_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); |
|||
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); |
|||
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); |
|||
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', { |
|||
count: 3, |
|||
offset: 0, |
|||
account_data: datas['journal_res'], |
|||
level:datas['levels'], |
|||
currency : datas['currency'], |
|||
line_id:parseInt(event.currentTarget.attributes[3].value), |
|||
})) |
|||
}else if(datas['levels']== 'very' || datas['levels']== false){ |
|||
$(event.currentTarget).next('tr').find('td ul').after( |
|||
QWeb.render('ChildSubSectionCF', { |
|||
count: 3, |
|||
offset: 0, |
|||
account_data: datas['account_res'], |
|||
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', |
|||
}); |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
|
|||
load_data: function (initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try{ |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.cash.flow', |
|||
method: 'view_report', |
|||
args: [[this.wizard_id]], |
|||
}).then(function(datas) { |
|||
|
|||
|
|||
_.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({ |
|||
placeholder: 'Select Journals...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
self.$el.find('.levels').select2({ |
|||
placeholder: 'Levels...', |
|||
}); |
|||
} |
|||
var child=[]; |
|||
|
|||
self.$('.table_view_tb').html(QWeb.render('CashTable', { |
|||
|
|||
account_data: datas['fetched_data'], |
|||
level:datas['levels'], |
|||
currency : datas['currency'], |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} |
|||
catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
show_gl: function(e) { |
|||
var self = this; |
|||
var account_id = $(e.target).attr('data-account-id'); |
|||
var options = { |
|||
account_ids: [account_id], |
|||
} |
|||
|
|||
var action = { |
|||
type: 'ir.actions.client', |
|||
name: 'GL View', |
|||
tag: 'g_l', |
|||
target: 'new', |
|||
|
|||
domain: [['account_ids','=', account_id]], |
|||
|
|||
|
|||
} |
|||
return this.do_action(action); |
|||
|
|||
}, |
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.cash.flow', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.cash_flow', |
|||
'report_file': 'dynamic_accounts_report.cash_flow', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.cash.flow', |
|||
'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: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.cash.flow', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': 'Cash Flow Statements', |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
downloadXlsx: function (action){ |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
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; |
|||
|
|||
var filter_data_selected = {}; |
|||
|
|||
|
|||
|
|||
if ($(".levels").length){ |
|||
var level_res = document.getElementById("level_res") |
|||
filter_data_selected.levels = $(".levels")[1].value |
|||
level_res.value = $(".levels")[1].value |
|||
level_res.innerHTML=level_res.value; |
|||
if ($(".levels").value==""){ |
|||
type_res.innerHTML="summary"; |
|||
filter_data_selected.type = "Summary" |
|||
} |
|||
} |
|||
|
|||
// if ($("#date_from").val()) {
|
|||
// var dateString = $("#date_from").val();
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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 ($(".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.cash.flow', |
|||
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("c_f", CashFlow); |
|||
return CashFlow; |
|||
odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var framework = require('web.framework'); |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
|
|||
window.click_num = 0; |
|||
var CashFlow = AbstractAction.extend({ |
|||
template: 'CFTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .cf-line': 'get_move_lines', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency = action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.cash.flow', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
_onCalendarIconClick: function(ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ |
|||
y: 1000 |
|||
}), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons: { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale: moment.locale(), |
|||
format: time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
get_move_lines: function(event) { |
|||
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) { |
|||
self._rpc({ |
|||
model: 'account.cash.flow', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(datas) { |
|||
_.each(datas['journal_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); |
|||
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); |
|||
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); |
|||
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', { |
|||
count: 3, |
|||
offset: 0, |
|||
account_data: datas['journal_res'], |
|||
level: datas['levels'], |
|||
currency: datas['currency'], |
|||
line_id: parseInt(event.currentTarget.attributes[3].value), |
|||
})) |
|||
} else if (datas['levels'] == 'very' || datas['levels'] == false) { |
|||
$(event.currentTarget).next('tr').find('td ul').after( |
|||
QWeb.render('ChildSubSectionCF', { |
|||
count: 3, |
|||
offset: 0, |
|||
account_data: datas['account_res'], |
|||
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', |
|||
}); |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
|
|||
load_data: function(initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.cash.flow', |
|||
method: 'view_report', |
|||
args: [ |
|||
[this.wizard_id] |
|||
], |
|||
}).then(function(datas) { |
|||
|
|||
|
|||
_.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({ |
|||
placeholder: 'Select Journals...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
self.$el.find('.levels').select2({ |
|||
placeholder: 'Levels...', |
|||
}); |
|||
} |
|||
var child = []; |
|||
|
|||
self.$('.table_view_tb').html(QWeb.render('CashTable', { |
|||
|
|||
account_data: datas['fetched_data'], |
|||
level: datas['levels'], |
|||
currency: datas['currency'], |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
show_gl: function(e) { |
|||
var self = this; |
|||
var account_id = $(e.target).attr('data-account-id'); |
|||
var options = { |
|||
account_ids: [account_id], |
|||
} |
|||
|
|||
var action = { |
|||
type: 'ir.actions.client', |
|||
name: 'GL View', |
|||
tag: 'g_l', |
|||
target: 'new', |
|||
|
|||
domain: [ |
|||
['account_ids', '=', account_id] |
|||
], |
|||
|
|||
|
|||
} |
|||
return this.do_action(action); |
|||
|
|||
}, |
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.cash.flow', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.cash_flow', |
|||
'report_file': 'dynamic_accounts_report.cash_flow', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.cash.flow', |
|||
'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: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.cash.flow', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': 'Cash Flow Statements', |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
downloadXlsx: function(action) { |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
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; |
|||
|
|||
var filter_data_selected = {}; |
|||
|
|||
|
|||
|
|||
if ($(".levels").length) { |
|||
var level_res = document.getElementById("level_res") |
|||
filter_data_selected.levels = $(".levels")[1].value |
|||
level_res.value = $(".levels")[1].value |
|||
level_res.innerHTML = level_res.value; |
|||
if ($(".levels").value == "") { |
|||
type_res.innerHTML = "summary"; |
|||
filter_data_selected.type = "Summary" |
|||
} |
|||
} |
|||
|
|||
// if ($("#date_from").val()) {
|
|||
// var dateString = $("#date_from").val();
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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 ($(".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.cash.flow', |
|||
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("c_f", CashFlow); |
|||
return CashFlow; |
|||
}); |
@ -1,439 +1,439 @@ |
|||
odoo.define('dynamic_partner_daybook.daybook', function (require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
var framework = require('web.framework'); |
|||
|
|||
window.click_num = 0; |
|||
var DayBook = AbstractAction.extend({ |
|||
template: 'DaybookTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .db-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency=action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.day.book', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
_onCalendarIconClick: function (ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ y: 1000 }), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons : { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale : moment.locale(), |
|||
format : time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
load_data: function (initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try{ |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [[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); |
|||
rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance); |
|||
|
|||
}); |
|||
|
|||
if (initial_render) { |
|||
|
|||
self.$('.filter_view_db').html(QWeb.render('DayFilterView', { |
|||
filter_data: datas['filters'], |
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: ' Journals...', |
|||
}); |
|||
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'], |
|||
filter : datas['filters'], |
|||
currency : datas['currency'], |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} |
|||
catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
|
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
|
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.day_book', |
|||
'report_file': 'dynamic_accounts_report.day_book', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.day.book', |
|||
'landscape': 1, |
|||
'daybook_pdf_report': true |
|||
}, |
|||
'display_name': 'Day Book', |
|||
}; |
|||
|
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.day.book', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': 'Day Book', |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
downloadXlsx: function (action){ |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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;"; |
|||
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_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>"; |
|||
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; |
|||
var line = $(el.target).parent().data('id'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
|
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
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) { |
|||
|
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
_.each(data['report_lines'], function(rep_lines) { |
|||
_.each(rep_lines['child_lines'], function(move_line) { |
|||
|
|||
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'] ){ |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSectiondb', { |
|||
|
|||
account_data: data['report_lines'][i]['child_lines'], |
|||
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', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
|
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
|
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
|
|||
var filter_data_selected = {}; |
|||
|
|||
|
|||
var account_ids = []; |
|||
var account_text = []; |
|||
|
|||
var account_res = document.getElementById("acc_res") |
|||
|
|||
var account_list = $(".account-partner").select2('data') |
|||
for (var i = 0; i < account_list.length; i++) { |
|||
if(account_list[i].element[0].selected === true){ |
|||
|
|||
account_ids.push(parseInt(account_list[i].id)) |
|||
if(account_text.includes(account_list[i].text) === false){ |
|||
account_text.push(account_list[i].text) |
|||
} |
|||
account_res.value = account_text |
|||
account_res.innerHTML=account_res.value; |
|||
} |
|||
} |
|||
if (account_list.length == 0){ |
|||
account_res.value = "" |
|||
account_res.innerHTML=""; |
|||
|
|||
} |
|||
|
|||
filter_data_selected.account_ids = account_ids |
|||
|
|||
|
|||
|
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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){ |
|||
|
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0){ |
|||
journal_res.value = "" |
|||
journal_res.innerHTML=""; |
|||
|
|||
} |
|||
filter_data_selected.journal_ids = journal_ids |
|||
|
|||
// if ($("#date_from").val()) {
|
|||
// var dateString = $("#date_from").val();
|
|||
//
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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 ($(".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.day.book', |
|||
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("d_b", DayBook); |
|||
return DayBook; |
|||
}); |
|||
odoo.define('dynamic_partner_daybook.daybook', function(require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
var framework = require('web.framework'); |
|||
|
|||
window.click_num = 0; |
|||
var DayBook = AbstractAction.extend({ |
|||
template: 'DaybookTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .db-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency = action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.day.book', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
_onCalendarIconClick: function(ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ |
|||
y: 1000 |
|||
}), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons: { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale: moment.locale(), |
|||
format: time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
load_data: function(initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[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); |
|||
rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance); |
|||
|
|||
}); |
|||
|
|||
if (initial_render) { |
|||
|
|||
self.$('.filter_view_db').html(QWeb.render('DayFilterView', { |
|||
filter_data: datas['filters'], |
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: ' Journals...', |
|||
}); |
|||
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'], |
|||
filter: datas['filters'], |
|||
currency: datas['currency'], |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
|
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
|
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.day_book', |
|||
'report_file': 'dynamic_accounts_report.day_book', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.day.book', |
|||
'landscape': 1, |
|||
'daybook_pdf_report': true |
|||
}, |
|||
'display_name': 'Day Book', |
|||
}; |
|||
|
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.day.book', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': 'Day Book', |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
downloadXlsx: function(action) { |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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;"; |
|||
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_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>"; |
|||
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; |
|||
var line = $(el.target).parent().data('id'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
|
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
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) { |
|||
|
|||
self._rpc({ |
|||
model: 'account.day.book', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
_.each(data['report_lines'], function(rep_lines) { |
|||
_.each(rep_lines['child_lines'], function(move_line) { |
|||
|
|||
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']) { |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSectiondb', { |
|||
|
|||
account_data: data['report_lines'][i]['child_lines'], |
|||
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', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
|
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
|
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
|
|||
var filter_data_selected = {}; |
|||
|
|||
|
|||
var account_ids = []; |
|||
var account_text = []; |
|||
|
|||
var account_res = document.getElementById("acc_res") |
|||
var account_list = $(".account-partner").select2('data') |
|||
for (var i = 0; i < account_list.length; i++) { |
|||
if (account_list[i].element[0].selected === true) { |
|||
|
|||
account_ids.push(parseInt(account_list[i].id)) |
|||
if (account_text.includes(account_list[i].text) === false) { |
|||
account_text.push(account_list[i].text) |
|||
} |
|||
account_res.value = account_text |
|||
account_res.innerHTML = account_res.value; |
|||
} |
|||
} |
|||
if (account_list.length == 0) { |
|||
account_res.value = "" |
|||
account_res.innerHTML = ""; |
|||
|
|||
} |
|||
|
|||
filter_data_selected.account_ids = account_ids |
|||
|
|||
|
|||
|
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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) { |
|||
|
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0) { |
|||
journal_res.value = "" |
|||
journal_res.innerHTML = ""; |
|||
|
|||
} |
|||
filter_data_selected.journal_ids = journal_ids |
|||
|
|||
// if ($("#date_from").val()) {
|
|||
// var dateString = $("#date_from").val();
|
|||
//
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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 ($(".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.day.book', |
|||
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("d_b", DayBook); |
|||
return DayBook; |
|||
}); |
@ -1,509 +1,471 @@ |
|||
odoo.define('dynamic_accounts_report.general_ledger', function (require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var trial = require('dynamic_accounts_report.trial_balance'); |
|||
var framework = require('web.framework'); |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
|
|||
window.click_num = 0; |
|||
var GeneralLedger = AbstractAction.extend({ |
|||
template: 'GeneralTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .gl-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency=action.currency; |
|||
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) { |
|||
rpc.query({ |
|||
model: 'account.general.ledger', |
|||
method: 'create', |
|||
args: [{ |
|||
account_ids : [this.searchModel.config.domain[0][2]] |
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}else{ |
|||
rpc.query({ |
|||
model: 'account.general.ledger', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
|
|||
_onCalendarIconClick: function (ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ y: 1000 }), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons : { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale : moment.locale(), |
|||
format : time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
load_data: function (initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try{ |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'view_report', |
|||
args: [[this.wizard_id], action_title], |
|||
}).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);
|
|||
// rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance);
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
// });
|
|||
|
|||
if (initial_render) { |
|||
self.$('.filter_view_tb').html(QWeb.render('GLFilterView', { |
|||
filter_data: datas['filters'], |
|||
title : datas['name'], |
|||
// eng_title : datas['eng_title'],
|
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: ' Journals...', |
|||
}); |
|||
self.$el.find('.account-partner').select2({ |
|||
placeholder: ' Accounts...', |
|||
}); |
|||
self.$el.find('.analytics').select2({ |
|||
placeholder: 'Analytic Accounts...', |
|||
}); |
|||
// self.$el.find('.analytic_tags').select2({
|
|||
// placeholder: 'Analytic Tags...',
|
|||
// });
|
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
|
|||
} |
|||
var child=[]; |
|||
self.$('.table_view_tb').html(QWeb.render('GLTable', { |
|||
|
|||
report_lines : datas['report_lines'], |
|||
filter : datas['filters'], |
|||
currency : datas['currency'], |
|||
credit_total : datas['credit_total'], |
|||
debit_total : datas['debit_total'], |
|||
debit_balance : datas['debit_balance'] |
|||
})); |
|||
|
|||
}); |
|||
|
|||
} |
|||
catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id], action_title |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.general_ledger', |
|||
'report_file': 'dynamic_accounts_report.general_ledger', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.general.ledger', |
|||
'landscape': 1, |
|||
'trial_pdf_report': true |
|||
}, |
|||
'display_name': action_title, |
|||
}; |
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id], action_title |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.general.ledger', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': action_title, |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
|
|||
downloadXlsx: function (action){ |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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;"; |
|||
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_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>"; |
|||
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; |
|||
var line = $(el.target).parent().data('id'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
|
|||
}, |
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
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) { |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'get_accounts_line', |
|||
args: [ |
|||
[self.wizard_id], account_id, action_title |
|||
], |
|||
}).then(function(data) { |
|||
// _.each(data['report_lines'], function(rep_lines) {
|
|||
// _.each(rep_lines['move_lines'], function(move_line) {
|
|||
//
|
|||
// 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'] ){ |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSection', { |
|||
account_data: data['report_lines'][i]['move_lines'], |
|||
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', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
|
|||
var filter_data_selected = {}; |
|||
|
|||
|
|||
var account_ids = []; |
|||
var account_text = []; |
|||
|
|||
var account_res = document.getElementById("acc_res") |
|||
var account_list = $(".account-partner").select2('data') |
|||
for (var i = 0; i < account_list.length; i++) { |
|||
if(account_list[i].element[0].selected === true){ |
|||
account_ids.push(parseInt(account_list[i].id)) |
|||
if(account_text.includes(account_list[i].text) === false){ |
|||
account_text.push(account_list[i].text) |
|||
} |
|||
account_res.value = account_text |
|||
account_res.innerHTML=account_res.value; |
|||
} |
|||
} |
|||
if (account_list.length == 0){ |
|||
account_res.value = "" |
|||
account_res.innerHTML=""; |
|||
|
|||
} |
|||
filter_data_selected.account_ids = account_ids |
|||
|
|||
|
|||
if(!(this._title == 'Bank Book' || this._title == 'Cash Book')){ |
|||
|
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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){ |
|||
|
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0){ |
|||
journal_res.value = "" |
|||
journal_res.innerHTML=""; |
|||
|
|||
} |
|||
filter_data_selected.journal_ids = journal_ids |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
// var analytic_ids = []
|
|||
// var analytic_text = [];
|
|||
//// var analytic_res = document.getElementById("analytic_res")
|
|||
// var analytic_list = $(".analytics").select2('data')
|
|||
//
|
|||
// for (var i = 0; i < analytic_list.length; i++) {
|
|||
// if(analytic_list[i].element[0].selected === true){
|
|||
//
|
|||
// analytic_ids.push(parseInt(analytic_list[i].id))
|
|||
// if(analytic_text.includes(analytic_list[i].text) === false){
|
|||
// analytic_text.push(analytic_list[i].text)
|
|||
// }
|
|||
// analytic_res.value = analytic_text
|
|||
// analytic_res.innerHTML=analytic_res.value;
|
|||
// }
|
|||
// }
|
|||
// if (analytic_list.length == 0){
|
|||
// analytic_res.value = ""
|
|||
// analytic_res.innerHTML="";
|
|||
//
|
|||
// }
|
|||
// filter_data_selected.analytic_ids = analytic_ids
|
|||
//
|
|||
// var analytic_tag_ids = []
|
|||
// var analytic_tag_text = [];
|
|||
// var analytic_tag_res = document.getElementById("analytic_tag_res")
|
|||
// var analytic_tag_list = $(".analytic_tags").select2('data')
|
|||
// for (var i = 0; i < analytic_tag_list.length; i++) {
|
|||
// if(analytic_tag_list[i].element[0].selected === true){
|
|||
//
|
|||
// analytic_tag_ids.push(parseInt(analytic_tag_list[i].id))
|
|||
// if(analytic_tag_text.includes(analytic_tag_list[i].text) === false){
|
|||
// analytic_tag_text.push(analytic_tag_list[i].text)
|
|||
// }
|
|||
// analytic_tag_res.value = analytic_tag_text
|
|||
// analytic_tag_res.innerHTML=analytic_tag_res.value;
|
|||
// }
|
|||
// }
|
|||
// if (analytic_tag_list.length == 0){
|
|||
// analytic_tag_res.value = ""
|
|||
// analytic_tag_res.innerHTML="";
|
|||
//
|
|||
// }
|
|||
// filter_data_selected.analytic_tag_ids = analytic_tag_ids
|
|||
|
|||
// if ($("#date_from").val()) {
|
|||
//
|
|||
// var dateString = $("#date_from").val();
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
// 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; |
|||
odoo.define('dynamic_accounts_report.general_ledger', function(require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var trial = require('dynamic_accounts_report.trial_balance'); |
|||
var framework = require('web.framework'); |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
window.click_num = 0; |
|||
var GeneralLedger = AbstractAction.extend({ |
|||
template: 'GeneralTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .gl-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency = action.currency; |
|||
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) { |
|||
rpc.query({ |
|||
model: 'account.general.ledger', |
|||
method: 'create', |
|||
args: [{ |
|||
account_ids: [this.searchModel.config.domain[0][2]] |
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
} else { |
|||
rpc.query({ |
|||
model: 'account.general.ledger', |
|||
method: 'create', |
|||
args: [{}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
_onCalendarIconClick: function(ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
var calendarOptions = { |
|||
minDate: moment({ |
|||
y: 1000 |
|||
}), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
icons: { |
|||
date: 'fa fa-calendar', |
|||
}, |
|||
locale: moment.locale(), |
|||
format: time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
load_data: function(initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try { |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[this.wizard_id], action_title |
|||
], |
|||
}).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);
|
|||
// rep_lines.balance = self.format_currency(datas['currency'],rep_lines.balance);
|
|||
// });
|
|||
|
|||
if (initial_render) { |
|||
self.$('.filter_view_tb').html(QWeb.render('GLFilterView', { |
|||
filter_data: datas['filters'], |
|||
title: datas['name'], |
|||
// eng_title : datas['eng_title'],
|
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: ' Journals...', |
|||
}); |
|||
self.$el.find('.account-partner').select2({ |
|||
placeholder: ' Accounts...', |
|||
}); |
|||
self.$el.find('.account-tag').select2({ |
|||
placeholder: ' Account Tag...', |
|||
}); |
|||
self.$el.find('.analytics').select2({ |
|||
placeholder: 'Analytic Accounts...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
} |
|||
var child = []; |
|||
self.$('.table_view_tb').html(QWeb.render('GLTable', { |
|||
report_lines: datas['report_lines'], |
|||
filter: datas['filters'], |
|||
currency: datas['currency'], |
|||
credit_total: datas['credit_total'], |
|||
debit_total: datas['debit_total'], |
|||
debit_balance: datas['debit_balance'] |
|||
})); |
|||
}); |
|||
} catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id], action_title |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.general_ledger', |
|||
'report_file': 'dynamic_accounts_report.general_ledger', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.general.ledger', |
|||
'landscape': 1, |
|||
'trial_pdf_report': true |
|||
}, |
|||
'display_name': action_title, |
|||
}; |
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id], action_title |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.general.ledger', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': action_title, |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
|
|||
downloadXlsx: function(action) { |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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;"; |
|||
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_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>"; |
|||
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; |
|||
var line = $(el.target).parent().data('id'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
|
|||
}, |
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
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) { |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.general.ledger', |
|||
method: 'get_accounts_line', |
|||
args: [ |
|||
[self.wizard_id], account_id, action_title |
|||
], |
|||
}).then(function(data) { |
|||
// _.each(data['report_lines'], function(rep_lines) {
|
|||
// _.each(rep_lines['move_lines'], function(move_line) {
|
|||
//
|
|||
// 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']) { |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSection', { |
|||
account_data: data['report_lines'][i]['move_lines'], |
|||
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', |
|||
}); |
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
var filter_data_selected = {}; |
|||
|
|||
//Account filter
|
|||
var account_ids = []; |
|||
var account_text = []; |
|||
var account_res = document.getElementById("account_res") |
|||
var account_list = $(".account-partner").select2('data') |
|||
for (var i = 0; i < account_list.length; i++) { |
|||
if (account_list[i].element[0].selected === true) { |
|||
account_ids.push(parseInt(account_list[i].id)) |
|||
if (account_text.includes(account_list[i].text) === false) { |
|||
account_text.push(account_list[i].text) |
|||
} |
|||
account_res.value = account_text |
|||
account_res.innerHTML = account_res.value; |
|||
} |
|||
} |
|||
if (account_list.length == 0) { |
|||
account_res.value = "" |
|||
account_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.account_ids = account_ids |
|||
|
|||
//Account Tag filter
|
|||
var account_tag_ids = []; |
|||
var account_tag_text = []; |
|||
var account_tag_res = document.getElementById("acc_tag_res") |
|||
|
|||
var account_tag_list = $(".account-tag").select2('data') |
|||
for (var i = 0; i < account_tag_list.length; i++) { |
|||
if (account_tag_list[i].element[0].selected === true) { |
|||
|
|||
account_tag_ids.push(parseInt(account_tag_list[i].id)) |
|||
if (account_tag_text.includes(account_tag_list[i].text) === false) { |
|||
account_tag_text.push(account_tag_list[i].text) |
|||
} |
|||
|
|||
account_tag_res.value = account_tag_text |
|||
account_tag_res.innerHTML = account_tag_res.value; |
|||
} |
|||
} |
|||
if (account_tag_list.length == 0) { |
|||
account_tag_res.value = "" |
|||
account_tag_res.innerHTML = ""; |
|||
|
|||
} |
|||
filter_data_selected.account_tag_ids = account_tag_ids |
|||
|
|||
//Journal Filter
|
|||
if (!(this._title == 'Bank Book' || this._title == 'Cash Book')) { |
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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) { |
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0) { |
|||
journal_res.value = "" |
|||
journal_res.innerHTML = ""; |
|||
} |
|||
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') |
|||
for (var i = 0; i < analytic_list.length; i++) { |
|||
if (analytic_list[i].element[0].selected === true) { |
|||
analytic_ids.push(parseInt(analytic_list[i].id)) |
|||
if (analytic_text.includes(analytic_list[i].text) === false) { |
|||
analytic_text.push(analytic_list[i].text) |
|||
} |
|||
analytic_res.value = analytic_text |
|||
analytic_res.innerHTML = analytic_res.value; |
|||
} |
|||
} |
|||
if (analytic_list.length == 0) { |
|||
analytic_res.value = "" |
|||
analytic_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.analytic_ids = analytic_ids |
|||
|
|||
//Date range filter
|
|||
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'); |
|||
} |
|||
|
|||
//Target Move Filter
|
|||
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) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
|
|||
window.click_num = 0; |
|||
var PartnerLedger = AbstractAction.extend({ |
|||
template: 'PartnerTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .pl-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
|
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency=action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.partner.ledger', |
|||
method: 'create', |
|||
args: [{ |
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
_onCalendarIconClick: function (ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ y: 1000 }), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons : { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale : moment.locale(), |
|||
format : time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
load_data: function (initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try{ |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [[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); |
|||
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'], |
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: ' Journals...', |
|||
}); |
|||
|
|||
self.$el.find('.account-partner').select2({ |
|||
placeholder: ' Accounts...', |
|||
}); |
|||
self.$el.find('.partners').select2({ |
|||
placeholder: 'Partners...', |
|||
}); |
|||
self.$el.find('.reconciled').select2({ |
|||
placeholder: 'Reconciled status...', |
|||
}); |
|||
self.$el.find('.type').select2({ |
|||
placeholder: 'Account Type...', |
|||
}); |
|||
self.$el.find('.category').select2({ |
|||
placeholder: 'Partner Tag...', |
|||
}); |
|||
self.$el.find('.acc').select2({ |
|||
placeholder: 'Select Acc...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
} |
|||
var child=[]; |
|||
self.$('.table_view_tb').html(QWeb.render('PLTable', { |
|||
report_lines : datas['report_lines'], |
|||
filter : datas['filters'], |
|||
currency : datas['currency'], |
|||
credit_total : datas['credit_total'], |
|||
debit_total : datas['debit_total'], |
|||
debit_balance : datas['debit_balance'] |
|||
})); |
|||
}); |
|||
|
|||
} |
|||
catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
|
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.partner_ledger', |
|||
'report_file': 'dynamic_accounts_report.partner_ledger', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.partner.ledger', |
|||
'landscape': 1, |
|||
'partner_ledger_pdf_report': true |
|||
}, |
|||
'display_name': 'Partner Ledger', |
|||
}; |
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
|
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.partner.ledger', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': 'Partner Ledger', |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
core.action_registry.map.t_b.prototype.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
|
|||
journal_line_click: function (el){ |
|||
click_num++; |
|||
var self = this; |
|||
var line = $(el.target).parent().data('id'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
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) { |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
_.each(data['report_lines'], function(rep_lines) { |
|||
_.each(rep_lines['move_lines'], function(move_line) { |
|||
|
|||
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'] ){ |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSectionPL', { |
|||
account_data: data['report_lines'][i]['move_lines'], |
|||
id : data['report_lines'][i]['id'] |
|||
})) |
|||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
|||
'background-color': '#00ede8', |
|||
'font-weight': 'bold', |
|||
}); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
var filter_data_selected = {}; |
|||
|
|||
var account_ids = []; |
|||
var account_text = []; |
|||
var span_res = document.getElementById("account_res") |
|||
var account_list = $(".account-partner").select2('data') |
|||
for (var i = 0; i < account_list.length; i++) { |
|||
if(account_list[i].element[0].selected === true) |
|||
{account_ids.push(parseInt(account_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (account_list.length == 0){ |
|||
span_res.value = "" |
|||
span_res.innerHTML=""; } |
|||
filter_data_selected.account_ids = account_ids |
|||
|
|||
|
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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){ |
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0){ |
|||
journal_res.value = "" |
|||
journal_res.innerHTML=""; |
|||
} |
|||
filter_data_selected.journal_ids = journal_ids |
|||
|
|||
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) |
|||
{partner_ids.push(parseInt(partner_list[i].id)) |
|||
if(partner_text.includes(partner_list[i].text) === false) |
|||
{partner_text.push(partner_list[i].text) |
|||
} |
|||
span_res.value = partner_text |
|||
span_res.innerHTML=span_res.value; |
|||
} |
|||
} |
|||
if (partner_list.length == 0){ |
|||
span_res.value = "" |
|||
span_res.innerHTML=""; |
|||
} |
|||
filter_data_selected.partner_ids = partner_ids |
|||
|
|||
var account_type_id = []; |
|||
var account_type_ids_text = []; |
|||
var span_res = document.getElementById("type_res") |
|||
var type_list = $(".type").select2('data') |
|||
for (var i = 0; i < type_list.length; i++) { |
|||
if(type_list[i].element[0].selected === true) |
|||
{account_type_id.push(parseInt(type_list[i].id)) |
|||
if(account_type_ids_text.includes(type_list[i].text) === false) |
|||
{account_type_ids_text.push(type_list[i].text) |
|||
} |
|||
span_res.value = account_type_ids_text |
|||
span_res.innerHTML=span_res.value; |
|||
} |
|||
} |
|||
if (type_list.length == 0){ |
|||
span_res.value = "" |
|||
span_res.innerHTML=""; |
|||
} |
|||
filter_data_selected.account_type_id = account_type_id |
|||
|
|||
var partner_category_ids = []; |
|||
var partner_category_text = []; |
|||
var span_res = document.getElementById("category_res") |
|||
var category_list = $(".category").select2('data') |
|||
for (var i = 0; i < category_list.length; i++) { |
|||
if(category_list[i].element[0].selected === true) |
|||
{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) |
|||
} |
|||
span_res.value = partner_category_text |
|||
span_res.innerHTML=span_res.value; |
|||
} |
|||
} |
|||
if (category_list.length == 0){ |
|||
span_res.value = "" |
|||
span_res.innerHTML=""; |
|||
} |
|||
filter_data_selected.partner_category_ids = partner_category_ids |
|||
|
|||
// if ($("#date_from").val()) {
|
|||
// var dateString = $("#date_from").val();
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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 ($(".reconciled").length){ |
|||
var reconciled_res = document.getElementById("reconciled_res") |
|||
filter_data_selected.reconciled = $(".reconciled")[1].value |
|||
reconciled_res.value = $(".reconciled")[1].value |
|||
reconciled_res.innerHTML=reconciled_res.value; |
|||
if ($(".reconciled").value==""){ |
|||
reconciled_res.innerHTML="unreconciled"; |
|||
filter_data_selected.reconciled = "unreconciled" |
|||
} |
|||
} |
|||
|
|||
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.partner.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("p_l", PartnerLedger); |
|||
return PartnerLedger; |
|||
}); |
|||
odoo.define('dynamic_accounts_report.partner_ledger', function(require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
var framework = require('web.framework'); |
|||
|
|||
window.click_num = 0; |
|||
var PartnerLedger = AbstractAction.extend({ |
|||
template: 'PartnerTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .pl-line': 'show_drop_down', |
|||
'click .view-account-move': 'view_acc_move', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
|
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency = action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.partner.ledger', |
|||
method: 'create', |
|||
args: [{}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
_onCalendarIconClick: function(ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
minDate: moment({ |
|||
y: 1000 |
|||
}), |
|||
maxDate: moment().add(200, 'y'), |
|||
calendarWeeks: true, |
|||
defaultDate: moment().format(), |
|||
sideBySide: true, |
|||
buttons: { |
|||
showClear: true, |
|||
showClose: true, |
|||
showToday: true, |
|||
}, |
|||
|
|||
icons: { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale: moment.locale(), |
|||
format: time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
load_data: function(initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[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); |
|||
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'], |
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: ' Journals...', |
|||
}); |
|||
|
|||
self.$el.find('.account-partner').select2({ |
|||
placeholder: ' Accounts...', |
|||
}); |
|||
self.$el.find('.partners').select2({ |
|||
placeholder: 'Partners...', |
|||
}); |
|||
self.$el.find('.reconciled').select2({ |
|||
placeholder: 'Reconciled status...', |
|||
}); |
|||
self.$el.find('.type').select2({ |
|||
placeholder: 'Account Type...', |
|||
}); |
|||
self.$el.find('.category').select2({ |
|||
placeholder: 'Partner Tag...', |
|||
}); |
|||
self.$el.find('.acc').select2({ |
|||
placeholder: 'Select Acc...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
} |
|||
var child = []; |
|||
self.$('.table_view_tb').html(QWeb.render('PLTable', { |
|||
report_lines: datas['report_lines'], |
|||
filter: datas['filters'], |
|||
currency: datas['currency'], |
|||
credit_total: datas['credit_total'], |
|||
debit_total: datas['debit_total'], |
|||
debit_balance: datas['debit_balance'] |
|||
})); |
|||
}); |
|||
|
|||
} catch (el) { |
|||
window.location.href |
|||
} |
|||
}, |
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.partner_ledger', |
|||
'report_file': 'dynamic_accounts_report.partner_ledger', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.partner.ledger', |
|||
'landscape': 1, |
|||
'partner_ledger_pdf_report': true |
|||
}, |
|||
'display_name': 'Partner Ledger', |
|||
}; |
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
var action_title = self._title |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.partner.ledger', |
|||
'options': JSON.stringify(data['filters']), |
|||
'output_format': 'xlsx', |
|||
'report_data': JSON.stringify(data['report_lines']), |
|||
'report_name': action_title, |
|||
'dfr_data': JSON.stringify(data), |
|||
}, |
|||
}; |
|||
// return self.do_action(action);
|
|||
// core.action_registry.map.t_b.prototype.downloadXlsx(action)
|
|||
self.downloadXlsx(action) |
|||
}); |
|||
}, |
|||
downloadXlsx: function(action) { |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: 'account.move', |
|||
views: [ |
|||
[false, 'form'] |
|||
], |
|||
res_id: line, |
|||
target: 'current', |
|||
}); |
|||
}, |
|||
|
|||
show_drop_down: function(event) { |
|||
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) { |
|||
self._rpc({ |
|||
model: 'account.partner.ledger', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
_.each(data['report_lines'], function(rep_lines) { |
|||
_.each(rep_lines['move_lines'], function(move_line) { |
|||
|
|||
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']) { |
|||
$(event.currentTarget).next('tr').find('td').remove(); |
|||
$(event.currentTarget).next('tr').after( |
|||
QWeb.render('SubSectionPL', { |
|||
account_data: data['report_lines'][i]['move_lines'], |
|||
id: data['report_lines'][i]['id'] |
|||
})) |
|||
$(event.currentTarget).next('tr').find('td ul li:first a').css({ |
|||
'background-color': '#00ede8', |
|||
'font-weight': 'bold', |
|||
}); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
}, |
|||
|
|||
view_acc_move: function(event) { |
|||
event.preventDefault(); |
|||
var self = this; |
|||
var context = {}; |
|||
var show_acc_move = function(res_model, res_id, view_id) { |
|||
var action = { |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
res_model: res_model, |
|||
views: [ |
|||
[view_id || false, 'form'] |
|||
], |
|||
res_id: res_id, |
|||
target: 'current', |
|||
context: context, |
|||
}; |
|||
return self.do_action(action); |
|||
}; |
|||
rpc.query({ |
|||
model: 'account.move', |
|||
method: 'search_read', |
|||
domain: [ |
|||
['id', '=', $(event.currentTarget).data('move-id')] |
|||
], |
|||
fields: ['id'], |
|||
limit: 1, |
|||
}) |
|||
.then(function(record) { |
|||
if (record.length > 0) { |
|||
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(); |
|||
var self = this; |
|||
self.initial_render = false; |
|||
var filter_data_selected = {}; |
|||
|
|||
//Account filter
|
|||
var account_ids = []; |
|||
var account_text = []; |
|||
var span_res = document.getElementById("account_res") |
|||
var account_list = $(".account-partner").select2('data') |
|||
for (var i = 0; i < account_list.length; i++) { |
|||
if (account_list[i].element[0].selected === true) { |
|||
account_ids.push(parseInt(account_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (account_list.length == 0) { |
|||
span_res.value = "" |
|||
span_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.account_ids = account_ids |
|||
|
|||
//Journal Filter
|
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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) { |
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0) { |
|||
journal_res.value = "" |
|||
journal_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.journal_ids = journal_ids |
|||
|
|||
//Partner Filter
|
|||
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) { |
|||
partner_ids.push(parseInt(partner_list[i].id)) |
|||
if (partner_text.includes(partner_list[i].text) === false) { |
|||
partner_text.push(partner_list[i].text) |
|||
} |
|||
span_res.value = partner_text |
|||
span_res.innerHTML = span_res.value; |
|||
} |
|||
} |
|||
if (partner_list.length == 0) { |
|||
span_res.value = "" |
|||
span_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.partner_ids = partner_ids |
|||
|
|||
//Account Type Filter
|
|||
if ($(".type").length) { |
|||
var type_res = document.getElementById("type_res") |
|||
filter_data_selected.account_type = $(".type")[1].value |
|||
type_res.value = $(".type")[1].value |
|||
type_res.innerHTML = account_type.value; |
|||
if ($(".type").value == "") { |
|||
type_res.innerHTML = "asset_receivable"; |
|||
filter_data_selected.account_type = "asset_receivable" |
|||
} |
|||
} |
|||
|
|||
//Partner Category Filter
|
|||
var partner_category_ids = []; |
|||
var partner_category_text = []; |
|||
var span_res = document.getElementById("category_res") |
|||
var category_list = $(".category").select2('data') |
|||
for (var i = 0; i < category_list.length; i++) { |
|||
if (category_list[i].element[0].selected === true) { |
|||
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) |
|||
} |
|||
span_res.value = partner_category_text |
|||
span_res.innerHTML = span_res.value; |
|||
} |
|||
} |
|||
if (category_list.length == 0) { |
|||
span_res.value = "" |
|||
span_res.innerHTML = ""; |
|||
} |
|||
filter_data_selected.partner_category_ids = partner_category_ids |
|||
|
|||
//Date range filter
|
|||
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'); |
|||
} |
|||
|
|||
//Reconciled Filter
|
|||
if ($(".reconciled").length) { |
|||
var reconciled_res = document.getElementById("reconciled_res") |
|||
filter_data_selected.reconciled = $(".reconciled")[1].value |
|||
reconciled_res.value = $(".reconciled")[1].value |
|||
reconciled_res.innerHTML = reconciled_res.value; |
|||
if ($(".reconciled").value == "") { |
|||
reconciled_res.innerHTML = "unreconciled"; |
|||
filter_data_selected.reconciled = "unreconciled" |
|||
} |
|||
} |
|||
|
|||
//Target Move Filter
|
|||
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.partner.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("p_l", PartnerLedger); |
|||
return PartnerLedger; |
|||
}); |
@ -1,338 +1,336 @@ |
|||
odoo.define('dynamic_accounts_report.trial_balance', function (require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
|
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var framework = require('web.framework'); |
|||
|
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
|
|||
// import framework from 'web.framework';
|
|||
// import { download } from "@web/core/network/download";
|
|||
|
|||
|
|||
// import { registry } from "@web/core/registry";
|
|||
// const serviceRegistry = registry.category("services");
|
|||
|
|||
window.click_num = 0; |
|||
var TrialBalance = AbstractAction.extend({ |
|||
template: 'TrialTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .show-gl': 'show_gl', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency=action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.trial.balance', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
|
|||
load_data: function (initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try{ |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.trial.balance', |
|||
method: 'view_report', |
|||
args: [[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); |
|||
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'], |
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: 'Select Journals...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
// self.$el.find('#start_dateee').select2({
|
|||
// placeholder: 'Date.',
|
|||
// });
|
|||
} |
|||
var child=[]; |
|||
|
|||
self.$('.table_view_tb').html(QWeb.render('TrialTable', { |
|||
|
|||
report_lines : datas['report_lines'], |
|||
filter : datas['filters'], |
|||
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 |
|||
} |
|||
}, |
|||
|
|||
show_gl: function(e) { |
|||
var self = this; |
|||
var account_id = $(e.target).attr('data-account-id'); |
|||
var options = { |
|||
account_ids: [account_id], |
|||
} |
|||
|
|||
var action = { |
|||
type: 'ir.actions.client', |
|||
name: 'GL View', |
|||
tag: 'g_l', |
|||
target: 'new', |
|||
|
|||
domain: [['account_ids','=', account_id]], |
|||
|
|||
|
|||
} |
|||
return this.do_action(action); |
|||
|
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.trial.balance', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.trial_balance', |
|||
'report_file': 'dynamic_accounts_report.trial_balance', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.trial.balance', |
|||
'landscape': 1, |
|||
'trial_pdf_report': true |
|||
}, |
|||
'display_name': 'Trial Balance', |
|||
}; |
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
_onCalendarIconClick: function (ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
// minDate: moment({ y: 1000 }),
|
|||
// maxDate: moment().add(200, 'y'),
|
|||
// calendarWeeks: true,
|
|||
// defaultDate: moment().format(),
|
|||
// sideBySide: true,
|
|||
// buttons: {
|
|||
// showClear: true,
|
|||
// showClose: true,
|
|||
// showToday: true,
|
|||
// },
|
|||
|
|||
icons : { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale : moment.locale(), |
|||
format : time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2],{ |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.trial.balance', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.trial.balance', |
|||
'options': JSON.stringify(data['filters']), |
|||
'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); |
|||
}); |
|||
}, |
|||
|
|||
downloadXlsx: function (action){ |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
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; |
|||
|
|||
|
|||
|
|||
|
|||
var filter_data_selected = {}; |
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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){ |
|||
|
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0){ |
|||
journal_res.value = "" |
|||
journal_res.innerHTML=""; |
|||
|
|||
} |
|||
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_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();
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
|
|||
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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.trial.balance', |
|||
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("t_b", TrialBalance); |
|||
return TrialBalance; |
|||
odoo.define('dynamic_accounts_report.trial_balance', function(require) { |
|||
'use strict'; |
|||
var AbstractAction = require('web.AbstractAction'); |
|||
var core = require('web.core'); |
|||
var field_utils = require('web.field_utils'); |
|||
var rpc = require('web.rpc'); |
|||
var session = require('web.session'); |
|||
var utils = require('web.utils'); |
|||
|
|||
var QWeb = core.qweb; |
|||
var _t = core._t; |
|||
var framework = require('web.framework'); |
|||
|
|||
|
|||
var datepicker = require('web.datepicker'); |
|||
var time = require('web.time'); |
|||
|
|||
// import framework from 'web.framework';
|
|||
// import { download } from "@web/core/network/download";
|
|||
|
|||
|
|||
// import { registry } from "@web/core/registry";
|
|||
// const serviceRegistry = registry.category("services");
|
|||
|
|||
window.click_num = 0; |
|||
var TrialBalance = AbstractAction.extend({ |
|||
template: 'TrialTemp', |
|||
events: { |
|||
'click .parent-line': 'journal_line_click', |
|||
'click .child_col1': 'journal_line_click', |
|||
'click #apply_filter': 'apply_filter', |
|||
'click #pdf': 'print_pdf', |
|||
'click #xlsx': 'print_xlsx', |
|||
'click .show-gl': 'show_gl', |
|||
'mousedown div.input-group.date[data-target-input="nearest"]': '_onCalendarIconClick', |
|||
}, |
|||
|
|||
init: function(parent, action) { |
|||
this._super(parent, action); |
|||
this.currency = action.currency; |
|||
this.report_lines = action.report_lines; |
|||
this.wizard_id = action.context.wizard | null; |
|||
}, |
|||
|
|||
|
|||
start: function() { |
|||
var self = this; |
|||
self.initial_render = true; |
|||
rpc.query({ |
|||
model: 'account.trial.balance', |
|||
method: 'create', |
|||
args: [{ |
|||
|
|||
}] |
|||
}).then(function(t_res) { |
|||
self.wizard_id = t_res; |
|||
self.load_data(self.initial_render); |
|||
}) |
|||
}, |
|||
|
|||
|
|||
load_data: function(initial_render = true) { |
|||
var self = this; |
|||
self.$(".categ").empty(); |
|||
try { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.trial.balance', |
|||
method: 'view_report', |
|||
args: [ |
|||
[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); |
|||
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'], |
|||
})); |
|||
self.$el.find('.journals').select2({ |
|||
placeholder: 'Select Journals...', |
|||
}); |
|||
self.$el.find('.target_move').select2({ |
|||
placeholder: 'Target Move...', |
|||
}); |
|||
// self.$el.find('#start_dateee').select2({
|
|||
// placeholder: 'Date.',
|
|||
// });
|
|||
} |
|||
var child = []; |
|||
|
|||
self.$('.table_view_tb').html(QWeb.render('TrialTable', { |
|||
|
|||
report_lines: datas['report_lines'], |
|||
filter: datas['filters'], |
|||
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 |
|||
} |
|||
}, |
|||
|
|||
show_gl: function(e) { |
|||
var self = this; |
|||
var account_id = $(e.target).attr('data-account-id'); |
|||
var options = { |
|||
account_ids: [account_id], |
|||
} |
|||
|
|||
var action = { |
|||
type: 'ir.actions.client', |
|||
name: 'GL View', |
|||
tag: 'g_l', |
|||
target: 'new', |
|||
|
|||
domain: [ |
|||
['account_ids', '=', account_id] |
|||
], |
|||
|
|||
|
|||
} |
|||
return this.do_action(action); |
|||
|
|||
}, |
|||
|
|||
print_pdf: function(e) { |
|||
e.preventDefault(); |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.trial.balance', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
'type': 'ir.actions.report', |
|||
'report_type': 'qweb-pdf', |
|||
'report_name': 'dynamic_accounts_report.trial_balance', |
|||
'report_file': 'dynamic_accounts_report.trial_balance', |
|||
'data': { |
|||
'report_data': data |
|||
}, |
|||
'context': { |
|||
'active_model': 'account.trial.balance', |
|||
'landscape': 1, |
|||
'trial_pdf_report': true |
|||
}, |
|||
'display_name': 'Trial Balance', |
|||
}; |
|||
return self.do_action(action); |
|||
}); |
|||
}, |
|||
|
|||
_onCalendarIconClick: function(ev) { |
|||
var $calendarInputGroup = $(ev.currentTarget); |
|||
|
|||
var calendarOptions = { |
|||
|
|||
// minDate: moment({ y: 1000 }),
|
|||
// maxDate: moment().add(200, 'y'),
|
|||
// calendarWeeks: true,
|
|||
// defaultDate: moment().format(),
|
|||
// sideBySide: true,
|
|||
// buttons: {
|
|||
// showClear: true,
|
|||
// showClose: true,
|
|||
// showToday: true,
|
|||
// },
|
|||
|
|||
icons: { |
|||
date: 'fa fa-calendar', |
|||
|
|||
}, |
|||
locale: moment.locale(), |
|||
format: time.getLangDateFormat(), |
|||
widgetParent: 'body', |
|||
allowInputToggle: true, |
|||
}; |
|||
|
|||
$calendarInputGroup.datetimepicker(calendarOptions); |
|||
}, |
|||
|
|||
|
|||
|
|||
format_currency: function(currency, amount) { |
|||
if (typeof(amount) != 'number') { |
|||
amount = parseFloat(amount); |
|||
} |
|||
var formatted_value = (parseInt(amount)).toLocaleString(currency[2], { |
|||
minimumFractionDigits: 2 |
|||
}) |
|||
return formatted_value |
|||
}, |
|||
|
|||
print_xlsx: function() { |
|||
var self = this; |
|||
self._rpc({ |
|||
model: 'account.trial.balance', |
|||
method: 'view_report', |
|||
args: [ |
|||
[self.wizard_id] |
|||
], |
|||
}).then(function(data) { |
|||
var action = { |
|||
// 'type': 'ir_actions_dynamic_xlsx_download',
|
|||
'data': { |
|||
'model': 'account.trial.balance', |
|||
'options': JSON.stringify(data['filters']), |
|||
'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); |
|||
}); |
|||
}, |
|||
|
|||
downloadXlsx: function(action) { |
|||
framework.blockUI(); |
|||
session.get_file({ |
|||
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'); |
|||
return self.do_action({ |
|||
type: 'ir.actions.act_window', |
|||
view_type: 'form', |
|||
view_mode: 'form', |
|||
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; |
|||
var filter_data_selected = {}; |
|||
var journal_ids = []; |
|||
var journal_text = []; |
|||
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) { |
|||
|
|||
journal_ids.push(parseInt(journal_list[i].id)) |
|||
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; |
|||
} |
|||
} |
|||
if (journal_list.length == 0) { |
|||
journal_res.value = "" |
|||
journal_res.innerHTML = ""; |
|||
|
|||
} |
|||
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_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();
|
|||
// filter_data_selected.date_from = dateString;
|
|||
// }
|
|||
|
|||
|
|||
// if ($("#date_to").val()) {
|
|||
// var dateString = $("#date_to").val();
|
|||
// filter_data_selected.date_to = dateString;
|
|||
// }
|
|||
|
|||
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.trial.balance', |
|||
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("t_b", TrialBalance); |
|||
return TrialBalance; |
|||
}); |
Loading…
Reference in new issue