changeset efc1da9c6cff in modules/analytic_account:default
details: 
https://hg.tryton.org/modules/analytic_account?cmd=changeset&node=efc1da9c6cff
description:
        Use context model for charts

        issue11496
        review443121003
diffstat:

 CHANGELOG                      |   2 ++
 __init__.py                    |   3 +--
 account.py                     |  26 ++------------------------
 account.xml                    |  37 +++++++++++++++++--------------------
 view/account_context_form.xml  |   9 +++++++++
 view/account_tree2.xml         |  11 -----------
 view/account_tree_chart.xml    |  11 +++++++++++
 view/open_chart_start_form.xml |   9 ---------
 8 files changed, 42 insertions(+), 66 deletions(-)

diffs (202 lines):

diff -r 49457cdc38b7 -r efc1da9c6cff CHANGELOG
--- a/CHANGELOG Mon May 02 16:52:30 2022 +0200
+++ b/CHANGELOG Mon Jul 18 00:04:04 2022 +0200
@@ -1,3 +1,5 @@
+* Use context model for chart of analytic accounts
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Add support for Python 3.10
diff -r 49457cdc38b7 -r efc1da9c6cff __init__.py
--- a/__init__.py       Mon May 02 16:52:30 2022 +0200
+++ b/__init__.py       Mon Jul 18 00:04:04 2022 +0200
@@ -13,7 +13,7 @@
     Pool.register(
         account.Account,
         account.AccountDistribution,
-        account.OpenChartAccountStart,
+        account.AccountContext,
         account.AnalyticAccountEntry,
         line.Line,
         line.Move,
@@ -21,6 +21,5 @@
         rule.Rule,
         module='analytic_account', type_='model')
     Pool.register(
-        account.OpenChartAccount,
         line.OpenAccount,
         module='analytic_account', type_='wizard')
diff -r 49457cdc38b7 -r efc1da9c6cff account.py
--- a/account.py        Mon May 02 16:52:30 2022 +0200
+++ b/account.py        Mon Jul 18 00:04:04 2022 +0200
@@ -16,7 +16,6 @@
 from trytond.pyson import Eval, If, PYSONDecoder, PYSONEncoder
 from trytond.tools import lstrip_wildcard
 from trytond.transaction import Transaction
-from trytond.wizard import Button, StateAction, StateView, Wizard
 
 from .exceptions import AccountValidationError
 
@@ -297,34 +296,13 @@
             return result
 
 
-class OpenChartAccountStart(ModelView):
+class AccountContext(ModelView):
     'Open Chart of Accounts'
-    __name__ = 'analytic_account.open_chart.start'
+    __name__ = 'analytic_account.account.context'
     start_date = fields.Date('Start Date')
     end_date = fields.Date('End Date')
 
 
-class OpenChartAccount(Wizard):
-    'Open Chart of Accounts'
-    __name__ = 'analytic_account.open_chart'
-    start = StateView('analytic_account.open_chart.start',
-        'analytic_account.open_chart_start_view_form', [
-            Button('Cancel', 'end', 'tryton-cancel'),
-            Button('Open', 'open_', 'tryton-ok', default=True),
-            ])
-    open_ = StateAction('analytic_account.act_account_tree2')
-
-    def do_open_(self, action):
-        action['pyson_context'] = PYSONEncoder().encode({
-                'start_date': self.start.start_date,
-                'end_date': self.start.end_date,
-                })
-        return action, {}
-
-    def transition_open_(self):
-        return 'end'
-
-
 class AccountDistribution(ModelView, ModelSQL):
     "Analytic Account Distribution"
     __name__ = 'analytic_account.account.distribution'
diff -r 49457cdc38b7 -r efc1da9c6cff account.xml
--- a/account.xml       Mon May 02 16:52:30 2022 +0200
+++ b/account.xml       Mon Jul 18 00:04:04 2022 +0200
@@ -77,38 +77,35 @@
             sequence="10"
             id="menu_account_list"/>
 
-        <record model="ir.ui.view" id="account_view_tree2">
+        <record model="ir.ui.view" id="account_view_tree_chart">
             <field name="model">analytic_account.account</field>
             <field name="type">tree</field>
             <field name="field_childs">childs</field>
             <field name="priority" eval="20"/>
-            <field name="name">account_tree2</field>
+            <field name="name">account_tree_chart</field>
         </record>
