[ADD]:account_cash_flow:Add branch_id

This commit is contained in:
Rutuba Chavda 2018-04-19 11:06:14 +05:30 committed by Kunjal
parent b0f6928355
commit 653abef735
4 changed files with 34 additions and 24 deletions

View File

@ -30,7 +30,8 @@ class ReportAccountCashFlow(models.AbstractModel):
return date_dict return date_dict
return year_list return year_list
def get_move_lines(self, date_from, date_to, key, dummy_list): def get_move_lines(self, date_from, date_to, key, dummy_list,
company_id, branch_id):
self._cr.execute("select CASE WHEN acc_type.activity_type is null THEN acc.name ELSE acc_type.activity_type END AS activity_type, " self._cr.execute("select CASE WHEN acc_type.activity_type is null THEN acc.name ELSE acc_type.activity_type END AS activity_type, "
"aml.account_id, " "aml.account_id, "
"(sum(aml.debit) - sum(aml.credit)) * -1 as " "(sum(aml.debit) - sum(aml.credit)) * -1 as "
@ -41,7 +42,9 @@ class ReportAccountCashFlow(models.AbstractModel):
"where acc.id = aml.account_id and " "where acc.id = aml.account_id and "
"aml.date >= '%s'" % date_from + "and " "aml.date >= '%s'" % date_from + "and "
"aml.date <= '%s'" % date_to + "and " "aml.date <= '%s'" % date_to + "and "
"acc.user_type_id = acc_type.id " "acc.user_type_id = acc_type.id and "
"aml.company_id = %s " % company_id + "and "
"aml.branch_id = %s " % branch_id +
"group by aml.account_id, " "group by aml.account_id, "
"acc_type.activity_type, acc.name") "acc_type.activity_type, acc.name")
balance_data = self._cr.dictfetchall() balance_data = self._cr.dictfetchall()
@ -58,7 +61,10 @@ class ReportAccountCashFlow(models.AbstractModel):
dummy_list = list(date_dict.keys()) dummy_list = list(date_dict.keys())
dummy_list.remove(key) dummy_list.remove(key)
balance_data += self.get_move_lines(date_dict[key][0], balance_data += self.get_move_lines(date_dict[key][0],
date_dict[key][1], key, dummy_list) date_dict[key][1], key,
dummy_list, data['form'][
'company_id'][0],
data['form']['branch_id'][0])
for data in balance_data: for data in balance_data:
if data['activity_type'] not in final_dict: if data['activity_type'] not in final_dict:
final_dict[data['activity_type']] = {'account': {}} final_dict[data['activity_type']] = {'account': {}}
@ -98,6 +104,7 @@ class ReportAccountCashFlow(models.AbstractModel):
docargs = { docargs = {
'doc_model': 'account.move.line', 'doc_model': 'account.move.line',
'docs': docs, 'docs': docs,
'branch_name': data['form']['branch_id'][1],
'get_data': self.get_data(data), 'get_data': self.get_data(data),
'get_years': self.get_years(data, is_getdata=False), 'get_years': self.get_years(data, is_getdata=False),
'get_acc_details': self.get_acc_details, 'get_acc_details': self.get_acc_details,

View File

@ -6,6 +6,7 @@
<div class="page"> <div class="page">
<h3 style="text-align:center">Cash Flow Statement <h3 style="text-align:center">Cash Flow Statement
</h3> </h3>
<p style="text-align:center;margin-top: -10px;">Branch: <span t-esc="branch_name"/> </p>
<p style="text-align:center;margin-top: -10px;">upto <p style="text-align:center;margin-top: -10px;">upto
<span t-esc="datetime.datetime.now().strftime('%Y-%m-%d')" <span t-esc="datetime.datetime.now().strftime('%Y-%m-%d')"
t-options="{'widget': 'date'}"/> t-options="{'widget': 'date'}"/>

View File

@ -5,6 +5,7 @@ from flectra import models, fields
class AccountCashFlow(models.TransientModel): class AccountCashFlow(models.TransientModel):
"""Credit Notes""" """Credit Notes"""
# TODO: Add date filters
_inherit = "account.common.report" _inherit = "account.common.report"
_name = "account.cash.flow" _name = "account.cash.flow"
@ -13,7 +14,8 @@ class AccountCashFlow(models.TransientModel):
no_of_year = fields.Integer(string='Previous Period', default=0) no_of_year = fields.Integer(string='Previous Period', default=0)
def _print_report(self, data): def _print_report(self, data):
data['form'].update(self.read(['no_of_year', 'company_id'])[0]) data['form'].update(self.read(['no_of_year', 'company_id',
'branch_id'])[0])
landscape = False landscape = False
if self.no_of_year > 2: if self.no_of_year > 2:
landscape = True landscape = True

View File

@ -23,7 +23,7 @@
<field name="res_model">account.cash.flow</field> <field name="res_model">account.cash.flow</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="view_id" ref="view_account_cash_flow_from" /> <field name="view_id" ref="view_account_cash_flow_from"/>
<field name="context">{}</field> <field name="context">{}</field>
<field name="target">new</field> <field name="target">new</field>
</record> </record>