Add trial balance

This commit is contained in:
Oscar Alvarez 2021-02-18 21:57:26 -05:00
parent 0abb7f6476
commit e297b50e6e
6 changed files with 104 additions and 4 deletions

29
.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/build
/dist
*egg-info
/node_modules
# testing
/coverage
# production
/build
# misc
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock*
/__pycache__
/app/__pycache__
/app/commons/__pycache__

View File

@ -18,8 +18,10 @@ def register():
sale.ShopDailySummaryStart,
account.PrintBalanceSheetCOLGAAPStart,
account.PrintIncomeStatementCOLGAAPStart,
account.PrintTrialBalanceStart,
module='syncronize_companies', type_='model')
Pool.register(
account.TrialBalanceClassic,
sale.SaleDailyReport,
sale.SaleDetailedReport,
sale.PortfolioDetailedReport,
@ -30,6 +32,7 @@ def register():
account.IncomeStatementCOLGAAP,
module='syncronize_companies', type_='report')
Pool.register(
account.PrintTrialBalance,
account.PrintBalanceSheetCOLGAAP,
account.PrintIncomeStatementCOLGAAP,
module='syncronize_companies', type_='wizard')

View File

@ -10,15 +10,65 @@ from trytond.transaction import Transaction
__all__ = [
'PrintBalanceSheetCOLGAAPStart', 'PrintBalanceSheetCOLGAAP',
'BalanceSheetCOLGAAP', 'PrintIncomeStatementCOLGAAPStart',
'PrintIncomeStatementCOLGAAP', 'IncomeStatementCOLGAAP'
'PrintIncomeStatementCOLGAAP', 'IncomeStatementCOLGAAP',
'PrintTrialBalanceStart', 'PrintTrialBalance', 'TrialBalanceClassic'
]
_ZERO = Decimal('0.00')
class PrintTrialBalanceStart(metaclass=PoolMeta):
__name__ = 'account.print_trial_balance.start'
sincronize = fields.Boolean('Syncronize')
class PrintTrialBalance(metaclass=PoolMeta):
__name__ = 'account.print_trial_balance'
def do_print_(self, action):
action, data = super(PrintTrialBalance, self).do_print_(action)
data['sincronize'] = self.start.sincronize
return action, data
class TrialBalanceClassic(metaclass=PoolMeta):
__name__ = 'account.trial_balance_classic'
@classmethod
def get_context(cls, records, data):
report_context = super(TrialBalanceClassic, cls).get_context(records, data)
Company = Pool().get('company.company')
company = Company(Transaction().context.get('company'))
result = {}
sync = data['sincronize']
if sync:
data['sincronize'] = [False]
args = {
'records': [],
'data': data,
}
for sync in company.connection_companies:
api_ = 'http://' + sync.api_connection + '/' + sync.database
route = api_ + '/' + 'report_context'
data_ = json.dumps({
'database': sync.database,
'report_name': 'account_col.trial_balance_classic',
'args': args,
})
res = requests.get(route, data=data_)
result = res.json()
# obj_ = dict(sorted(result['records'].items()))
print('-' * 190)
print(result['accounts'])
report_context['accounts'].extend(result['accounts'])
# report_context['records'].extend(obj_.values())
# report_context['global_result'] += Decimal(result['global_result'])
return report_context
class PrintIncomeStatementCOLGAAPStart(metaclass=PoolMeta):
__name__ = 'account_col.print_income_statement_colgaap.start'
sincronize = fields.Boolean('Syncronize')
@ -69,7 +119,6 @@ class IncomeStatementCOLGAAP(metaclass=PoolMeta):
class PrintBalanceSheetCOLGAAPStart(metaclass=PoolMeta):
__name__ = 'account_col.print_balance_sheet_colgaap.start'
sincronize = fields.Boolean('Syncronize')

View File

@ -14,6 +14,12 @@
<field name="name">print_income_statement_colgaap_start_form</field>
</record>
<record model="ir.ui.view" id="print_trial_balance_start_view_form">
<field name="model">account.print_trial_balance.start</field>
<field name="inherit" ref="account_col.print_trial_balance_start_view_form"/>
<field name="name">print_trial_balance_start_form</field>
</record>
<record model="ir.rule.group" id="rule_group_voucher">
<field name="model" search="[('model', '=', 'account.voucher')]"/>
<field name="default_p" eval="False"/>
@ -61,5 +67,6 @@
pyson="1"/>
<field name="rule_group" ref="rule_group_shop"/>
</record>
</data>
</tryton>

View File

@ -1,7 +1,9 @@
[tryton]
version=5.0.0
version=5.0.1
depends:
company
account
account_col
sale
sale_pos
invoice_report

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<data>
<xpath
expr="/form/field[@name='detailed']" position="after">
<label name="sincronize"/>
<field name="sincronize"/>
</xpath>
</data>