This question has been flagged
2 Replies
2982 Views

I want to change the profit and loss query in openerp. Because i am planing to get the business units profit and loss report. I am tracing the each transaction using analytic account. The basic profit and loss not giving the reports based on analytic account. we are planing to get those. I have tried allot to find the profit and loss query. In my point of view what my final job is to add one more condition to profit and loss query, which filters the result based on Analytic account. Can any one tell me where i have to add this condition?

I am trying like this... I have activated "developer mode". The name of "print" button in profit and loss scren is "check_report" I have find this function in the file path is addons/accounts/wizard/account_financial_report.py The model of profit and loss is "accounting.report" inherited from "account.common.report". Can any one explain these two functions,

*************************************************************************************************************

def _build_comparison_context(self, cr, uid, ids, data, context=None):
        if context is None:
            context = {}
        result = {}
        result['fiscalyear'] = 'fiscalyear_id_cmp' in data['form'] and data['form']['fiscalyear_id_cmp'] or False
        result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False
        result['chart_account_id'] = 'chart_account_id' in data['form'] and data['form']['chart_account_id'] or False
        result['state'] = 'target_move' in data['form'] and data['form']['target_move'] or ''
        if data['form']['filter_cmp'] == 'filter_date':
            result['date_from'] = data['form']['date_from_cmp']
            result['date_to'] = data['form']['date_to_cmp']
        elif data['form']['filter_cmp'] == 'filter_period':
            if not data['form']['period_from_cmp'] or not data['form']['period_to_cmp']:
                raise osv.except_osv(_('Error!'),_('Select a starting and an ending period'))
            result['period_from'] = data['form']['period_from_cmp']
            result['period_to'] = data['form']['period_to_cmp']
        return result

  ***************************************************************************************************************

  def check_report(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        res = super(accounting_report, self).check_report(cr, uid, ids, context=context)
        data = {}
        data['form'] = self.read(cr, uid, ids, ['account_report_id', 'date_from_cmp',  'date_to_cmp',  'fiscalyear_id_cmp', 'journal_ids', 'period_from_cmp', 'period_to_cmp',  'filter_cmp',  'chart_account_id', 'target_move'], context=context)[0]
        for field in ['fiscalyear_id_cmp', 'chart_account_id', 'period_from_cmp', 'period_to_cmp', 'account_report_id']:
            if isinstance(data['form'][field], tuple):
                data['form'][field] = data['form'][field][0]
        comparison_context = self._build_comparison_context(cr, uid, ids, data, context=context)
        res['datas']['form']['comparison_context'] = comparison_context
        return res

******************************************************************************************************************

As per my knowledge these two functions for get the wizard data perfectly to res variable. How the profit and loss report come out?  Where is the query to get that report?.

Avatar
Discard

Don't ask the same question again... https://www.odoo.com/forum/help-1/question/how-can-i-change-profit-and-loss-report-query-62055. Think of a new title!

Author Best Answer
Avatar
Discard
Best Answer

Refer it:

Avatar
Discard
Author

I am trying like this... I have activated "developer mode". The name of "print" button in profit and loss scren is "check_report" I have find this function in the file path is addons/accounts/wizard/account_financial_report.py The model of profit and loss is "accounting.report" inherited from "account.common.report". Can any one explain these two functions, ************************************************************************************************************* def _build_comparison_context(self, cr, uid, ids, data, context=None): if context is None: context = {} result = {} result['fiscalyear'] = 'fiscalyear_id_cmp' in data['form'] and data['form']['fiscalyear_id_cmp'] or False result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False result['chart_account_id'] = 'chart_account_id' in data['form'] and data['form']['chart_account_id'] or False result['state'] = 'target_move' in data['form'] and data['form']['target_move'] or '' if data['form']['filter_cmp'] == 'filter_date': result['date_from'] = data['form']['date_from_cmp'] result['date_to'] = data['form']['date_to_cmp'] elif data['form']['filter_cmp'] == 'filter_period': if not data['form']['period_from_cmp'] or not data['form']['period_to_cmp']: raise osv.except_osv(_('Error!'),_('Select a starting and an ending period')) result['period_from'] = data['form']['period_from_cmp'] result['period_to'] = data['form']['period_to_cmp'] return result *************************************************************************************************************** def check_report(self, cr, uid, ids, context=None): if context is None: context = {} res = super(accounting_report, self).check_report(cr, uid, ids, context=context) data = {} data['form'] = self.read(cr, uid, ids, ['account_report_id', 'date_from_cmp', 'date_to_cmp', 'fiscalyear_id_cmp', 'journal_ids', 'period_from_cmp', 'period_to_cmp', 'filter_cmp', 'chart_account_id', 'target_move'], context=context)[0] for field in ['fiscalyear_id_cmp', 'chart_account_id', 'period_from_cmp', 'period_to_cmp', 'account_report_id']: if isinstance(data['form'][field], tuple): data['form'][field] = data['form'][field][0] comparison_context = self._build_comparison_context(cr, uid, ids, data, context=context) res['datas']['form']['comparison_context'] = comparison_context return res ****************************************************************************************************************** As per my knowledge these two functions for get the wizard data perfectly to res variable. How the profit and loss report come out? Where is the query to get that report?.