-        <record model="ir.action.act_window" id="act_account_tree2">
-            <field name="name">Analytic Accounts</field>
+        <record model="ir.action.act_window" id="act_account_tree_chart">
+            <field name="name">Chart of Analytic Accounts</field>
             <field name="res_model">analytic_account.account</field>
+            <field 
name="context_model">analytic_account.account.context</field>
             <field name="domain" eval="[('parent', '=', None)]" pyson="1"/>
         </record>
-        <record model="ir.action.act_window.view" id="act_account_tree2_view1">
+        <record model="ir.action.act_window.view" 
id="act_account_tree_chart_view1">
             <field name="sequence" eval="10"/>
-            <field name="view" ref="account_view_tree2"/>
-            <field name="act_window" ref="act_account_tree2"/>
+            <field name="view" ref="account_view_tree_chart"/>
+            <field name="act_window" ref="act_account_tree_chart"/>
         </record>
-        <record model="ir.action.act_window.view" id="act_account_tree2_view2">
+        <record model="ir.action.act_window.view" 
id="act_account_tree_chart_view2">
             <field name="sequence" eval="20"/>
             <field name="view" ref="account_view_form"/>
-            <field name="act_window" ref="act_account_tree2"/>
-        </record>
-        <record model="ir.action.wizard" id="act_open_chart">
-            <field name="name">Open Chart of Analytic Accounts</field>
-            <field name="wiz_name">analytic_account.open_chart</field>
+            <field name="act_window" ref="act_account_tree_chart"/>
         </record>
+
         <menuitem
-            parent="account.menu_charts"
-            action="act_open_chart"
+            parent="account.menu_reporting"
+            action="act_account_tree_chart"
             sequence="30"
-            id="menu_open_chart"
-            icon="tryton-tree"/>
+            id="menu_account_tree_chart"/>
 
         <record model="ir.rule.group" id="rule_group_account_companies">
             <field name="name">User in companies</field>
@@ -169,10 +166,10 @@
             <field name="perm_delete" eval="True"/>
         </record>
 
-        <record model="ir.ui.view" id="open_chart_start_view_form">
-            <field name="model">analytic_account.open_chart.start</field>
+        <record model="ir.ui.view" id="account_context_view_form">
+            <field name="model">analytic_account.account.context</field>
             <field name="type">form</field>
-            <field name="name">open_chart_start_form</field>
+            <field name="name">account_context_form</field>
         </record>
 
         <record model="ir.ui.view" id="analytic_account_entry_view_form">
diff -r 49457cdc38b7 -r efc1da9c6cff view/account_context_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/view/account_context_form.xml     Mon Jul 18 00:04:04 2022 +0200
@@ -0,0 +1,9 @@
+<?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. -->
+<form>
+    <label name="start_date"/>
+    <field name="start_date"/>
+    <label name="end_date"/>
+    <field name="end_date"/>
+</form>
diff -r 49457cdc38b7 -r efc1da9c6cff view/account_tree2.xml
--- a/view/account_tree2.xml    Mon May 02 16:52:30 2022 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-<?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. -->
-<tree keyword_open="1">
-    <field name="name" expand="2"/>
-    <field name="company" expand="1" optional="1"/>
-    <field name="code" optional="0"/>
-    <field name="debit" optional="0"/>
-    <field name="credit" optional="0"/>
-    <field name="balance" optional="0"/>
-</tree>
diff -r 49457cdc38b7 -r efc1da9c6cff view/account_tree_chart.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/view/account_tree_chart.xml       Mon Jul 18 00:04:04 2022 +0200
@@ -0,0 +1,11 @@
+<?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. -->
+<tree keyword_open="1">
+    <field name="name" expand="2"/>
+    <field name="company" expand="1" optional="1"/>
+    <field name="code" optional="0"/>
+    <field name="debit" optional="0"/>
+    <field name="credit" optional="0"/>
+    <field name="balance" optional="0"/>
+</tree>
diff -r 49457cdc38b7 -r efc1da9c6cff view/open_chart_start_form.xml
--- a/view/open_chart_start_form.xml    Mon May 02 16:52:30 2022 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-<?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. -->
-<form>
-    <label name="start_date"/>
-    <field name="start_date"/>
-    <label name="end_date"/>
-    <field name="end_date"/>
-</form>

Reply via email to