Commits

kantntreiber committed a5fbb3e

Renamed model

Renamed "account.dunning.level" to "account.dunning.procedure.level" in order to better reflect the data structure.

Comments (0)

Files changed (3)

 from trytond.transaction import Transaction
 from trytond.wizard import Wizard, StateView, StateAction, Button
 from trytond.modules.company import CompanyReport
+from trytond.backend import TableHandler
 
 
 class Procedure(ModelView, ModelSQL):
     _description = __doc__
 
     name = fields.Char('Name', required=True)
-    levels = fields.One2Many('account.dunning.level', 'procedure',
+    levels = fields.One2Many('account.dunning.procedure.level', 'procedure',
             'Dunning Levels', order=[('days', 'ASC')])
 
     def dunning_run(self, id_, base_date=None):
 Procedure()
 
 
-class Level(ModelView, ModelSQL):
+class ProcedureLevel(ModelView, ModelSQL):
     'Dunning Level'
-    _name = 'account.dunning.level'
+    _name = 'account.dunning.procedure.level'
     _description = __doc__
 
     name = fields.Char('Name', translate=True)
     procedure = fields.Many2One('account.dunning.procedure',
             'Dunning Procedure', ondelete='CASCADE', select=True)
     next_level = fields.Function(
-            fields.Many2One('account.dunning.level', 'Next Dunning Level'),
-            'get_next_level')
+            fields.Many2One('account.dunning.procedure.level',
+                    'Next Dunning Level'), 'get_next_level')
 
     def __init__(self):
-        super(Level, self).__init__()
+        super(ProcedureLevel, self).__init__()
         self._constraints += [
             ('check_days_not_negative', 'days_negative'),
         ]
         ]
         self._order = [('days', 'ASC')]
 
+    def init(self, module_name):
+        cursor = Transaction().cursor
+        old_table_name = 'account_dunning_level'
+        if TableHandler.table_exist(cursor, old_table_name):
+            TableHandler.drop_table(cursor, 'account.dunning.level',
+                    old_table_name, cascade=True)
+            cursor.execute('DROP SEQUENCE account_dunning_level_id_seq')
+        return super(ProcedureLevel, self).init(module_name)
+
     def check_days_not_negative(self, ids):
         if any(level.days < 0 for level in self.browse(ids)):
             return False
                 res[level.id] = level.id
         return res
 
-Level()
+ProcedureLevel()
 
 
 class Dunning(ModelView, ModelSQL):
 
     line = fields.Many2One('account.move.line', 'Account Move Line',
             ondelete='CASCADE', select=True, required=True)
