diff --git a/base_accounting_kit/__manifest__.py b/base_accounting_kit/__manifest__.py index 6245516df..c3ad6578c 100644 --- a/base_accounting_kit/__manifest__.py +++ b/base_accounting_kit/__manifest__.py @@ -22,7 +22,7 @@ { 'name': 'Odoo 13 Full Accounting Kit', - 'version': '13.0.4.5.5', + 'version': '13.0.4.5.6', 'category': 'Accounting', 'live_test_url': 'https://www.youtube.com/watch?v=peAp2Tx_XIs', 'summary': """ Asset and Budget Management, diff --git a/base_accounting_kit/doc/changelog.md b/base_accounting_kit/doc/changelog.md index 7f80c2ea3..07be6be35 100644 --- a/base_accounting_kit/doc/changelog.md +++ b/base_accounting_kit/doc/changelog.md @@ -59,3 +59,8 @@ #### Version 13.0.4.5.5 #### FIX - Bug Fixed in recurring + +#### 20.03.2020 +#### Version 13.0.4.5.6 +#### UPDT +- Code Optimized-dashboard diff --git a/base_accounting_kit/models/account_dashboard.py b/base_accounting_kit/models/account_dashboard.py index 7aabfc6f7..c6c467d79 100644 --- a/base_accounting_kit/models/account_dashboard.py +++ b/base_accounting_kit/models/account_dashboard.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- -from odoo import models, fields, api +import calendar import datetime from datetime import datetime + from dateutil.relativedelta import relativedelta -import calendar + +from odoo import models, api class DashBoard(models.Model): @@ -12,190 +14,6 @@ class DashBoard(models.Model): # function to getting expenses - @api.model - def get_expense_details(self): - - self._cr.execute('''select sum(debit)-sum(credit) as expense ,to_char(account_move_line.date, 'Month') as month , - internal_group from account_move_line , - account_account - where account_move_line.account_id=account_account.id AND internal_group = 'expense' AND - to_char(DATE(NOW()), 'YY') = to_char(account_move_line.date, 'YY') - AND account_move_line.parent_state = 'posted' - group by internal_group,month - order by month desc - ''') - result = self._cr.dictfetchall() - month = list(sorted(set([item['month'] for item in result]))) - incomes = list(filter(lambda i: i['internal_group'] == 'income', result)) - expenses = list(filter(lambda i: i['internal_group'] == 'expense', result)) - inc = [item['amount'] * -1 for item in incomes] - exp = [item['amount'] for item in expenses] - record = { - 'month': month, - 'income': inc, - 'expense': exp - } - return record - - # function to getting expense of this year - - @api.model - def get_ex_this_year(self): - month_list = [] - for i in range(11, -1, -1): - l_month = datetime.now() - relativedelta(months=i) - text = format(l_month, '%B') - month_list.append(text) - - self._cr.execute('''select sum(debit)-sum(credit) as expense ,to_char(account_move_line.date, 'Month') as month , - internal_group from account_move_line , - account_account - where account_move_line.account_id=account_account.id AND internal_group = 'expense' AND - to_char(DATE(NOW()), 'YY') = to_char(account_move_line.date, 'YY') AND account_move_line.parent_state='posted' - group by internal_group,month - ''') - - record = self._cr.dictfetchall() - records = [] - for month in month_list: - this_month = list(filter(lambda r: r['month'].strip() == month, record)) - if not this_month: - records.append({ - 'month': month, - 'expense': 0.0 - }) - else: - records.append(this_month[0]) - labels = [item['month'] for item in records] - expense = [item['expense'] for item in records] - record = { - 'expense': expense, - 'label': labels - } - return record - - # function to getting expense of last year - - @api.model - def get_ex_last_year(self): - month_list = [] - for i in range(11, -1, -1): - l_month = datetime.now() - relativedelta(months=i) - text = format(l_month, '%B') - month_list.append(text) - - self._cr.execute(''' - - select sum(debit)-sum(credit) as expense,to_char(account_move_line.date, 'Month') as month , - internal_group from account_move_line , - account_account - where Extract(year FROM account_move_line.date) = Extract(year FROM DATE(NOW())) -1 AND - account_move_line.account_id=account_account.id AND internal_group = 'expense' - AND account_move_line.parent_state='posted' - group by month, internal_group - ''') - record = self._cr.dictfetchall() - records = [] - for month in month_list: - this_month = list(filter(lambda r: r['month'].strip() == month, record)) - if not this_month: - records.append({ - 'month': month, - 'expense': 0.0 - }) - else: - records.append(this_month[0]) - labels = [item['month'] for item in records] - expense = [item['expense'] for item in records] - record = { - 'expense': expense, - 'label': labels - } - return record - - # function to getting expense of this month - - @api.model - def get_ex_this_month(self): - - day_list = [] - now = datetime.now() - day = calendar.monthrange(now.year, now.month)[1] - for x in range(1, day + 1): - day_list.append(x) - self._cr.execute('''select sum(debit)-sum(credit) as expense ,cast(to_char(account_move_line.date, 'DD')as int) - as date , - internal_group from account_move_line , - account_account - where Extract(month FROM account_move_line.date) = Extract(month FROM DATE(NOW())) AND - Extract(year FROM account_move_line.date) = Extract(year FROM DATE(NOW())) AND - account_move_line.account_id=account_account.id AND internal_group='expense' - AND account_move_line.parent_state='posted' - group by internal_group,date - ''') - - record = self._cr.dictfetchall() - records = [] - for date in day_list: - last_month = list(filter(lambda m: m['date'] == date, record)) - if not last_month: - records.append({ - 'date': date, - 'expense': 0.0 - }) - else: - records.append(last_month[0]) - labels = [item['date'] for item in records] - series = [item['expense'] for item in records] - record = { - 'expense': series, - 'label': labels - } - return record - - # function to getting expense of last month - - @api.model - def get_ex_last_month(self): - day_list = [] - now = datetime.now() - day = \ - calendar.monthrange(now.year - 1 if now.month == 1 else now.year, - now.month - 1 if not now.month == 1 else 12)[ - 1] - for x in range(1, day + 1): - day_list.append(x) - - one_month_ago = (datetime.now() - relativedelta(months=1)).month - - self._cr.execute('''select sum(debit)-sum(credit) as expense ,cast(to_char(account_move_line.date, 'DD')as int) - as date , - internal_group from account_move_line , - account_account - where Extract(month FROM account_move_line.date) = ''' + str(one_month_ago) + ''' AND - account_move_line.account_id=account_account.id AND internal_group='expense' - AND account_move_line.parent_state='posted' - group by internal_group,date - ''') - record = self._cr.dictfetchall() - records = [] - for date in day_list: - last_month = list(filter(lambda m: m['date'] == date, record)) - if not last_month: - records.append({ - 'date': date, - 'expense': 0.0 - }) - else: - records.append(last_month[0]) - labels = [item['date'] for item in records] - series = [item['expense'] for item in records] - record = { - 'expense': series, - 'label': labels - } - return record - # function to getting income of this year @api.model @@ -642,44 +460,6 @@ class DashBoard(models.Model): # return record - @api.model - def get_latebills_last_month(self): - - # company_id = self.env.company.id - - one_month_ago = (datetime.now() - relativedelta(months=1)).month - - self._cr.execute(''' select to_char(account_move.date, 'Month') as month, res_partner.name as partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'in_invoice' - AND invoice_payment_state = 'not_paid' - AND state = 'posted' AND Extract(month FROM account_move.invoice_date_due) = ''' + str( - one_month_ago) + ''' - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - AND account_move.partner_id = res_partner.commercial_partner_id - group by parent, partner, month - order by amount desc ''') - - record = self._cr.dictfetchall() - return record - - @api.model - def get_latebills_last_year(self): - - # company_id = self.env.company.id - - self._cr.execute(''' select to_char(account_move.date, 'Month') as month, res_partner.name as partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'in_invoice' - AND invoice_payment_state = 'not_paid' - AND state = 'posted' AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - 1 - AND account_move.partner_id = res_partner.commercial_partner_id - group by parent, partner, month - order by amount desc ''') - - record = self._cr.dictfetchall() - return record - # function to getting over dues @api.model @@ -728,27 +508,40 @@ class DashBoard(models.Model): return records @api.model - def get_overdues_this_month(self, *post): + def get_overdues_this_month_and_year(self, *post): states_arg = "" - if post != ('posted',): + if post[0] != 'posted': states_arg = """ state in ('posted', 'draft')""" else: states_arg = """ state = 'posted'""" company_id = self.env.company.id - self._cr.execute((''' - select to_char(account_move.date, 'Month') as month, res_partner.name as due_partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND invoice_payment_state = 'not_paid' - AND %s - AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - AND account_move.partner_id = res_partner.commercial_partner_id - AND account_move.company_id = ''' + str(company_id) + ''' - group by parent, due_partner, month - order by amount desc ''') % (states_arg)) + if post[1] == 'this_month': + self._cr.execute((''' + select to_char(account_move.date, 'Month') as month, res_partner.name as due_partner, account_move.partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id + AND account_move.type = 'out_invoice' + AND invoice_payment_state = 'not_paid' + AND %s + AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) + AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) + AND account_move.partner_id = res_partner.commercial_partner_id + AND account_move.company_id = ''' + str(company_id) + ''' + group by parent, due_partner, month + order by amount desc ''') % (states_arg)) + else: + self._cr.execute((''' select res_partner.name as due_partner, account_move.partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id + AND account_move.type = 'out_invoice' + AND invoice_payment_state = 'not_paid' + AND %s + AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) + AND account_move.partner_id = res_partner.commercial_partner_id + AND account_move.company_id = ''' + str(company_id) + ''' + + group by parent, due_partner + order by amount desc ''') % (states_arg)) record = self._cr.dictfetchall() due_partner = [item['due_partner'] for item in record] @@ -772,30 +565,41 @@ class DashBoard(models.Model): return records @api.model - def get_latebills_this_month(self, *post): - + def get_latebillss(self, *post): company_id = self.env.company.id partners = self.env['res.partner'].search([('active', '=', True)]) states_arg = "" - if post != ('posted',): + if post[0] != 'posted': states_arg = """ state in ('posted', 'draft')""" else: states_arg = """ state = 'posted'""" - self._cr.execute((''' - select to_char(account_move.date, 'Month') as month, res_partner.name as bill_partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'in_invoice' - AND invoice_payment_state = 'not_paid' - AND %s - AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - AND account_move.company_id = ''' + str(company_id) + ''' - AND account_move.partner_id = res_partner.commercial_partner_id - group by parent, bill_partner, month - order by amount desc ''') % (states_arg)) + if post[1] == 'this_month': + self._cr.execute((''' + select to_char(account_move.date, 'Month') as month, res_partner.name as bill_partner, account_move.partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id + AND account_move.type = 'in_invoice' + AND invoice_payment_state = 'not_paid' + AND %s + AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) + AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) + AND account_move.company_id = ''' + str(company_id) + ''' + AND account_move.partner_id = res_partner.commercial_partner_id + group by parent, bill_partner, month + order by amount desc ''') % (states_arg)) + else: + self._cr.execute((''' select res_partner.name as bill_partner, account_move.partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id + AND account_move.type = 'in_invoice' + AND invoice_payment_state = 'not_paid' + AND %s + AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) + AND account_move.partner_id = res_partner.commercial_partner_id + AND account_move.company_id = ''' + str(company_id) + ''' + group by parent, bill_partner + order by amount desc ''') % (states_arg)) result = self._cr.dictfetchall() bill_partner = [item['bill_partner'] for item in result] @@ -820,167 +624,73 @@ class DashBoard(models.Model): return records @api.model - def get_overdues_last_month(self): - - # company_id = self.env.company.id - - one_month_ago = (datetime.now() - relativedelta(months=1)).month - - self._cr.execute(''' select to_char(account_move.date, 'Month') as month, res_partner.name as partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND invoice_payment_state = 'not_paid' - AND state = 'posted' AND Extract(month FROM account_move.invoice_date_due) = ''' + str( - one_month_ago) + ''' - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - AND account_move.partner_id = res_partner.commercial_partner_id - group by parent, partner, month - order by amount desc ''') - - record = self._cr.dictfetchall() - return record - - @api.model - def get_top_10_customers(self, *post): - + def get_top_10_customers_month(self, *post): + record_invoice = {} + record_refund = {} company_id = self.env.company.id states_arg = "" - if post != ('posted',): + if post[0] != 'posted': states_arg = """ state in ('posted', 'draft')""" else: states_arg = """ state = 'posted'""" - - - self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner - where account_move.commercial_partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND %s - group by parent, customers - order by amount desc - limit 10 - ''') % (states_arg)) - - record_invoice = self._cr.dictfetchall() - - self._cr.execute((''' select res_partner.commercial_company_name as customers, account_move.commercial_partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner - where account_move.commercial_partner_id = res_partner.id - AND account_move.type = 'out_refund' - AND %s - group by parent, customers - order by amount desc - limit 10 - ''') % (states_arg)) - - record_refund = self._cr.dictfetchall() - - summed = [] - for out_sum in record_invoice: - parent = out_sum['parent'] - su = out_sum['amount'] - \ - (list(filter(lambda refund: refund['parent'] == out_sum['parent'], record_refund))[0][ - 'amount'] if len( - list(filter(lambda refund: refund['parent'] == out_sum['parent'], record_refund))) > 0 else 0.0) - summed.append({ - 'customers': out_sum['customers'], - 'amount': su, - 'parent': parent - }) - - return summed - - @api.model - def get_top_10_customers_this_month(self, *post): - - company_id = self.env.company.id - - states_arg = "" - if post != ('posted',): - states_arg = """ state in ('posted', 'draft')""" + if post[1] == 'this_month': + self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner + where account_move.commercial_partner_id = res_partner.id + AND account_move.type = 'out_invoice' + AND %s + AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) + AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) + group by parent, customers + order by amount desc + limit 10 + ''') % (states_arg)) + + record_invoice = self._cr.dictfetchall() + + self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner + where account_move.commercial_partner_id = res_partner.id + AND account_move.type = 'out_refund' + AND %s + AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) + AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) + group by parent, customers + order by amount desc + limit 10 + ''') % (states_arg)) + + record_refund = self._cr.dictfetchall() else: - states_arg = """ state = 'posted'""" - - self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner - where account_move.commercial_partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND %s - AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - group by parent, customers - order by amount desc - limit 10 - ''') % (states_arg)) - - record_invoice = self._cr.dictfetchall() - - self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner - where account_move.commercial_partner_id = res_partner.id - AND account_move.type = 'out_refund' - AND %s - AND Extract(month FROM account_move.invoice_date_due) = Extract(month FROM DATE(NOW())) - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - group by parent, customers - order by amount desc - limit 10 - ''') % (states_arg)) - - record_refund = self._cr.dictfetchall() - - summed = [] - for out_sum in record_invoice: - parent = out_sum['parent'] - su = out_sum['amount'] - \ - (list(filter(lambda refund: refund['parent'] == out_sum['parent'], record_refund))[0][ - 'amount'] if len( - list(filter(lambda refund: refund['parent'] == out_sum['parent'], record_refund))) > 0 else 0.0) - summed.append({ - 'customers': out_sum['customers'], - 'amount': su, - 'parent': parent - }) - - return summed - - @api.model - def get_top_10_customers_last_month(self, *post): - - company_id = self.env.company.id - one_month_ago = (datetime.now() - relativedelta(months=1)).month - - if post != ('posted',): - states_arg = """ state in ('posted', 'draft')""" - else: - states_arg = """ state = 'posted'""" - - self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner - where account_move.commercial_partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND %s - AND Extract(month FROM account_move.invoice_date_due) = ''' + str(one_month_ago) + ''' - group by parent, customers - order by amount desc - limit 10 - ''') % (states_arg)) - - record_invoice = self._cr.dictfetchall() - - self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner - where account_move.commercial_partner_id = res_partner.id - AND account_move.type = 'out_refund' - AND %s - AND Extract(month FROM account_move.invoice_date_due) = ''' + str(one_month_ago) + ''' - group by parent, customers - order by amount desc - limit 10 - ''') % (states_arg)) - - record_refund = self._cr.dictfetchall() + one_month_ago = (datetime.now() - relativedelta(months=1)).month + self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner + where account_move.commercial_partner_id = res_partner.id + AND account_move.type = 'out_invoice' + AND %s + AND Extract(month FROM account_move.invoice_date_due) = ''' + str( + one_month_ago) + ''' + group by parent, customers + order by amount desc + limit 10 + ''') % (states_arg)) + + record_invoice = self._cr.dictfetchall() + + self._cr.execute((''' select res_partner.name as customers, account_move.commercial_partner_id as parent, + sum(account_move.amount_total) as amount from account_move, res_partner + where account_move.commercial_partner_id = res_partner.id + AND account_move.type = 'out_refund' + AND %s + AND Extract(month FROM account_move.invoice_date_due) = ''' + str( + one_month_ago) + ''' + group by parent, customers + order by amount desc + limit 10 + ''') % (states_arg)) + + record_refund = self._cr.dictfetchall() summed = [] for out_sum in record_invoice: @@ -997,112 +707,6 @@ class DashBoard(models.Model): return summed - @api.model - def get_overdues_this_year(self, *post): - - company_id = self.env.company.id - partners = self.env['res.partner'].search([('active', '=', True)]) - - states_arg = "" - if post != ('posted',): - states_arg = """ state in ('posted', 'draft')""" - else: - states_arg = """ state = 'posted'""" - - self._cr.execute((''' select res_partner.name as due_partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND invoice_payment_state = 'not_paid' - AND %s - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - AND account_move.partner_id = res_partner.commercial_partner_id - AND account_move.company_id = ''' + str(company_id) + ''' - - group by parent, due_partner - order by amount desc ''') % (states_arg)) - - record = self._cr.dictfetchall() - due_partner = [item['due_partner'] for item in record] - due_amount = [item['amount'] for item in record] - - amounts = sum(due_amount[9:]) - name = due_partner[9:] - result = [] - pre_partner = [] - - due_amount = due_amount[:9] - due_amount.append(amounts) - due_partner = due_partner[:9] - due_partner.append("Others") - records = { - 'due_partner': due_partner, - 'due_amount': due_amount, - 'result': result, - - } - return records - - @api.model - def get_latebills_this_year(self, *post): - - company_id = self.env.company.id - - states_arg = "" - if post != ('posted',): - states_arg = """ state in ('posted', 'draft')""" - else: - states_arg = """ state = 'posted'""" - - self._cr.execute((''' select res_partner.name as bill_partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'in_invoice' - AND invoice_payment_state = 'not_paid' - AND %s - AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - AND account_move.partner_id = res_partner.commercial_partner_id - AND account_move.company_id = ''' + str(company_id) + ''' - group by parent, bill_partner - order by amount desc ''') % (states_arg)) - - result = self._cr.dictfetchall() - - bill_partner = [item['bill_partner'] for item in result] - - bill_amount = [item['amount'] for item in result] - amounts = sum(bill_amount[9:]) - name = bill_partner[9:] - results = [] - pre_partner = [] - - bill_amount = bill_amount[:9] - bill_amount.append(amounts) - bill_partner = bill_partner[:9] - bill_partner.append("Others") - records = { - 'bill_partner': bill_partner, - 'bill_amount': bill_amount, - 'result': results, - - } - return records - - @api.model - def get_overdues_last_year(self): - - # company_id = self.env.company.id - - self._cr.execute(''' select to_char(account_move.date, 'Month') as month, res_partner.name as partner, account_move.partner_id as parent, - sum(account_move.amount_total) as amount from account_move, res_partner where account_move.partner_id = res_partner.id - AND account_move.type = 'out_invoice' - AND invoice_payment_state = 'not_paid' - AND state = 'posted' AND Extract(YEAR FROM account_move.invoice_date_due) = Extract(YEAR FROM DATE(NOW())) - 1 - AND account_move.partner_id = res_partner.commercial_partner_id - group by parent, partner, month - order by amount desc ''') - - record = self._cr.dictfetchall() - return record - # function to get total invoice @api.model @@ -1168,7 +772,6 @@ class DashBoard(models.Model): ''') % (states_arg)) record_supplier_current_year = self._cr.dictfetchall() - self._cr.execute(('''select sum(-(amount_total_signed)) - sum(-(amount_residual_signed)) as credit_note from account_move where type ='out_refund' AND %s AND Extract(YEAR FROM account_move.date) = Extract(YEAR FROM DATE(NOW())) @@ -1176,7 +779,6 @@ class DashBoard(models.Model): ''') % (states_arg)) result_credit_note_current_year = self._cr.dictfetchall() - self._cr.execute(('''select sum(-(amount_total_signed)) as refund from account_move where type ='in_refund' AND %s AND Extract(YEAR FROM account_move.date) = Extract(YEAR FROM DATE(NOW())) @@ -1184,8 +786,6 @@ class DashBoard(models.Model): ''') % (states_arg)) result_refund_current_year = self._cr.dictfetchall() - - self._cr.execute(('''select sum(amount_total_signed) - sum(amount_residual_signed) as customer_invoice_paid from account_move where type ='out_invoice' AND %s AND invoice_payment_state = 'paid' @@ -1194,9 +794,6 @@ class DashBoard(models.Model): ''') % (states_arg)) record_paid_customer_invoice_current_year = self._cr.dictfetchall() - - - self._cr.execute(('''select sum(-(amount_total_signed)) - sum(-(amount_residual_signed)) as supplier_invoice_paid from account_move where type ='in_invoice' AND %s AND invoice_payment_state = 'paid' @@ -1205,8 +802,6 @@ class DashBoard(models.Model): ''') % (states_arg)) result_paid_supplier_invoice_current_year = self._cr.dictfetchall() - - self._cr.execute(('''select sum(-(amount_total_signed)) - sum(-(amount_residual_signed)) as customer_credit_paid from account_move where type ='out_refund' AND %s AND invoice_payment_state = 'paid' @@ -1215,8 +810,6 @@ class DashBoard(models.Model): ''') % (states_arg)) record_paid_customer_credit_current_year = self._cr.dictfetchall() - - self._cr.execute(('''select sum(amount_total_signed) - sum(amount_residual_signed) as supplier_refund_paid from account_move where type ='in_refund' AND %s AND invoice_payment_state = 'paid' @@ -1225,23 +818,23 @@ class DashBoard(models.Model): ''') % (states_arg)) result_paid_supplier_refund_current_year = self._cr.dictfetchall() - - customer_invoice_current_year = [item['customer_invoice'] for item in record_customer_current_year] supplier_invoice_current_year = [item['supplier_invoice'] for item in record_supplier_current_year] credit_note_current_year = [item['credit_note'] for item in result_credit_note_current_year] refund_current_year = [item['refund'] for item in result_refund_current_year] - paid_customer_invoice_current_year = [item['customer_invoice_paid'] for item in record_paid_customer_invoice_current_year] - paid_supplier_invoice_current_year = [item['supplier_invoice_paid'] for item in result_paid_supplier_invoice_current_year] + paid_customer_invoice_current_year = [item['customer_invoice_paid'] for item in + record_paid_customer_invoice_current_year] + paid_supplier_invoice_current_year = [item['supplier_invoice_paid'] for item in + result_paid_supplier_invoice_current_year] - paid_customer_credit_current_year = [item['customer_credit_paid'] for item in record_paid_customer_credit_current_year] - paid_supplier_refund_current_year = [item['supplier_refund_paid'] for item in result_paid_supplier_refund_current_year] + paid_customer_credit_current_year = [item['customer_credit_paid'] for item in + record_paid_customer_credit_current_year] + paid_supplier_refund_current_year = [item['supplier_refund_paid'] for item in + result_paid_supplier_refund_current_year] - - - return customer_invoice_current_year, credit_note_current_year, supplier_invoice_current_year, refund_current_year, paid_customer_invoice_current_year,paid_supplier_invoice_current_year, paid_customer_credit_current_year, paid_supplier_refund_current_year + return customer_invoice_current_year, credit_note_current_year, supplier_invoice_current_year, refund_current_year, paid_customer_invoice_current_year, paid_supplier_invoice_current_year, paid_customer_credit_current_year, paid_supplier_refund_current_year @api.model def get_total_invoice_current_month(self, *post): @@ -1324,11 +917,15 @@ class DashBoard(models.Model): supplier_invoice_current_month = [item['supplier_invoice'] for item in record_supplier_current_month] credit_note_current_month = [item['credit_note'] for item in result_credit_note_current_month] refund_current_month = [item['refund'] for item in result_refund_current_month] - paid_customer_invoice_current_month = [item['customer_invoice_paid'] for item in record_paid_customer_invoice_current_month] - paid_supplier_invoice_current_month = [item['supplier_invoice_paid'] for item in result_paid_supplier_invoice_current_month] + paid_customer_invoice_current_month = [item['customer_invoice_paid'] for item in + record_paid_customer_invoice_current_month] + paid_supplier_invoice_current_month = [item['supplier_invoice_paid'] for item in + result_paid_supplier_invoice_current_month] - paid_customer_credit_current_month = [item['customer_credit_paid'] for item in record_paid_customer_credit_current_month] - paid_supplier_refund_current_month = [item['supplier_refund_paid'] for item in result_paid_supplier_refund_current_month] + paid_customer_credit_current_month = [item['customer_credit_paid'] for item in + record_paid_customer_credit_current_month] + paid_supplier_refund_current_month = [item['supplier_refund_paid'] for item in + result_paid_supplier_refund_current_month] return customer_invoice_current_month, credit_note_current_month, supplier_invoice_current_month, refund_current_month, paid_customer_invoice_current_month, paid_supplier_invoice_current_month, paid_customer_credit_current_month, paid_supplier_refund_current_month @@ -1422,11 +1019,10 @@ class DashBoard(models.Model): Extract(YEAR FROM l.date) = Extract(YEAR FROM DATE(NOW())) AND L.account_id=a.id AND l.full_reconcile_id IS NULL AND l.balance != 0 AND a.reconcile IS F - AND l.'''+states_arg+''' + AND l.''' + states_arg + ''' AND l.company_id = ''' + str(company_id) + ''' ''' - self._cr.execute((''' select count(*) FROM account_move_line l,account_account a where Extract(month FROM l.date) = Extract(month FROM DATE(NOW())) AND Extract(YEAR FROM l.date) = Extract(YEAR FROM DATE(NOW())) AND @@ -1438,7 +1034,6 @@ class DashBoard(models.Model): record = self._cr.dictfetchall() return record - # function to get unreconcile items last month @api.model @@ -1547,7 +1142,7 @@ class DashBoard(models.Model): AND Extract(year FROM account_move_line.date) = Extract(year FROM DATE(NOW())) AND account_move_line.company_id = ''' + str(company_id) + ''' group by internal_group - ''') %(states_arg)) + ''') % (states_arg)) income = self._cr.dictfetchall() profit = [item['profit'] for item in income] internal_group = [item['internal_group'] for item in income] @@ -1583,44 +1178,7 @@ class DashBoard(models.Model): AND Extract(year FROM account_move_line.date) = Extract(year FROM DATE(NOW())) AND account_move_line.company_id = ''' + str(company_id) + ''' group by internal_group - ''') %(states_arg)) - income = self._cr.dictfetchall() - profit = [item['profit'] for item in income] - internal_group = [item['internal_group'] for item in income] - net_profit = True - loss = True - - if profit and profit == 0: - if (-profit[1]) > (profit[0]): - net_profit = -profit[1] - profit[0] - elif (profit[1]) > (profit[0]): - net_profit = -profit[1] - profit[0] - else: - net_profit = -profit[1] - profit[0] - - return profit - - @api.model - def profit_income_last_year(self, *post): - - company_id = self.env.company.id - - states_arg = "" - if post != ('posted',): - states_arg = """ parent_state in ('posted', 'draft')""" - else: - states_arg = """ parent_state = 'posted'""" - - self._cr.execute('''select sum(debit) - sum(credit) as profit, account_account.internal_group from account_account, account_move_line where - - account_move_line.account_id = account_account.id AND - %s AND - (account_account.internal_group = 'income' or - account_account.internal_group = 'expense' ) - AND Extract(year FROM account_move_line.date) = Extract(year FROM DATE(NOW())) - 1 - AND account_move_line.company_id = ''' + str(company_id) + ''' - group by internal_group - ''') + ''') % (states_arg)) income = self._cr.dictfetchall() profit = [item['profit'] for item in income] internal_group = [item['internal_group'] for item in income] @@ -1735,12 +1293,10 @@ class DashBoard(models.Model): AND account_move_line.company_id = ''' + str(company_id) + ''' - ''') %(states_arg)) + ''') % (states_arg)) record = self._cr.dictfetchall() return record - - # function to get total expense this year @api.model @@ -1748,7 +1304,6 @@ class DashBoard(models.Model): company_id = self.env.company.id - states_arg = "" if post != ('posted',): states_arg = """ parent_state in ('posted', 'draft')""" @@ -1801,6 +1356,3 @@ class DashBoard(models.Model): } return records - - - diff --git a/base_accounting_kit/static/description/banner.gif b/base_accounting_kit/static/description/banner.gif index cc886f8f4..ff9d0e7af 100644 Binary files a/base_accounting_kit/static/description/banner.gif and b/base_accounting_kit/static/description/banner.gif differ diff --git a/base_accounting_kit/static/description/banner2.gif b/base_accounting_kit/static/description/banner2.gif new file mode 100644 index 000000000..cc886f8f4 Binary files /dev/null and b/base_accounting_kit/static/description/banner2.gif differ diff --git a/base_accounting_kit/static/src/js/account_dashboard.js b/base_accounting_kit/static/src/js/account_dashboard.js index ad1995804..e58b65076 100644 --- a/base_accounting_kit/static/src/js/account_dashboard.js +++ b/base_accounting_kit/static/src/js/account_dashboard.js @@ -17,59 +17,56 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { events: { 'click .invoice_dashboard': 'onclick_dashboard', - - 'click #invoice_hide': 'onclick_invoice_hide', - 'click #income_hide': 'onclick_income_hide', - 'click #ex_hide': 'onclick_ex_hide', - 'click #due_hide': 'onclick_due_hide', - 'click #top_10_hide': 'onclick_top_10_hide', - 'click #late_hide': 'onclick_late_hide', 'click #prog_bar': 'onclick_prog_bar', - 'click #invoice_this_month': 'onclick_invoice_this_month', 'click #invoice_this_year': 'onclick_invoice_this_year', 'click #invoice_last_month': 'onclick_invoice_last_month', 'click #invoice_last_year': 'onclick_invoice_last_year', - 'click #onclick_banks_balance': 'onclick_bank_balance', - 'click #income_this_month': 'onclick_income_this_month', 'click #income_this_year': 'onclick_income_this_year', 'click #income_last_month': 'onclick_income_last_month', 'click #income_last_year': 'onclick_income_last_year', - - 'click #aged_payable_this_month': 'onclick_aged_payable_this_month', - 'click #aged_receivable_this_year': 'onclick_aged_receivable_this_year', 'click #total_aged_payable': 'onclick_total_aged_payable', - 'click #aged_payable_this_year': 'onclick_aged_payable_this_year', - 'click #in_ex_bar_chart': 'onclick_in_ex_bar_chart', 'click #aged_recevable_pie_chart': 'onclick_aged_recevable_pie_chart', 'click #invoice_bar_chart': 'onclick_invoice_bar_chart', 'click .overdue_line_cust': 'onclick_overdue_line_cust', 'click .top_customers': 'onclick_top_customers', 'click .top_customers_amount': 'onclick_top_customers_amount', - 'click #aged_receivable_this_month': 'onclick_aged_receivable_this_month', - 'click #bank_balance_hide': 'onclick_bank_balance_hide', 'click #cash_balance_hide': 'onclick_cash_balance_hide', 'click #in_ex_hide': 'onclick_in_ex_hide', 'click #aged_payable_hide': 'onclick_aged_payable_hide', - 'click #top_10_customer_this_month': 'onclick_top_10_customer_this_month', - 'click #top_10_customer_last_month': 'onclick_top_10_customer_last_month', - + 'change #aged_receivable_values': function(e) { + e.stopPropagation(); + var $target = $(e.target); + var value = $target.val(); +// this.$('.aged_receivable_this_month').empty(); + this.onclick_aged_payable(this.$('#aged_receivable_values').val()); + }, + 'change #aged_payable_value': function(e) { + e.stopPropagation(); + var $target = $(e.target); + var value = $target.val(); + this.$('.aged_receivable_this_month').empty(); + this.onclick_aged_receivable(this.$('#aged_payable_value').val()); + }, + 'change #top_10_customer_value': function(e) { + e.stopPropagation(); + var $target = $(e.target); + var value = $target.val(); + this.$('.top_10_customers_this_month').empty(); + this.onclick_top_10_month(this.$('#top_10_customer_value').val()); + }, 'change #toggle-two': 'onclick_toggle_two', }, onclick_toggle_two: function (ev) { + this.onclick_aged_payable(this.$('#aged_receivable_values').val()); - this.onclick_aged_payable_this_month(ev); - this.onclick_aged_payable_this_year(ev); - - this.onclick_aged_receivable_this_month(ev); - this.onclick_aged_receivable_this_year(ev); - + this.onclick_aged_receivable(this.$('#aged_payable_value').val()); this.onclick_invoice_this_year(ev); this.onclick_invoice_this_month(ev); @@ -79,285 +76,22 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { this.onclick_income_this_year(ev); }, - onclick_overdue_line_cust: function (ev) { - ev.preventDefault(); - var data = $(ev.currentTarget).data(); - this.do_action({ - type: 'ir.actions.act_window', - res_model: 'res.partner', - res_id: data['userId'], - view_mode: 'form', - views: [ - [false, 'form'] - ], - }) - }, - - onclick_top_customers: function (ev) { - ev.stopPropagation(); - ev.preventDefault(); - var data = $(ev.currentTarget).data(); - this.do_action({ - type: 'ir.actions.act_window', - res_model: 'res.partner', - res_id: data['userId'], - view_mode: 'tree,form', - target: 'current', - views: [ - [false, 'tree'], - [false, 'form'] - ], - context: { - create: false, - edit: false, - } - }) - }, - - onclick_top_customers_amount: function (ev) { - ev.preventDefault(); - var data = $(ev.currentTarget).data(); - this.do_action({ - type: 'ir.actions.act_window', - res_model: 'account.move', - res_id: data['userId'], - view_mode: 'list', - - views: [ - [false, 'list'] - ], - name: 'Invoices', - domain: ['|', - ['type', '=', 'out_invoice'], - ['type', '=', 'out_refund'], - ['state', '=', 'posted'], - ['partner_id', 'child_of', data['userId'],] - ], - context: { - default_type: 'out_invoice', - type: 'out_invoice', - journal_type: 'sale', - create: false, - search_default_unpaid: 1, - } - - }) - }, - - onclick_prog_bar: function (ev) { - this.do_action({ - type: 'ir.actions.act_window', - res_model: 'account.move', - view_mode: 'tree,form', - views: [ - [false, 'list'], - [false, 'form'] - ], - name: 'Unpaid Invoices', - - domain: [ - ['state', '=', 'posted'], - ['type', '=', 'out_invoice'], - ['invoice_payment_state', '=', 'not_paid'] - ] - }); - }, - onclick_unreconciled_items: function (ev) { - this.do_action({ - type: 'ir.actions.act_window', - res_model: 'account.move.line', - view_mode: 'tree,form', - target: 'new', - views: [ - [false, 'list'], - [false, 'form'] - ], - name: 'Unreconciled Payments', - - domain: [ - ['full_reconcile_id', '=', false], - ['balance', '!=', 0], - ['account_id.reconcile', '=', true] - ] - }); - }, - - onclick_unreconcile_items_this_years: function (ev) { - - this.do_action({ - type: 'ir.actions.act_window', - res_model: 'account.move.line', - view_mode: 'tree,form', - target: 'new', - views: [ - [false, 'list'], - [false, 'form'] - ], - name: 'Unreconciled Payments', - - domain: [ - ['full_reconcile_id', '=', false], - ['balance', '!=', 0], - ['account_id.reconcile', '=', true] - ] - }); - }, - - onclick_unreconcile_items_this_month: function (ev) { - ev.preventDefault(); - var selected = $('.btn.btn-tool.selected'); - var data = $(selected[0]).data(); - - $('#monthly_expense').show() - $('#monthly_invoice').show() - $('#monthly_income').show() - $('#monthly_unreconciled').show() - - - $('#yearly_expense').hide() - $('#yearly_income').hide() - $('#yearly_invoice').hide() - $('#yearly_unreconciled').hide() - }, - - onclick_income_hide: function () { - var x = document.getElementById("income_body"); - if (x.style.display === "none") { - - x.style.display = "block"; - } else { - x.style.display = "none"; - } - }, - onclick_ex_hide: function () { - var x = document.getElementById("ex_body"); - if (x.style.display === "none") { - x.style.display = "block"; - } else { - x.style.display = "none"; - } - }, - onclick_due_hide: function () { - var x = document.getElementById("due_body"); - - if (x.style.display === "none") { - x.style.display = "block"; - - - } else { - x.style.display = "none"; - - - } - }, - - onclick_top_10_hide: function () { - var x = document.getElementById("top_10_body"); - - if (x.style.display === "none") { - x.style.display = "block"; - - - } else { - x.style.display = "none"; - - - } - }, - - onclick_bank_balance_hide: function () { - var x = document.getElementById("bank_balance_body_hide"); - - if (x.style.display === "none") { - x.style.display = "block"; - - - } else { - x.style.display = "none"; - - - } - }, - onclick_in_ex_hide: function () { - var x = document.getElementById("in_ex_body_hide"); - - if (x.style.display === "none") { - x.style.display = "block"; - - - } else { - x.style.display = "none"; - - - } - }, - - onclick_aged_payable_hide: function () { - var x = document.getElementById("aged_payable_body_hide"); - - if (x.style.display === "none") { - x.style.display = "block"; - - - } else { - x.style.display = "none"; - - - } - }, - - onclick_cash_balance_hide: function () { - var x = document.getElementById("cash_balance_body_hide"); - - if (x.style.display === "none") { - x.style.display = "block"; - - - } else { - x.style.display = "none"; - - - } - }, - - onclick_late_hide: function () { - - - var x = document.getElementById("late_body"); - if (x.style.display === "none") { - x.style.display = "block"; - } else { - x.style.display = "none"; - } - }, - - onclick_invoice_hide: function () { - var x = document.getElementById("invoice_body"); - if (x.style.display === "none") { - x.style.display = "block"; - } else { - x.style.display = "none"; - } - - }, - - onclick_top_10_customer_this_month: function (ev) { - ev.preventDefault(); + onclick_top_10_month: function (f) { var selected = $('.btn.btn-tool.income'); var data = $(selected[0]).data(); var posted = false; + var f = f; if ($('#toggle-two')[0].checked == true) { posted = "posted" } rpc.query({ model: "account.move", - method: "get_top_10_customers_this_month", - args: [posted] + method: "get_top_10_customers_month", + args: [posted,f] }) .then(function (result) { - $('#top_10_customers').hide(); $('#top_10_customers_last_month').hide(); $('#top_10_customers_this_month').show(); @@ -372,32 +106,6 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { }) }, - onclick_top_10_customer_last_month: function (ev) { - ev.preventDefault(); - var selected = $('.btn.btn-tool.income'); - var data = $(selected[0]).data(); - var posted = false; - if ($('#toggle-two')[0].checked == true) { - posted = "posted" - } - rpc.query({ - model: "account.move", - method: "get_top_10_customers_last_month", - args: [posted] - }) - .then(function (result) { - $('#top_10_customers').hide(); - $('#top_10_customers_this_month').hide(); - $('#top_10_customers_last_month').show(); - $('#top_10_customers_last_month').empty(); - var due_count = 0; - _.forEach(result, function (x) { - due_count++; - $('#top_10_customers_last_month').append('
  • ' + x.customers + '
    ' + '
    ' + x.amount.toFixed(2) + ' ' + currency + '
    ' + '
  • '); - }); - }) - }, - onclick_income_last_year: function (ev) { ev.preventDefault(); var selected = $('.btn.btn-tool.income'); @@ -635,28 +343,6 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { }) }, - onclick_bank_balance: function (ev) { - ev.preventDefault(); - var selected = $('.btn.btn-tool.selected'); - var data = $(selected[0]).data(); - var self = this; - - rpc.query({ - model: "account.move", - method: "bank_balance", - }) - .then(function (result) { - - var banks = result['banks']; - var balance = result['banking']; - - - $('.bank_repeat').remove(); - $('#charts').append('
    ' + banks + '        ' + '' + balance.toFixed(2) + '' + '
    '); - - - }) - }, onclick_invoice_this_year: function (ev) { @@ -747,30 +433,30 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { }) .then(function (result) { - $('#total_supplier_invoice_paid').hide(); - $('#total_supplier_invoice').hide(); - $('#total_customer_invoice_paid').hide(); - $('#total_customer_invoice').hide(); - $('#tot_invoice').hide(); - $('#tot_supplier_inv').hide(); - $('#total_supplier_invoice_paid_current_month').empty(); - $('#total_supplier_invoice_current_month').empty(); - $('#total_customer_invoice_paid_current_month').empty(); - $('#total_customer_invoice_current_month').empty(); - $('#tot_invoice_current_month').empty(); - $('#tot_supplier_inv_current_month').empty(); - $('#total_supplier_invoice_paid_current_year').hide(); - $('#total_supplier_invoice_current_year').hide(); - $('#total_customer_invoice_paid_current_year').hide(); - $('#total_customer_invoice_current_year').hide(); - $('#tot_invoice_current_year').hide(); - $('#tot_supplier_inv_current_year').hide(); - $('#total_supplier_invoice_paid_current_month').show(); - $('#total_supplier_invoice_current_month').show(); - $('#total_customer_invoice_paid_current_month').show(); - $('#total_customer_invoice_current_month').show(); - $('#tot_invoice_current_month').show(); - $('#tot_supplier_inv_current_month').show(); +// $('#total_supplier_invoice_paid').hide(); +// $('#total_supplier_invoice').hide(); +// $('#total_customer_invoice_paid').hide(); +// $('#total_customer_invoice').hide(); +// $('#tot_invoice').hide(); +// $('#tot_supplier_inv').hide(); +// $('#total_supplier_invoice_paid_current_month').empty(); +// $('#total_supplier_invoice_current_month').empty(); +// $('#total_customer_invoice_paid_current_month').empty(); +// $('#total_customer_invoice_current_month').empty(); +// $('#tot_invoice_current_month').empty(); +// $('#tot_supplier_inv_current_month').empty(); +// $('#total_supplier_invoice_paid_current_year').hide(); +// $('#total_supplier_invoice_current_year').hide(); +// $('#total_customer_invoice_paid_current_year').hide(); +// $('#total_customer_invoice_current_year').hide(); +// $('#tot_invoice_current_year').hide(); +// $('#tot_supplier_inv_current_year').hide(); +// $('#total_supplier_invoice_paid_current_month').show(); +// $('#total_supplier_invoice_current_month').show(); +// $('#total_customer_invoice_paid_current_month').show(); +// $('#total_customer_invoice_current_month').show(); +// $('#tot_invoice_current_month').show(); +// $('#tot_supplier_inv_current_month').show(); var tot_invoice_current_month = result[0][0] var tot_credit_current_month = result[1][0] var tot_supplier_inv_current_month = result[2][0] @@ -877,153 +563,10 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { }) }, - onclick_aged_recevable_pie_chart: function () { - - document.getElementById("aged_recevable_pie_chart").style.color = "gray"; - - $('#aged_recevable_pie_chart').addClass("expense"); - - rpc.query({ - model: "account.move", - method: "get_latebills", - }) - .then(function (result) { - - $(document).ready(function () { - var options = { - // legend: false, - responsive: true, - legend: { - position: 'bottom' - } - }; - - if (window.donuts != undefined) - window.donuts.destroy(); + onclick_aged_payable: function (f) { - window.donuts = new Chart($("#horizontalbarChart"), { - type: 'doughnut', - tooltipFillColor: "rgba(51, 51, 51, 0.55)", - data: { - labels: result.bill_partner, - datasets: [{ - data: result.bill_amount, - backgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ], - hoverBackgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ] - }] - }, - options: { - responsive: false - } - }); - }); - - - }) - }, - onclick_in_ex_bar_chart: function (ev) { - document.getElementById("in_ex_bar_chart").style.color = "gray"; - $('#in_ex_bar_chart').addClass("expense"); - var posted = false; - if ($('#toggle-two')[0].checked == true) { - posted = "posted" - } - - rpc.query({ - model: "account.move", - method: "get_income_this_year", - args: [posted], - }) - .then(function (result) { - - - var ctx = document.getElementById("canvas").getContext('2d'); - - $('#net_profit_this_months').hide(); - $('#net_profit_last_month').hide(); - $('#net_profit_last_year').hide(); - $('#net_profit_this_year').show(); - // Define the data - var income = result.income; // Add data values to array - var expense = result.expense; - var profit = result.profit; - - var labels = result.month; // Add labels to array - // End Defining data - - // End Defining data - if (window.myCharts != undefined) - window.myCharts.destroy(); - window.myCharts = new Chart(ctx, { - //var myChart = new Chart(ctx, { - type: 'bar', - data: { - labels: labels, - datasets: [{ - label: 'Income', // Name the series - data: income, // Specify the data values array - backgroundColor: '#66aecf', - borderColor: '#66aecf', - - borderWidth: 1, // Specify bar border width - type: 'bar', // Set this data to a line chart - fill: false - }, - { - label: 'Expense', // Name the series - data: expense, // Specify the data values array - backgroundColor: '#6993d6', - borderColor: '#6993d6', - - borderWidth: 1, // Specify bar border width - type: 'bar', // Set this data to a line chart - fill: false - }, - { - label: 'Profit/Loss', // Name the series - data: profit, // Specify the data values array - backgroundColor: '#0bd465', - borderColor: '#0bd465', - - borderWidth: 1, // Specify bar border width - type: 'line', // Set this data to a line chart - fill: false - } - ] - }, - options: { - responsive: true, // Instruct chart js to respond nicely. - maintainAspectRatio: false, // Add to prevent default behaviour of full-width/height - } - }); - - - }) - }, - onclick_aged_payable_this_month: function (ev) { - ev.preventDefault(); +// ev.preventDefault(); + var arg = f; var selected = $('.btn.btn-tool.expense'); var data = $(selected[0]).data(); var posted = false; @@ -1032,8 +575,8 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { } rpc.query({ model: 'account.move', - method: 'get_overdues_this_month', - args: [posted], + method: 'get_overdues_this_month_and_year', + args: [posted,f], }) .then(function (result) { @@ -1089,218 +632,20 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { }) }, - onclick_total_aged_payable: function (ev) { - ev.preventDefault(); - var selected = $('.btn.btn-tool.expense'); - var data = $(selected[0]).data(); - - rpc.query({ - model: 'account.move', - method: 'get_overdues', - }) - .then(function (result) { - // Doughnut Chart - $(document).ready(function () { - var options = { - // legend: false, - responsive: false - }; - - - if (window.donut != undefined) - window.donut.destroy(); - - - window.donut = new Chart($("#canvas1"), { - type: 'doughnut', - tooltipFillColor: "rgba(51, 51, 51, 0.55)", - data: { - labels: result.due_partner, - datasets: [{ - data: result.due_amount, - backgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ], - hoverBackgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ] - }] - }, - options: { - responsive: false - } - }); - }); - }) - - }, - onclick_aged_payable_this_year: function (ev) { - ev.preventDefault(); - var selected = $('.btn.btn-tool.expense'); - var data = $(selected[0]).data(); - var posted = false; - if ($('#toggle-two')[0].checked == true) { - posted = "posted" - } - rpc.query({ - model: 'account.move', - method: 'get_overdues_this_year', - args: [posted], - }) - .then(function (result) { - // Doughnut Chart - $(document).ready(function () { - var options = { - // legend: false, - responsive: false - }; - if (window.donut != undefined) - window.donut.destroy(); - - - window.donut = new Chart($("#canvas1"), { - type: 'doughnut', - tooltipFillColor: "rgba(51, 51, 51, 0.55)", - data: { - labels: result.due_partner, - datasets: [{ - data: result.due_amount, - backgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ], - hoverBackgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ] - }] - }, - options: { - responsive: false - } - }); - }); - // Doughnut Chart - }) - }, - onclick_aged_receivable_this_year: function (ev) { - ev.preventDefault(); - var selected = $('.btn.btn-tool.expense'); - var data = $(selected[0]).data(); - var posted = false; - if ($('#toggle-two')[0].checked == true) { - posted = "posted" - } - rpc.query({ - model: 'account.move', - method: 'get_latebills_this_year', - args: [posted], - }) - .then(function (result) { - $(document).ready(function () { - var options = { - // legend: false, - responsive: true, - legend: { - position: 'bottom' - } - }; - - - if (window.donuts != undefined) - window.donuts.destroy(); - - window.donuts = new Chart($("#horizontalbarChart"), { - type: 'doughnut', - tooltipFillColor: "rgba(51, 51, 51, 0.55)", - data: { - labels: result.bill_partner, - datasets: [{ - data: result.bill_amount, - backgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ], - hoverBackgroundColor: [ - '#66aecf ', '#6993d6 ', '#666fcf', '#7c66cf', '#9c66cf', - '#bc66cf ', '#b75fcc', ' #cb5fbf ', ' #cc5f7f ', ' #cc6260', - '#cc815f', '#cca15f ', '#ccc25f', '#b9cf66', '#99cf66', - ' #75cb5f ', '#60cc6c', '#804D8000', '#80B33300', '#80CC80CC', '#f2552c', '#00cccc', - '#1f2e2e', '#993333', '#00cca3', '#1a1a00', '#3399ff', - '#8066664D', '#80991AFF', '#808E666FF', '#804DB3FF', '#801AB399', - '#80E666B3', '#8033991A', '#80CC9999', '#80B3B31A', '#8000E680', - '#804D8066', '#80809980', '#80E6FF80', '#801AFF33', '#80999933', - '#80FF3380', '#80CCCC00', '#8066E64D', '#804D80CC', '#809900B3', - '#80E64D66', '#804DB380', '#80FF4D4D', '#8099E6E6', '#806666FF' - ] - }] - }, - options: { - responsive: false - } - }); - }); - - - }) - }, - - onclick_aged_receivable_this_month: function (ev) { - ev.preventDefault(); + onclick_aged_receivable: function (f) { var selected = $('.btn.btn-tool.expense'); var data = $(selected[0]).data(); var posted = false; + var f = f if ($('#toggle-two')[0].checked == true) { posted = "posted" } rpc.query({ model: 'account.move', - method: 'get_latebills_this_month', - args: [posted], + method: 'get_latebillss', + args: [posted, f], }) .then(function (result) { @@ -1457,19 +802,20 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { }); }) - + var arg = 'this_month'; rpc.query({ model: 'account.move', - method: 'get_overdues_this_month', - args: [posted], + method: 'get_overdues_this_month_and_year', + args: [posted,arg], }).then(function (result) { // }) + var arg = 'this_month'; rpc.query({ model: 'account.move', - method: 'get_overdues_this_month', - args: [posted], + method: 'get_overdues_this_month_and_year', + args: [posted,arg], }) .then(function (result) { // Doughnut Chart @@ -1586,10 +932,11 @@ odoo.define('AccountingDashboard.AccountingDashboard', function (require) { $('#total_supplier_invoice_current_month').append('