Commits

kantntreiber committed be320d2

Make dunning entries editable

Comments (0)

Files changed (4)

 from trytond.wizard import Wizard, StateView, StateAction, Button
 from trytond.modules.company import CompanyReport
 from trytond.backend import TableHandler
+from trytond.pyson import Eval, If
 
 
 class Procedure(ModelView, ModelSQL):
     line = fields.Many2One('account.move.line', 'Account Move Line',
             ondelete='CASCADE', select=True, required=True)
     level = fields.Many2One('account.dunning.procedure.level', 'Dunning Level',
-            ondelete='CASCADE', required=True)
+            ondelete='CASCADE', domain=[('procedure', '=',
+                    Eval('_parent_line', {}).get('dunning_procedure', 0))],
+            required=True)
     date = fields.Date('Date', required=True)
 
 Dunning()
         </record>
 
         <!-- dunning -->
-
         <record model="ir.ui.view" id="view_account_dunning_dunning_tree">
             <field name="model">account.dunning.dunning</field>
             <field name="type">tree</field>
             <field name="arch" type="xml">
                 <![CDATA[
                 <tree string="Dunnings">
+                    <field name="date"/>
                     <field name="level"/>
+                </tree>
+                ]]>
+            </field>
+        </record>
+        <record model="ir.ui.view" id="view_account_dunning_dunning_tree_move">
+            <field name="model">account.dunning.dunning</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+                <![CDATA[
+                <tree string="Dunnings" editable="bottom">
                     <field name="date"/>
+                    <field name="level"/>
                 </tree>
                 ]]>
             </field>
 # this repository contains the full copyright notices and license terms.
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.pool import Pool
+from trytond.pyson import Eval
 
 
 class Line(ModelSQL, ModelView):
             fields.Many2One('account.dunning.dunning', 'Current Dunning'),
             'get_current_dunning')
     dunnings = fields.One2Many('account.dunning.dunning', 'line', 'Dunnings',
-            readonly=True)
+            states={'invisible': ~Eval('dunning_procedure')},
+            depends=['dunning_procedure'])
 
     def __init__(self):
         super(Line, self).__init__()
         if not hasattr(self, '_check_modify_exclude'):
             raise NotImplementedError('The account module must be patched. '
                     'See https://bugs.tryton.org/issue2768')
-        self._check_modify_exclude += ['dunning_procedure', 'dunning_block']
+        self._check_modify_exclude += ['dunning_procedure', 'dunning_block',
+                'dunnings']
 
     def default_dunning_block(self):
         return False
                             <field name="dunning_procedure"/>
                             <label name="dunning_block"/>
                             <field name="dunning_block"/>
-                    		<field name="dunnings" colspan="4"/>
+                    		<field name="dunnings" colspan="4" view_ids="account_dunning.view_account_dunning_dunning_tree_move"/>
                         </page>
                     </xpath>
                 </data>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.