Guest User

Untitled

a guest
Jul 5th, 2018
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -r 677e57333f98 -r 415c7ccd7f0f __init__.py
  2. --- a/__init__.py   Tue Jun 26 19:11:40 2018 +0200
  3. +++ b/__init__.py   Thu Jul 05 17:51:25 2018 +0200
  4. @@ -29,6 +29,7 @@
  5.          GeneralLedgerAccountContext,
  6.          GeneralLedgerLine,
  7.          GeneralLedgerLineContext,
  8. +        GeneralLedgerParty,
  9.          BalanceSheetContext,
  10.          BalanceSheetComparisionContext,
  11.          IncomeStatementContext,
  12. diff -r 677e57333f98 -r 415c7ccd7f0f account.py
  13. --- a/account.py    Tue Jun 26 19:11:40 2018 +0200
  14. +++ b/account.py    Thu Jul 05 17:51:25 2018 +0200
  15. @@ -7,7 +7,7 @@
  16.  
  17.  from dateutil.relativedelta import relativedelta
  18.  from sql import Column, Null, Window, Literal
  19. -from sql.aggregate import Sum, Max
  20. +from sql.aggregate import Sum, Max, Min
  21.  from sql.conditionals import Coalesce, Case
  22.  
  23.  from trytond.model import (
  24. @@ -28,6 +28,7 @@
  25.      'OpenChartAccountStart', 'OpenChartAccount',
  26.      'GeneralLedgerAccount', 'GeneralLedgerAccountContext',
  27.      'GeneralLedgerLine', 'GeneralLedgerLineContext',
  28. +    'GeneralLedgerParty',
  29.      'GeneralLedger', 'TrialBalance',
  30.      'BalanceSheetContext', 'BalanceSheetComparisionContext',
  31.      'IncomeStatementContext',
  32. @@ -1285,6 +1286,8 @@
  33.          'get_account', searcher='search_account')
  34.      lines = fields.One2Many('account.general_ledger.line', 'account', 'Lines',
  35.          readonly=True)
  36. +    parties = fields.One2Many('account.general_ledger.party', 'account', 'Parties',
  37. +        readonly=True)
  38.      general_ledger_balance = fields.Boolean('General Ledger Balance')
  39.      currency_digits = fields.Function(fields.Integer('Currency Digits'),
  40.          'get_currency_digits')
  41. @@ -1521,6 +1524,44 @@
  42.              self.end_period = None
  43.  
  44.  
  45. +class GeneralLedgerParty(ModelSQL, ModelView):
  46. +    'General Ledger Party'
  47. +    __name__ = 'account.general_ledger.party'
  48. +
  49. +    account = fields.Many2One('account.general_ledger.account', 'Account')
  50. +    party = fields.Many2One('party.party', 'Party')
  51. +
  52. +    @classmethod
  53. +    def table_query(cls):
  54. +        pool = Pool()
  55. +        Line = pool.get('account.move.line')
  56. +        LedgerAccount = pool.get('account.general_ledger.account')
  57. +        Account = pool.get('account.account')
  58. +        Party = pool.get('party.party')
  59. +        transaction = Transaction()
  60. +        line = Line.__table__()
  61. +        account = Account.__table__()
  62. +        party = Party.__table__()
  63. +
  64. +        start_period_ids = set(LedgerAccount.get_period_ids('start_balance'))
  65. +        end_period_ids = set(LedgerAccount.get_period_ids('end_balance'))
  66. +        period_ids = list(end_period_ids.difference(start_period_ids))
  67. +        with Transaction().set_context(periods=period_ids):
  68. +            line_query, fiscalyear_ids = Line.query_get(line)
  69. +        return party.join(line, condition=party.id == line.party
  70. +            ).join(account, condition=line.account == account.id
  71. +                    ).select(
  72. +                            Min(party.id).as_('id'),
  73. +                            Max(party.create_uid).as_('create_uid'),
  74. +                            Max(party.create_date).as_('create_date'),
  75. +                            Max(party.write_uid).as_('write_uid'),
  76. +                            Max(party.write_date).as_('write_date'),
  77. +                            party.id.as_('party'),
  78. +                            account.id.as_('account'),
  79. +                            where=line_query,
  80. +                            group_by=party.id
  81. +                            )
  82. +
  83.  class GeneralLedgerLine(ModelSQL, ModelView):
  84.      'General Ledger Line'
  85.      __name__ = 'account.general_ledger.line'
  86. diff -r 677e57333f98 -r 415c7ccd7f0f account.xml
  87. --- a/account.xml   Tue Jun 26 19:11:40 2018 +0200
  88. +++ b/account.xml   Thu Jul 05 17:51:25 2018 +0200
  89. @@ -469,9 +469,16 @@
  90.          <record model="ir.ui.view" id="general_ledger_account_view_list">
  91.              <field name="model">account.general_ledger.account</field>
  92.              <field name="type">tree</field>
  93. +            <field name="field_childs">parties</field>
  94.              <field name="name">general_ledger_account_list</field>
  95.          </record>
  96.  
  97. +        <record model="ir.ui.view" id="general_ledger_party_view_list">
  98. +            <field name="model">account.general_ledger.party</field>
  99. +            <field name="type">tree</field>
  100. +            <field name="name">general_ledger_party_list</field>
  101. +        </record>
  102. +
  103.          <record model="ir.action.act_window" id="act_general_ledger_account_form">
  104.              <field name="name">General Ledger - Accounts</field>
  105.              <field name="res_model">account.general_ledger.account</field>
  106. diff -r 677e57333f98 -r 415c7ccd7f0f view/general_ledger_account_list.xml
  107. --- a/view/general_ledger_account_list.xml  Tue Jun 26 19:11:40 2018 +0200
  108. +++ b/view/general_ledger_account_list.xml  Thu Jul 05 17:51:25 2018 +0200
  109. @@ -8,4 +8,5 @@
  110.      <field name="debit" sum="Debit"/>
  111.      <field name="credit" sum="Credit"/>
  112.      <field name="end_balance" sum="End Balance"/>
  113. +    <field name="parties" tree_invisible="1"/>
  114.  </tree>
  115. diff -r 677e57333f98 -r 415c7ccd7f0f view/general_ledger_party_list.xml
  116. --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
  117. +++ b/view/general_ledger_party_list.xml    Thu Jul 05 17:51:25 2018 +0200
  118. @@ -0,0 +1,6 @@
  119. +<?xml version="1.0"?>
  120. +<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
  121. +this repository contains the full copyright notices and license terms. -->
  122. +<tree>
  123. +    <field name="party" expand="1"/>
  124. +</tree>
RAW Paste Data