[FIX]: fix a problem in the wiki module
authorMantavya Gajjar <mga@tinyerp.com>
Thu, 16 Sep 2010 17:52:58 +0000 (23:22 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Thu, 16 Sep 2010 17:52:58 +0000 (23:22 +0530)
[FIX]: fix a view for the journal voucher view

bzr revid: mga@tinyerp.com-20100916175258-vjz4pnjh3eqlgb7k

addons/account/account.py
addons/account_voucher/voucher_sales_purchase_view.xml
addons/account_voucher/voucher_view.xml
addons/wiki/wiki.py
addons/wiki/wiki_view.xml

index 625bcd1..375d1a0 100644 (file)
@@ -686,6 +686,27 @@ class account_journal(osv.osv):
             vals.update({'sequence_id' : self.create_sequence(cr, uid, vals, context)})
         return super(account_journal, self).create(cr, uid, vals, context)
 
+    def name_get(self, cr, user, ids, context={}):
+        """
+        Returns a list of tupples containing id, name.
+        result format : {[(id, name), (id, name), ...]}
+        
+        @param cr: A database cursor
+        @param user: ID of the user currently logged in
+        @param ids: list of ids for which name should be read
+        @param context: context arguments, like lang, time zone
+        
+        @return: Returns a list of tupples containing id, name
+        """
+        result = self.browse(cr, user, ids, context)
+        res = []
+        for rs in result:
+            name = rs.name 
+            if rs.currency:
+                name = "%s (%s)" % (rs.name, rs.currency.name)
+            res += [(rs.id, name)]
+        return res
+    
     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
         if not args:
             args = []
index 7dd79c2..b72faa4 100644 (file)
                         <field name="name" colspan="4"/>
                         <field name="date" on_change="onchange_date(date)"/>
                         <field name="type" invisible="True"/>
+                        <field name="currency_id" invisible="True" nolabel="1"/>
                     </group>
                     <notebook colspan="4">
                         <page string="Sales Information">
                                 <group col="4" colspan="1">
                                     <separator string="Total" colspan="4"/>
                                     <field name="tax_id" on_change="onchange_price(line_cr_ids, tax_id, partner_id)" widget="selection" domain="[('type_tax_use','in',('sale','all'))]"/><field name="tax_amount" nolabel="1"/><button type="object" icon="terp-stock_format-scientific" name="compute_tax" groups="base.group_extended" string="Compute Tax" attrs="{'invisible': [('state','!=','draft')]}"/>
-                                    <label string="" colspan="1"/><field name="currency_id" invisible="True" nolabel="1"/><field name="amount" string="Total"/>
+                                    <label string="" colspan="1"/><field name="amount" string="Total"/>
                                 </group>
                             </group>
                         </page>
                         <field name="reference" select="1"/>
                         <field name="account_id" domain="[('type','=','other')]"  invisible="True"/>
                         <field name="type" invisible="True"/>
+                        <field name="currency_id" invisible="True" nolabel="1"/>
                     </group>
                     <notebook colspan="4">
                         <page string="Bill Information">
                                 <group col="4" colspan="1">
                                     <separator string="Total" colspan="4"/>
                                     <field name="tax_id" on_change="onchange_price(line_dr_ids, tax_id, partner_id)" widget="selection" domain="[('type_tax_use','in',('purchase','all'))]"/><field name="tax_amount" nolabel="1"/><button type="object" icon="terp-stock_format-scientific" name="compute_tax" string="Compute Tax" groups="base.group_extended" attrs="{'invisible': [('state','!=','draft')]}"/>
-                                    <label string="" colspan="1"/><field name="currency_id" invisible="True" nolabel="1"/><field name="amount" string="Total"/>
+                                    <label string="" colspan="1"/><field name="amount" string="Total"/>
                                 </group>
                             </group>
                         </page>
index 94b2577..9291567 100644 (file)
             <field name="view_id" eval="view_voucher_tree"/>
             <field name="search_view_id" ref="view_voucher_filter"/>
         </record>
+        <record id="action_journal_voucher_tree" model="ir.actions.act_window.view">
+            <field eval="1" name="sequence"/>
+            <field name="view_mode">tree</field>
+            <field name="act_window_id" ref="action_voucher_list"/>
+        </record>
+        <record id="action_journal_voucher_form" model="ir.actions.act_window.view">
+            <field eval="2" name="sequence"/>
+            <field name="view_mode">form</field>
+            <field name="view_id" ref="view_voucher_form"/>
+            <field name="act_window_id" ref="action_voucher_list"/>
+        </record>
         <menuitem action="action_voucher_list" id="menu_encode_entries_by_voucher" parent="account.menu_finance_entries" sequence="6"/>
 
         <act_window
index ab19dc8..ff21e39 100644 (file)
@@ -24,13 +24,13 @@ from osv import fields, osv
 from tools.translate import _
 import difflib
 
-class Wiki(osv.osv):
+class wiki_wiki(osv.osv):
     """ wiki """
     _name = "wiki.wiki"
 
-Wiki()
+wiki_wiki()
 
-class WikiGroup(osv.osv):
+class wiki_group(osv.osv):
     """ Wiki Groups """
 
     _name = "wiki.groups"
@@ -45,8 +45,8 @@ class WikiGroup(osv.osv):
        'template': fields.text('Wiki Template'),
        'section': fields.boolean("Make Section ?"),
        'method':fields.selection([('list', 'List'), ('page', 'Home Page'), \
-                                   ('tree', 'Tree')], 'Display Method'),
-       'home':fields.many2one('wiki.wiki', 'Home Page'),
+                                   ('tree', 'Tree')], 'Display Method', help="Define the default behaviour of the menu created on this group"),
+       'home':fields.many2one('wiki.wiki', 'Home Page', help="Required to select home page if display method is Home Page"),
        'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True),
     }
 
