Fix: PEP8
This commit is contained in:
parent
885cf6977e
commit
05c67726b5
7 changed files with 124 additions and 118 deletions
|
@ -3,18 +3,17 @@ from trytond.pool import Pool
|
|||
from . import analytic_account_report
|
||||
from . import income_statement_colgaap_report
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
analytic_account_report.PrintAnalyticAccountStart,
|
||||
income_statement_colgaap_report.PrintIncomeStatementCOLGAAPStart,
|
||||
module='analytic_account_co',type_='model')
|
||||
|
||||
module='analytic_account_co', type_='model')
|
||||
Pool.register(
|
||||
analytic_account_report.PrintAnalyticAccount,
|
||||
income_statement_colgaap_report.PrintIncomeStatementCOLGAAP,
|
||||
module='analytic_account_co',type_='wizard')
|
||||
|
||||
module='analytic_account_co', type_='wizard')
|
||||
Pool.register(
|
||||
analytic_account_report.AnalyticAccount,
|
||||
income_statement_colgaap_report.IncomeStatementCOLGAAP,
|
||||
module='analytic_account_co',type_='report')
|
||||
module='analytic_account_co', type_='report')
|
||||
|
|
|
@ -6,7 +6,6 @@ from trytond.pyson import Eval
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.report import Report
|
||||
from trytond.pool import Pool
|
||||
import datetime
|
||||
|
||||
|
||||
def compute_report(data):
|
||||
|
@ -27,19 +26,20 @@ def compute_report(data):
|
|||
if child in parent_child.childs:
|
||||
return True
|
||||
else:
|
||||
if is_child(child,parent_child):
|
||||
if is_child(child, parent_child):
|
||||
return True
|
||||
return False
|
||||
|
||||
with Transaction().set_context(ctx):
|
||||
analytic_accounts_filter = Analytic_Account.search([('parent', '!=', None),
|
||||
('parent.type', '=','root'),
|
||||
('id', 'in', data['analytic_account']),
|
||||
], order=[('code', 'ASC')])
|
||||
analytic_accounts_filter = Analytic_Account.search([
|
||||
('parent', '!=', None),
|
||||
('parent.type', '=', 'root'),
|
||||
('id', 'in', data['analytic_account']),
|
||||
], order=[('code', 'ASC')])
|
||||
|
||||
analytic_accounts = Analytic_Account.search([
|
||||
('id', '=', data['analytic_account_root'])
|
||||
],order=[('code', 'ASC')])
|
||||
], order=[('code', 'ASC')])
|
||||
aas = {}
|
||||
total = 0
|
||||
|
||||
|
@ -47,10 +47,10 @@ def compute_report(data):
|
|||
record = []
|
||||
for aaf in analytic_accounts_filter:
|
||||
aas[aa.code] = {}
|
||||
aas[aa.code][aaf.code] = [aaf,0,0,0,False]
|
||||
aas[aa.code][aaf.code] = [aaf, 0, 0, 0, False]
|
||||
if is_child(aaf, aa):
|
||||
record.append(aaf)
|
||||
record = record + [0,0,0]
|
||||
record = record + [0, 0, 0]
|
||||
if aaf.type == 'normal':
|
||||
aa_line = Analytic_Account_Line.search([
|
||||
('account', '=', aaf),
|
||||
|
@ -61,26 +61,35 @@ def compute_report(data):
|
|||
|
||||
for a_l in aa_line:
|
||||
if a_l.move_line.account.code in lines:
|
||||
lines[a_l.move_line.account.code][1] += a_l.debit
|
||||
lines[a_l.move_line.account.code][2] += a_l.credit
|
||||
lines[a_l.move_line.account.code][3].append(a_l.move_line)
|
||||
lines[
|
||||
a_l.move_line.account.code
|
||||
][1] += a_l.debit
|
||||
lines[
|
||||
a_l.move_line.account.code
|
||||
][2] += a_l.credit
|
||||
lines[
|
||||
a_l.move_line.account.code
|
||||
][3].append(a_l.move_line)
|
||||
else:
|
||||
move_line = [a_l.move_line]
|
||||
lines[a_l.move_line.account.code] = [
|
||||
a_l.move_line.account.name,
|
||||
a_l.debit,
|
||||
a_l.credit,
|
||||
move_line
|
||||
]
|
||||
move_line]
|
||||
record[1] += a_l.debit
|
||||
record[2] += a_l.credit * -(1)
|
||||
record[3] += a_l.debit - a_l.credit
|
||||
total += a_l.debit - a_l.credit
|
||||
|
||||
def is_parent(parent, account, debit, credit):
|
||||
if parent and account and parent.code in aas[aa.code]:
|
||||
aas[aa.code][parent.code][3] += debit - credit
|
||||
if parent and account and parent.code in aas[
|
||||
aa.code]:
|
||||
aas[aa.code][
|
||||
parent.code][3] += debit - credit
|
||||
if parent.parent and parent.parent.code:
|
||||
is_parent(parent.parent, account, debit, credit)
|
||||
is_parent(
|
||||
parent.parent, account, debit, credit)
|
||||
|
||||
is_parent(aa, aaf, a_l.debit, a_l.credit)
|
||||
record.append(lines)
|
||||
|
@ -88,7 +97,7 @@ def compute_report(data):
|
|||
res['record'] = aas
|
||||
res['total'] = -total
|
||||
|
||||
res['root'] = Analytic_Account.search([
|
||||
res['root'] = Analytic_Account.search([
|
||||
('id', '=', data['analytic_account_root'])])
|
||||
res['start_date'] = data['start_date']
|
||||
res['end_date'] = data['end_date']
|
||||
|
@ -112,16 +121,16 @@ class PrintAnalyticAccountStart(ModelView):
|
|||
depends=['detailed'],
|
||||
help='Show account move detailed')
|
||||
without_balance = fields.Boolean('Without Balance')
|
||||
analytic_account_root = fields.Many2One('analytic_account.account',
|
||||
'Analytic Account Root', required=True,
|
||||
domain=[('type', '=', 'root')]
|
||||
)
|
||||
analytic_account = fields.Many2Many('analytic_account.account',
|
||||
None, None, 'Analytic Account',
|
||||
domain=[('parent', '=', Eval('analytic_account_root')),
|
||||
('type', '!=', 'root')],
|
||||
depends=['analytic_account_root']
|
||||
)
|
||||
analytic_account_root = fields.Many2One(
|
||||
'analytic_account.account',
|
||||
'Analytic Account Root', required=True,
|
||||
domain=[('type', '=', 'root')])
|
||||
analytic_account = fields.Many2Many(
|
||||
'analytic_account.account',
|
||||
None, None, 'Analytic Account',
|
||||
domain=[('parent', '=', Eval('analytic_account_root')),
|
||||
('type', '!=', 'root')],
|
||||
depends=['analytic_account_root'])
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
|
@ -141,12 +150,13 @@ class PrintAnalyticAccount(Wizard):
|
|||
def do_print_(self, action):
|
||||
Analytic_Account = Pool().get('analytic_account.account')
|
||||
|
||||
|
||||
if self.start.analytic_account:
|
||||
analytic_account_ids = [ac.id for ac in self.start.analytic_account]
|
||||
analytic_account_ids = [
|
||||
ac.id for ac in self.start.analytic_account]
|
||||
else:
|
||||
analytic_account = Analytic_Account.search([('parent.type', '=', 'root'),
|
||||
('parent', '=', self.start.analytic_account_root)])
|
||||
analytic_account = Analytic_Account.search([
|
||||
('parent.type', '=', 'root'),
|
||||
('parent', '=', self.start.analytic_account_root)])
|
||||
analytic_account_ids = [ac.id for ac in analytic_account]
|
||||
|
||||
data = {
|
||||
|
@ -170,7 +180,8 @@ class AnalyticAccount(Report):
|
|||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super(AnalyticAccount, cls).get_context(records, header, data)
|
||||
report_context = super(AnalyticAccount, cls).get_context(
|
||||
records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
company = Company(data['company'])
|
||||
|
|
|
@ -23,7 +23,6 @@ def compute_report(data, domain, codes):
|
|||
'posted': data['posted'],
|
||||
}
|
||||
|
||||
|
||||
def is_child(child, parent):
|
||||
if child in parent.childs:
|
||||
return True
|
||||
|
@ -32,7 +31,7 @@ def compute_report(data, domain, codes):
|
|||
if child in parent_child.childs:
|
||||
return True
|
||||
else:
|
||||
if is_child(child,parent_child):
|
||||
if is_child(child, parent_child):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -60,15 +59,15 @@ def compute_report(data, domain, codes):
|
|||
)
|
||||
|
||||
if data.get('account_profit'):
|
||||
account_profit = Account(data['account_profit'])
|
||||
# account_profit = Account(data['account_profit'])
|
||||
profit_accounts = Account.search(['OR',
|
||||
('code', 'in', ['4', '5', '6', '7']),
|
||||
])
|
||||
amount_profit = sum([a.balance for a in profit_accounts])
|
||||
|
||||
Account_Move_Line = pool.get('account.move.line')
|
||||
analytics_accounts = []
|
||||
records = []
|
||||
# analytics_accounts = []
|
||||
# records = []
|
||||
res['records'] = {}
|
||||
res['records_full'] = {}
|
||||
res['analytic_balance'] = 0
|
||||
|
@ -85,7 +84,8 @@ def compute_report(data, domain, codes):
|
|||
record2.append(a.code)
|
||||
record2.append(a.name)
|
||||
record2.append(a.balance)
|
||||
move_state = ['posted'] if data['posted'] else ['posted', 'draft']
|
||||
move_state = ['posted'] if data['posted'] else [
|
||||
'posted', 'draft']
|
||||
account_move_lines = Account_Move_Line.search([
|
||||
('account.id', '=', a.id),
|
||||
('period', 'in', ctx['periods']),
|
||||
|
@ -98,9 +98,11 @@ def compute_report(data, domain, codes):
|
|||
if len(account_move_lines) > 0:
|
||||
for account_move_line in account_move_lines:
|
||||
for analytic_line in account_move_line.analytic_lines:
|
||||
if is_child(analytic_line.account, analytic_account):
|
||||
if is_child(
|
||||
analytic_line.account, analytic_account):
|
||||
if analytic_line.debit > 0:
|
||||
analytic_balance += analytic_line.debit * (-1)
|
||||
analytic_balance += analytic_line.debit * (
|
||||
-1)
|
||||
analytic_balance += analytic_line.credit
|
||||
record[1].append(analytic_line)
|
||||
record2[3].append(analytic_line)
|
||||
|
@ -110,18 +112,18 @@ def compute_report(data, domain, codes):
|
|||
|
||||
def is_parent(parent, account, debit):
|
||||
if parent and account:
|
||||
res['records'][analytic_account.name][parent.code][2] += debit
|
||||
res['records'][analytic_account.name][parent.code][
|
||||
2] += debit
|
||||
res['records_full'][parent.code][4] += debit
|
||||
if parent.parent and parent.parent.code:
|
||||
is_parent(parent.parent, account, debit)
|
||||
|
||||
is_parent(a.parent, a.code, analytic_balance)
|
||||
|
||||
else:
|
||||
record.append(0)
|
||||
record2.append(0)
|
||||
res['records'][analytic_account.name][a.code] = record
|
||||
if a.code in res['records_full']:
|
||||
if a.code in res['records_full']:
|
||||
res['records_full'][a.code][2] += record2[2]
|
||||
res['records_full'][a.code][4] += record2[4]
|
||||
else:
|
||||
|
@ -130,12 +132,13 @@ def compute_report(data, domain, codes):
|
|||
if res['analytic_balance'] == 0:
|
||||
res['records'].pop(analytic_account.name)
|
||||
else:
|
||||
res['records'][analytic_account.name]['balance'] = result_parcial
|
||||
res['records'][analytic_account.name]['code'] = analytic_account.code
|
||||
res['records'][
|
||||
analytic_account.name]['balance'] = result_parcial
|
||||
res['records'][
|
||||
analytic_account.name]['code'] = analytic_account.code
|
||||
main_accounts = Account.search(['OR',
|
||||
('code', 'in', codes),
|
||||
])
|
||||
|
||||
res['root'] = Analytic_Account.search([
|
||||
('id', '=', data['analytic_account_root'])
|
||||
])
|
||||
|
@ -166,6 +169,7 @@ def compute_report(data, domain, codes):
|
|||
class PrintIncomeStatementCOLGAAPStart(ModelView):
|
||||
'Print Balance Sheet <Up>art'
|
||||
__name__ = 'analytic_account_co.print_income_statement_colgaap.start'
|
||||
|
||||
fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
|
||||
help='Leave empty for all open fiscal year', required=True)
|
||||
posted = fields.Boolean('Posted Moves', help='Show posted moves only')
|
||||
|
@ -187,17 +191,17 @@ class PrintIncomeStatementCOLGAAPStart(ModelView):
|
|||
depends=['detailed'],
|
||||
help='Show account move detailed')
|
||||
without_balance = fields.Boolean('Without Balance')
|
||||
analytic_account_root = fields.Many2One('analytic_account.account',
|
||||
'Analytic Account Root', required=True,
|
||||
domain=[('type', '=', 'root')]
|
||||
)
|
||||
analytic_account = fields.Many2Many('analytic_account.account',
|
||||
None, None, 'Analytic Account',
|
||||
domain=[('parent', '=', Eval('analytic_account_root')),
|
||||
('type', '!=', 'root')],
|
||||
depends=['analytic_account_root']
|
||||
)
|
||||
|
||||
analytic_account_root = fields.Many2One(
|
||||
'analytic_account.account',
|
||||
'Analytic Account Root', required=True,
|
||||
domain=[('type', '=', 'root')]
|
||||
)
|
||||
analytic_account = fields.Many2Many(
|
||||
'analytic_account.account',
|
||||
None, None, 'Analytic Account',
|
||||
domain=[('parent', '=', Eval('analytic_account_root')),
|
||||
('type', '!=', 'root')],
|
||||
depends=['analytic_account_root'])
|
||||
|
||||
@staticmethod
|
||||
def default_posted():
|
||||
|
@ -221,11 +225,12 @@ class PrintIncomeStatementCOLGAAPStart(ModelView):
|
|||
class PrintIncomeStatementCOLGAAP(Wizard):
|
||||
'Print Analytic Income Statement COLGAAP'
|
||||
__name__ = 'analytic_account_co.print_income_statement_colgaap'
|
||||
start = StateView('analytic_account_co.print_income_statement_colgaap.start',
|
||||
start = StateView(
|
||||
'analytic_account_co.print_income_statement_colgaap.start',
|
||||
'analytic_account_co.print_income_statement_colgaap_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-print', default=True),
|
||||
])
|
||||
])
|
||||
print_ = StateReport('analytic_account_co.income_statement_colgaap')
|
||||
|
||||
def do_print_(self, action):
|
||||
|
@ -246,9 +251,11 @@ class PrintIncomeStatementCOLGAAP(Wizard):
|
|||
|
||||
periods_ids = [p.id for p in periods]
|
||||
if self.start.analytic_account:
|
||||
analytic_account_ids = [ac.id for ac in self.start.analytic_account]
|
||||
analytic_account_ids = [
|
||||
ac.id for ac in self.start.analytic_account]
|
||||
else:
|
||||
analytic_account = Analytic_Account.search([('parent.type', '=', 'root')])
|
||||
analytic_account = Analytic_Account.search([
|
||||
('parent.type', '=', 'root')])
|
||||
analytic_account_ids = [ac.id for ac in analytic_account]
|
||||
ctx['periods'] = periods_ids
|
||||
|
||||
|
@ -278,7 +285,8 @@ class IncomeStatementCOLGAAP(Report):
|
|||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super(IncomeStatementCOLGAAP, cls).get_context(records, header, data)
|
||||
report_context = super(IncomeStatementCOLGAAP, cls).get_context(
|
||||
records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
Period = pool.get('account.period')
|
||||
|
|
48
setup.py
48
setup.py
|
@ -3,7 +3,7 @@ import io
|
|||
import os
|
||||
import re
|
||||
from configparser import ConfigParser
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools import setup
|
||||
|
||||
MODULE = 'analytic_account_co'
|
||||
PREFIX = 'etrivial'
|
||||
|
@ -25,7 +25,7 @@ def get_require_version(name):
|
|||
else:
|
||||
require = '%s >= %s.%s, < %s.%s'
|
||||
require %= (name, major_version, minor_version,
|
||||
major_version, minor_version + 1)
|
||||
major_version, minor_version + 1)
|
||||
return require
|
||||
|
||||
|
||||
|
@ -53,25 +53,27 @@ if minor_version % 2:
|
|||
dependency_links.append('https://trydevpi.tryton.org/?mirror=bitbucket')
|
||||
|
||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
||||
version=version,
|
||||
description='Informes Contables y Financieros Analíticos para Colombia',
|
||||
long_description=read('README.rst'),
|
||||
author='Alnus',
|
||||
author_email='alnus@disroot.org',
|
||||
url='http://www.etrivial.icu',
|
||||
keywords='',
|
||||
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
||||
packages=[
|
||||
'trytond.modules.%s' % MODULE,
|
||||
'trytond.modules.%s.tests' % MODULE,
|
||||
],
|
||||
version=version,
|
||||
description='Informes Contables y Financieros Analíticos para Colombia',
|
||||
long_description=read('README.rst'),
|
||||
author='Alnus',
|
||||
author_email='alnus@disroot.org',
|
||||
url='http://www.etrivial.icu',
|
||||
keywords='',
|
||||
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
||||
packages=[
|
||||
'trytond.modules.%s' % MODULE,
|
||||
'trytond.modules.%s.tests' % MODULE,
|
||||
],
|
||||
package_data={
|
||||
'trytond.modules.%s' % MODULE : (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
||||
'*.fods','icons/*.svg', 'tests/*.rst']),
|
||||
},
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml',
|
||||
'locale/*.po', '*.fodt',
|
||||
'*.fods', 'icons/*.svg',
|
||||
'tests/*.rst']),
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Plugins',
|
||||
'Framework :: Tryton',
|
||||
'Intended Audience :: Developers',
|
||||
|
@ -107,7 +109,7 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Office/Business',
|
||||
],
|
||||
],
|
||||
license='GPL-3',
|
||||
python_requires='>=3.5',
|
||||
install_requires=requires,
|
||||
|
@ -115,9 +117,9 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
zip_safe=False,
|
||||
entry_points="""
|
||||
[trytond.modules]
|
||||
%s = trytond.modules.%s
|
||||
""" % (MODULE, MODULE),
|
||||
analytic_account_co= trytond.modules.analytic_account_co
|
||||
""", # noqa:
|
||||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
try:
|
||||
from trytond.modules.account_co_reports.tests.test_account_co_reports import suite # noqa: E501
|
||||
except ImportError:
|
||||
from .test_account_co_reports import suite
|
||||
|
||||
__all__ = ['suite']
|
|
@ -1,8 +1,4 @@
|
|||
import unittest
|
||||
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
from trytond.tests.test_tryton import suite as test_suite
|
||||
|
||||
|
||||
class AnalyticAccountCoTestCase(ModuleTestCase):
|
||||
|
@ -10,8 +6,4 @@ class AnalyticAccountCoTestCase(ModuleTestCase):
|
|||
module = 'analytic_account_co'
|
||||
|
||||
|
||||
def suite():
|
||||
suite = test_suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
AnalticAccountCoTestCase))
|
||||
return suite
|
||||
del ModuleTestCase
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=5.8.0
|
||||
version=6.8.0
|
||||
depends=
|
||||
ir
|
||||
res
|
||||
|
|
Loading…
Reference in a new issue