-    level = fields.Many2One('account.dunning.level', 'Dunning Level',
+    level = fields.Many2One('account.dunning.procedure.level', 'Dunning Level',
             ondelete='CASCADE', required=True)
     date = fields.Date('Date', required=True)
 
 
         <!-- dunning level -->
 
-        <record model="ir.ui.view" id="view_account_dunning_level_form">
-            <field name="model">account.dunning.level</field>
+        <record model="ir.ui.view" id="view_account_dunning_procedure_level_form">
+            <field name="model">account.dunning.procedure.level</field>
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <![CDATA[
                 ]]>
             </field>
         </record>
-        <record model="ir.ui.view" id="view_account_dunning_level_tree">
-            <field name="model">account.dunning.level</field>
+        <record model="ir.ui.view" id="view_account_dunning_procedure_level_tree">
+            <field name="model">account.dunning.procedure.level</field>
             <field name="type">tree</field>
             <field name="arch" type="xml">
                 <![CDATA[
         </record>
 
         <record model="ir.model.access" id="access_dunning_level">
-            <field name="model" search="[('model', '=', 'account.dunning.level')]"/>
+            <field name="model" search="[('model', '=', 'account.dunning.procedure.level')]"/>
             <field name="perm_read" eval="False"/>
             <field name="perm_write" eval="False"/>
             <field name="perm_create" eval="False"/>
             <field name="perm_delete" eval="False"/>
         </record>
         <record model="ir.model.access" id="access_dunning_level_account">
-            <field name="model" search="[('model', '=', 'account.dunning.level')]"/>
+            <field name="model" search="[('model', '=', 'account.dunning.procedure.level')]"/>
             <field name="group" ref="account.group_account"/>
             <field name="perm_read" eval="True"/>
             <field name="perm_write" eval="False"/>
             <field name="perm_delete" eval="False"/>
         </record>
         <record model="ir.model.access" id="access_dunning_level_account_admin">
-            <field name="model" search="[('model', '=', 'account.dunning.level')]"/>
+            <field name="model" search="[('model', '=', 'account.dunning.procedure.level')]"/>
             <field name="group" ref="account.group_account_admin"/>
             <field name="perm_read" eval="True"/>
             <field name="perm_write" eval="True"/>
 msgid ""
 msgstr "Content-Type: text/plain; charset=utf-8\n"
 
-msgctxt "error:account.dunning.level:"
+msgctxt "error:account.dunning.procedure.level:"
 msgid "Every dunning level can only be defined once."
 msgstr "Jede Mahnstufe darf nur einmal definiert werden."
 
-msgctxt "error:account.dunning.level:"
+msgctxt "error:account.dunning.procedure.level:"
 msgid "The number of days must not be negative."
 msgstr "Die Anzahl der Tage darf nicht negativ sein."
 
 msgid "The number of days must be ascending."
 msgstr "Die Anzahl der Tage muss ansteigend sein."
 
-msgctxt "field:account.dunning.level,create_date:"
+msgctxt "field:account.dunning.procedure.level,create_date:"
 msgid "Create Date"
 msgstr "Erstellungsdatum"
 
-msgctxt "field:account.dunning.level,create_uid:"
+msgctxt "field:account.dunning.procedure.level,create_uid:"
 msgid "Create User"
 msgstr "Erstellt durch"
 
-msgctxt "field:account.dunning.level,days:"
+msgctxt "field:account.dunning.procedure.level,days:"
 msgid "Days"
 msgstr "Tage"
 
-msgctxt "field:account.dunning.level,id:"
+msgctxt "field:account.dunning.procedure.level,id:"
 msgid "ID"
 msgstr "ID"
 
-msgctxt "field:account.dunning.level,level:"
+msgctxt "field:account.dunning.procedure.level,level:"
 msgid "Dunning Level"
 msgstr "Mahnstufe"
 
-msgctxt "field:account.dunning.level,move_lines:"
+msgctxt "field:account.dunning.procedure.level,move_lines:"
 msgid "Open Items"
 msgstr "Offene Posten"
 
-msgctxt "field:account.dunning.level,name:"
+msgctxt "field:account.dunning.procedure.level,name:"
 msgid "Name"
 msgstr "Name"
 
-msgctxt "field:account.dunning.level,next_level:"
+msgctxt "field:account.dunning.procedure.level,next_level:"
 msgid "Next Dunning Level"
 msgstr "Nächste Mahnstufe"
 
-msgctxt "field:account.dunning.level,procedure:"
+msgctxt "field:account.dunning.procedure.level,procedure:"
 msgid "Dunning Procedure"
 msgstr "Mahnschema"
 
-msgctxt "field:account.dunning.level,rec_name:"
+msgctxt "field:account.dunning.procedure.level,rec_name:"
 msgid "Name"
 msgstr "Name"
 
-msgctxt "field:account.dunning.level,text:"
+msgctxt "field:account.dunning.procedure.level,text:"
 msgid "Dunning Text"
 msgstr "Mahnungstext"
 
-msgctxt "field:account.dunning.level,write_date:"
+msgctxt "field:account.dunning.procedure.level,write_date:"
 msgid "Write Date"
 msgstr "Zuletzt geändert"
 
-msgctxt "field:account.dunning.level,write_uid:"
+msgctxt "field:account.dunning.procedure.level,write_uid:"
 msgid "Write User"
 msgstr "Letzte Änderung durch"
 
 msgid "Dunning Procedure"
 msgstr "Mahnschema"
 
-msgctxt "model:account.dunning.level,name:"
+msgctxt "model:account.dunning.procedure.level,name:"
 msgid "Dunning Level"
 msgstr "Mahnstufe"
 
 msgid "Dunned Line Items"
 msgstr "Mahnposten"
 
-msgctxt "view:account.dunning.level:"
+msgctxt "view:account.dunning.procedure.level:"
 msgid "Dunning Level"
 msgstr "Mahnstufe"
 
-msgctxt "view:account.dunning.level:"
+msgctxt "view:account.dunning.procedure.level:"
 msgid "Dunning Levels"
 msgstr "Mahnstufen"
 
-msgctxt "view:account.dunning.level:"
+msgctxt "view:account.dunning.procedure.level:"
 msgid "Text"
 msgstr "Text"