@@ -94,10 +94,10 @@ class WikiGroup(osv.osv):
             value['view_type'] = 'tree'
 
         return value
-WikiGroup()
+wiki_group()
 
 
-class Wiki2(osv.osv):
+class wiki_wiki2(osv.osv):
     """ Wiki Page """
 
     _inherit = "wiki.wiki"
@@ -111,7 +111,7 @@ class Wiki2(osv.osv):
         'create_uid': fields.many2one('res.users', 'Author', select=True),
         'create_date': fields.datetime("Created on", select=True),
         'write_date': fields.datetime("Modification Date", select=True),
-        'tags': fields.char('Tags', size=1024, select=True),
+        'tags': fields.char('Keywords', size=1024, select=True),
         'history_id': fields.one2many('wiki.wiki.history', 'wiki_id', 'History Lines'),
         'minor_edit': fields.boolean('Minor edit', select=True),
         'summary': fields.char('Summary', size=256),
@@ -119,12 +119,17 @@ class Wiki2(osv.osv):
         'group_id': fields.many2one('wiki.groups', 'Wiki Group', select=1, ondelete='set null',
             help="Topic, also called Wiki Group"),
         'toc': fields.boolean('Table of Contents',
-            help="Indicates that this pages is a table of contents (linking to other pages)"),
+            help="Indicates that this pages have a table of contents or not"),
         'review': fields.boolean('Needs Review', select=True,
             help="Indicates that this page should be reviewed, raising the attention of other contributors"),
-        'parent_id': fields.many2one('wiki.wiki', 'Parent Page'),
+        'parent_id': fields.many2one('wiki.wiki', 'Parent Page', help="Allows you to link with the other page with in the current topic"),
         'child_ids': fields.one2many('wiki.wiki', 'parent_id', 'Child Pages'),
     }
+    _defaults = {
+        'toc': lambda *a: True,
+        'review': lambda *a: True,
+        'minor_edit': lambda *a: True,
+    }
 
     def onchange_group_id(self, cr, uid, ids, group_id, content, context={}):
 
@@ -160,23 +165,28 @@ class Wiki2(osv.osv):
             @param id: Give wiki page's ID """
 
         return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
-
-    def create(self, cr, uid, vals, context=None):
-
-        """ @param cr: the current row, from the database cursor,
-            @param uid: the current user’s ID for security checks, """
-
-        id = super(Wiki, self).create(cr, uid, vals, context)
+    
+    def create_history(self, cr, uid, ids, vals, context=None):
+        history_id = False
         history = self.pool.get('wiki.wiki.history')
         if vals.get('text_area'):
             res = {
                 'minor_edit': vals.get('minor_edit', True),
                 'text_area': vals.get('text_area', ''),
                 'write_uid': uid,
-                'wiki_id': id,
+                'wiki_id': ids[0],
                 'summary':vals.get('summary', '')
             }
-            history.create(cr, uid, res)
+            history_id = history.create(cr, uid, res)
+        return history_id
+    
+    def create(self, cr, uid, vals, context=None):
+
+        """ @param cr: the current row, from the database cursor,
+            @param uid: the current user’s ID for security checks, """
+
+        id = super(Wiki, self).create(cr, uid, vals, context)
+        self.create_history(cr, uid, [id], vals, context)
         return id
 
     def write(self, cr, uid, ids, vals, context=None):
