Added Third Party Balance report
This commit is contained in:
+111
@@ -1243,3 +1243,114 @@ class CreateChartAccount(Wizard):
|
||||
return {}
|
||||
|
||||
CreateChartAccount()
|
||||
|
||||
|
||||
class OpenThirdPartyBalanceInit(WizardOSV):
|
||||
_name = 'account.account.open_third_party_balance.init'
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
|
||||
required=True)
|
||||
posted = fields.Boolean('Posted Move', help='Only posted move')
|
||||
|
||||
|
||||
def default_fiscalyear(self, cursor, user, context=None):
|
||||
fiscalyear_obj = self.pool.get('account.fiscalyear')
|
||||
if context is None:
|
||||
context = {}
|
||||
fiscalyear_id = fiscalyear_obj.find(cursor, user,
|
||||
context.get('company', False), exception=False, context=context)
|
||||
if fiscalyear_id:
|
||||
return fiscalyear_obj.name_get(cursor, user, fiscalyear_id,
|
||||
context=context)[0]
|
||||
return False
|
||||
|
||||
def default_posted(self, cursor, user, context=None):
|
||||
return False
|
||||
|
||||
def default_company(self, cursor, user, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
company_obj = self.pool.get('company.company')
|
||||
if context.get('company'):
|
||||
return company_obj.name_get(cursor, user, context['company'],
|
||||
context=context)[0]
|
||||
return False
|
||||
|
||||
OpenThirdPartyBalanceInit()
|
||||
|
||||
|
||||
class OpenThirdPartyBalance(Wizard):
|
||||
'Open Third Party Balance'
|
||||
_name = 'account.account.open_third_party_balance'
|
||||
states = {
|
||||
'init': {
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'object': 'account.account.open_third_party_balance.init',
|
||||
'state': [
|
||||
('end', 'Cancel', 'tryton-cancel'),
|
||||
('print', 'Print', 'tryton-ok', True),
|
||||
],
|
||||
},
|
||||
},
|
||||
'print': {
|
||||
'result': {
|
||||
'type': 'print',
|
||||
'report': 'account.account.third_party_balance',
|
||||
'state': 'end',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
OpenThirdPartyBalance()
|
||||
|
||||
|
||||
class ThirdPartyBalance(Report):
|
||||
_name = 'account.account.third_party_balance'
|
||||
|
||||
def _get_objects(self, cursor, user, ids, model, datas, context):
|
||||
party_obj = self.pool.get('relationship.party')
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
company_obj = self.pool.get('company.company')
|
||||
company = company_obj.browse(cursor, user,
|
||||
datas['form']['company'], context=context)
|
||||
context['company'] = company
|
||||
context['digits'] = company.currency.digits
|
||||
context['fiscalyear'] = datas['form']['fiscalyear']
|
||||
line_query = move_line_obj.query_get(cursor, user, context=context)
|
||||
if datas['form']['posted']:
|
||||
posted_clause = "and m.state = 'posted' "
|
||||
else:
|
||||
posted_clause = ""
|
||||
|
||||
cursor.execute('SELECT l.party, SUM(l.debit), SUM(l.credit) ' \
|
||||
'FROM account_move_line l ' \
|
||||
'JOIN account_move m on (l.move = m.id) '
|
||||
'JOIN account_account a on (l.account = a.id) '
|
||||
'WHERE l.party is not null '\
|
||||
'AND a.active ' \
|
||||
'AND a.kind in (\'payable\',\'receivable\') ' \
|
||||
'AND l.reconciliation IS NULL ' \
|
||||
'AND a.company = %s ' \
|
||||
'AND (l.maturity_date <= %s ' \
|
||||
'OR l.maturity_date IS NULL) '\
|
||||
'AND ' + line_query + ' ' \
|
||||
+ posted_clause + \
|
||||
'GROUP BY l.party',
|
||||
(datas['form']['company'],datetime.date.today()))
|
||||
|
||||
res = cursor.fetchall()
|
||||
party_name = dict(party_obj.name_get(
|
||||
cursor, user, [x[0] for x in res],
|
||||
context=context))
|
||||
objects = [{'name': party_name[x[0]],
|
||||
'debit': x[1],
|
||||
'credit': x[2],
|
||||
'solde': x[1]-x[2]} for x in res]
|
||||
objects.sort(lambda x,y: cmp(x['name'],y['name']))
|
||||
context['total_debit'] = sum((o['debit'] for o in objects))
|
||||
context['total_credit'] = sum((o['credit'] for o in objects))
|
||||
context['total_solde'] = sum((o['solde'] for o in objects))
|
||||
return objects
|
||||
|
||||
ThirdPartyBalance()
|
||||
|
||||
+30
@@ -683,5 +683,35 @@
|
||||
id="menu_open_income_statement" icon="tryton-tree"
|
||||
name="Income Statement"/>
|
||||
|
||||
<record model="ir.ui.view" id="open_third_party_balance_init_view_form">
|
||||
<field name="model">account.account.open_third_party_balance.init</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Open Third Party Balance" col="2">
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="fiscalyear"/>
|
||||
<field name="fiscalyear"/>
|
||||
<label name="posted"/>
|
||||
<field name="posted"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.action.report" id="report_third_party_balance">
|
||||
<field name="name">Third Party Balance</field>
|
||||
<field name="model">relationship.partner</field>
|
||||
<field name="report_name">account.account.third_party_balance</field>
|
||||
<field name="report">account/third_party_balance.odt</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_open_third_party_balance">
|
||||
<field name="name">Open Third Party Balance</field>
|
||||
<field name="wiz_name">account.account.open_third_party_balance</field>
|
||||
</record>
|
||||
<menuitem parent="menu_reporting" action="wizard_open_third_party_balance"
|
||||
id="menu_third_party_balance" icon="tryton-print"
|
||||
name="Third Party Balance"/>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -364,7 +364,7 @@ class Line(OSV):
|
||||
help='The second currency')
|
||||
party = fields.Many2One('relationship.party', 'Party',
|
||||
on_change=['move', 'party', 'account', 'debit', 'credit',
|
||||
'journal'])
|
||||
'journal'], select=True)
|
||||
blocked = fields.Boolean('Litigation',
|
||||
help='Mark the line as litigation with the party.')
|
||||
maturity_date = fields.Date('Maturity Date',
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user