[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 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, "
"aml.account_id, "
"(sum(aml.debit) - sum(aml.credit)) * -1 as "
@ -41,7 +42,9 @@ class ReportAccountCashFlow(models.AbstractModel):
"where acc.id = aml.account_id and "
"aml.date >= '%s'" % date_from + "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, "
"acc_type.activity_type, acc.name")
balance_data = self._cr.dictfetchall()
@ -58,7 +61,10 @@ class ReportAccountCashFlow(models.AbstractModel):
dummy_list = list(date_dict.keys())
dummy_list.remove(key)
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:
if data['activity_type'] not in final_dict:
final_dict[data['activity_type']] = {'account': {}}
@ -98,6 +104,7 @@ class ReportAccountCashFlow(models.AbstractModel):
docargs = {
'doc_model': 'account.move.line',
'docs': docs,
'branch_name': data['form']['branch_id'][1],
'get_data': self.get_data(data),
'get_years': self.get_years(data, is_getdata=False),
'get_acc_details': self.get_acc_details,

View File

@ -6,6 +6,7 @@
<div class="page">
<h3 style="text-align:center">Cash Flow Statement
</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
<span t-esc="datetime.datetime.now().strftime('%Y-%m-%d')"
t-options="{'widget': 'date'}"/>

View File

@ -5,6 +5,7 @@ from flectra import models, fields
class AccountCashFlow(models.TransientModel):
"""Credit Notes"""
# TODO: Add date filters
_inherit = "account.common.report"
_name = "account.cash.flow"
@ -13,7 +14,8 @@ class AccountCashFlow(models.TransientModel):
no_of_year = fields.Integer(string='Previous Period', default=0)
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
if self.no_of_year > 2:
landscape = True

View File

@ -5,30 +5,30 @@
<field name="model">account.cash.flow</field>
<field name="inherit_id" ref="account.account_common_report_view"/>
<field name="arch" type="xml">
<field name="journal_ids" position="replace"/>
<xpath expr="//field[@name='date_from']" position="before">
<field name="no_of_year"/>
<field name="company_id"/>
</xpath>
<field name="journal_ids" position="replace"/>
<xpath expr="//field[@name='date_from']" position="before">
<field name="no_of_year"/>
<field name="company_id"/>
</xpath>
<xpath expr="//field[@name='date_from']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='date_to']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='date_to']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_cash_flow">
<field name="name">Cash Flow</field>
<field name="res_model">account.cash.flow</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_cash_flow_from" />
<field name="context">{}</field>
<field name="target">new</field>
</record>
<record model="ir.actions.act_window" id="action_account_cash_flow">
<field name="name">Cash Flow</field>
<field name="res_model">account.cash.flow</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_cash_flow_from"/>
<field name="context">{}</field>
<field name="target">new</field>
</record>
<menuitem id="menu_cash_flow_report" name="Cash Flow"
parent="account.menu_finance_legal_statement"
action="account_cash_flow.action_account_cash_flow"/>
action="account_cash_flow.action_account_cash_flow"/>
</flectra>