@@ -185,23 +195,13 @@ class Wiki2(osv.osv):
             @param uid: the current user’s ID for security checks, """
 
         result = super(Wiki, self).write(cr, uid, ids, vals, context)
-        history = self.pool.get('wiki.wiki.history')
-        if vals.get('text_area'):
-            for id in ids:
-                res = {
-                    'minor_edit': vals.get('minor_edit', True),
-                    'text_area': vals.get('text_area', ''),
-                    'write_uid': uid,
-                    'wiki_id': id,
-                    'summary': vals.get('summary', '')
-                }
-                history.create(cr, uid, res)
+        self.create_history(cr, uid, ids, vals, context)
         return result
 
-Wiki2()
+wiki_wiki2()
 
 
-class History(osv.osv):
+class wiki_history(osv.osv):
     """ Wiki History """
 
     _name = "wiki.wiki.history"
@@ -240,6 +240,6 @@ class History(osv.osv):
         diff = difflib.HtmlDiff()
         return diff.make_file(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=False)
 
-History()
+wiki_history()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 5c9aa84..04f33be 100644 (file)
@@ -12,8 +12,7 @@
            parent="knowledge.menu_document_configuration" sequence="2" />
 
 
-<!--  Wiki Groups Tree view -->
-
+        <!--  Wiki Groups Tree view -->
        <record model="ir.ui.view" id="wiki_group_tree">
             <field name="name">wiki.groups.tree</field>
             <field name="model">wiki.groups</field>
             </field>
         </record>
 
-<!--  Wiki Groups Form view -->
-
+        <!--  Wiki Groups Form view -->
         <record model="ir.ui.view" id="wiki_group_form">
             <field name="name">wiki.groups.form</field>
             <field name="model">wiki.groups</field>
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Wiki Groups">
-                    <group colspan="4" col="4">
+                    <group col="4" colspan="3" >
                         <field name="name" select="1"/>
                         <field name="create_date" readonly="2"/>
+                    </group>
+                    <group col="2" colspan="1">
                         <field name="method" select="1"/>
-                        <field name="home" select="1"
+                        <field name="home" select="1" domain="[('group_id','=',active_id)]"
                             attrs="{'required':[('method','=','page')], 'readonly':[('method','!=','page')]}" />
                     </group>
                     <notebook colspan="4">
                     <page string="Notes">
+                        <separator string="Group Description" colspan="4"/>
                         <field name="notes" colspan="4" nolabel="1"/>
                     </page><page string="Configuration">
                         <separator string="Page Template" colspan="4"/>
@@ -64,8 +65,7 @@
             </field>
         </record>
 
-<!--  Wiki Groups Action  -->
-
+        <!--  Wiki Groups Action  -->
         <record model="ir.actions.act_window" id="action_wiki_groups">
             <field name="name">Wiki Groups</field>
             <field name="res_model">wiki.groups</field>
@@ -84,8 +84,7 @@
             <field name="view_type">tree</field>
         </record>
 
-<!-- wiki Tree view For child -->
-
+        <!-- wiki Tree view For child -->
         <record id="view_wiki_tree_childs" model="ir.ui.view">
             <field name="name">wiki.wiki.tree.childs</field>
             <field name="model">wiki.wiki</field>
             </field>
         </record>
 
-<!-- wiki Tree view  -->
-
+        <!-- wiki Tree view  -->
         <record model="ir.ui.view" id="view_wiki_tree">
             <field name="name">wiki.wiki.tree</field>
             <field name="model">wiki.wiki</field>
             <field name="arch" type="xml">
                 <tree string="Wiki">
                     <field name="name"/>
+                    <field name="group_id"/>
                     <field name="section" invisible="not context.get('section',False)"/>
-                    <field name="group_id" invisible="context.get('group_id',False)"/>
                     <field name="review"/>
+                    <field name="create_uid" invisible="context.get('create_uid',False)"/>
                     <field name="write_uid"/>
                     <field name="write_date"/>
                 </tree>
             </field>
         </record>
 
-<!-- wiki Form view  -->
-
+        <!-- wiki Form view  -->
         <record model="ir.ui.view" id="view_wiki_form">
             <field name="name">wiki.wiki.form</field>
             <field name="model">wiki.wiki</field>
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Wiki">
-                    <group col="8" colspan="4">
-                        <field name="name" select="1" colspan="8"/>
+                    <group col="6" colspan="4">
+                        <field name="name" select="1" colspan="6"/>
                         <field name="group_id" string="Topic" select="1" on_change="onchange_group_id(group_id, text_area)"/>
-                        <field name="section"/>
+                        <field name="parent_id" groups="base.group_extended" domain="[('group_id','=',group_id)]"/>
+                        <field name="section"/>                        
                     </group>
                     <notebook colspan="4">
                         <page string="Content">
                         <field name="text_area" nolabel="1" colspan="4" select="1" widget="text_wiki"/>
                         </page>
                     </notebook>
-                    <separator colspan="4" string="Modifications"/>
-                    <group col="4" colspan="4">
+                    <group col="2" colspan="2">
+                        <separator colspan="4" string="Modification Information"/>
                         <field name="write_date" readonly="1"/>
-                        <field name="review" select="1"/>
-                        <field name="tags" select="1" groups="base.group_extended"/>
-                        <field name="toc"/>
+                        <field name="minor_edit" groups="base.group_extended"/>
+                        <field name="review" select="1" groups="base.group_extended"/>
+                    </group>
+                    <group col="2" colspan="2">
+                        <separator colspan="4" string="Meta Information"/>
+                        <field name="tags" select="1"/>
+                        <field name="toc" groups="base.group_extended"/>
                     </group>
                 </form>
             </field>
         </record>
 
-    <!-- wiki Search view  -->
-
+        <!-- wiki Search view  -->
         <record id="view_wiki_filter" model="ir.ui.view">
             <field name="name">wiki.wiki.search</field>
             <field name="model">wiki.wiki</field>
             <field name="type">search</field>
             <field name="arch" type="xml">
                 <search string="Wiki">
-                    <filter icon="terp-check" string="Need Review" domain="[('review','=',True)]"/>
+                    <filter icon="terp-gtk-jump-to-ltr" string="Need Review" domain="[('review','=',True)]"/>
                     <separator orientation="vertical"/>
-                    <field name="section" select="1"/>
                     <field name="name" select="1"/>
                     <field name="group_id" select="1"/>
+                    <field name="tags" select="1"/>
+                    <field name="section" select="1" groups="base.group_extended"/>
                     <field name="write_uid" select="1"/>
                     <field name="write_date" select="1"/>
                     <newline/>
                     <group expand="0" string="Group By..." colspan="8" col="6">
-                        <filter icon="terp-check" string="Wiki Group" domain="[]" context="{'group_by':'group_id'}"/>
+                        <filter icon="terp-folder-blue" string="Wiki Group" domain="[]" context="{'group_by':'group_id'}"/>
                         <filter icon="terp-personal" string="Author" domain="[]" context="{'group_by':'create_uid'}"/>
-                        <filter icon="terp-personal-" string="Last Contributor" domain="[]" context="{'group_by':'write_uid'}"/>
+                        <filter icon="terp-personal+" string="Last Contributor" domain="[]" context="{'group_by':'write_uid'}"/>
                     </group>
                 </search>
             </field>
         </record>
 
-<!-- search page for wiki -->
-
+        <!-- search page for wiki -->
         <record model="ir.actions.act_window" id="action_wiki">
             <field name="name">Wiki Pages</field>
             <field name="res_model">wiki.wiki</field>
             id="menu_action_wiki_wiki" name="Wiki Pages"
             action="action_wiki" />
 
-<!--  Pages Waiting Review -->
-
+        <!--  Pages Waiting Review -->
         <record model="ir.actions.act_window" id="action_wiki_review">
             <field name="name">Pages Waiting Review</field>
             <field name="res_model">wiki.wiki</field>
             <field name="filter" eval="True"/>
         </record>
 
-<!-- History Tree view -->
-
+        <!-- History Tree view -->
         <record model="ir.ui.view" id="view_wiki_history_tree">
             <field name="name">wiki.wiki.history.tree</field>
             <field name="model">wiki.wiki.history</field>
             </field>
         </record>
 
-<!-- History Form view  -->
-
+        <!-- History Form view  -->
         <record model="ir.ui.view" id="wiki_history_form">
             <field name="name">wiki.wiki.history.form</field>
             <field name="model">wiki.wiki.history</field>
             </field>
         </record>
 
-<!-- History Action  -->
-
+        <!-- History Action  -->
         <record model="ir.actions.act_window" id="action_history">
             <field name="name">All Page Histories</field>
             <field name="res_model">wiki.wiki.history</field>