[IMP] change related button into stat for account,project
authorRandhir Mayatra rma-openerp <rma@tinyerp.com>
Tue, 25 Mar 2014 12:45:31 +0000 (18:15 +0530)
committerRandhir Mayatra rma-openerp <rma@tinyerp.com>
Tue, 25 Mar 2014 12:45:31 +0000 (18:15 +0530)
bzr revid: rma@tinyerp.com-20140325124531-kkwm1v8bhndzs846

addons/account/account_view.xml
addons/account_asset/account_asset.py
addons/account_asset/account_asset_view.xml
addons/account_payment/account_payment_view.xml
addons/account_voucher/account_voucher_view.xml
addons/email_template/email_template_view.xml
addons/project_long_term/project_long_term.py
addons/project_long_term/project_long_term_view.xml
addons/purchase/partner.py
addons/purchase/partner_view.xml

index 48d6320..562cd62 100644 (file)
                     <field name="lines_id" widget="one2many_list"/>
                     <separator string="Legend"/>
                     <field name="legend"/>
-                    <button name="%(action_account_use_model_create_entry)d" string="Create entries" type="action" icon="gtk-execute"/>
+                    <div class="oe_button_box">
+                        <button class="oe_inline oe_button_box oe_stat_button" name="%(action_account_use_model_create_entry)d" string="Create entries" type="action" icon="fa-cogs" widget="statinfo"/>
+                    </div>
                 </form>
             </field>
         </record>
index f4e5d17..6552281 100644 (file)
@@ -237,9 +237,17 @@ class account_asset_asset(osv.osv):
             if salvage_value:
                 val['value_residual'] = purchase_value - salvage_value
         return {'value': val}    
-
+    def _entry_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for entry in self.browse(cr, uid, ids, context=context):
+                res[entry.id] = len(entry.account_move_line_ids)
+        except:
+            pass
+        return res
     _columns = {
         'account_move_line_ids': fields.one2many('account.move.line', 'asset_id', 'Entries', readonly=True, states={'draft':[('readonly',False)]}),
+        'entry_count': fields.function(_entry_count, string='# Asset Entries', type='integer'),
         'name': fields.char('Asset Name', size=64, required=True, readonly=True, states={'draft':[('readonly',False)]}),
         'code': fields.char('Reference', size=32, readonly=True, states={'draft':[('readonly',False)]}),
         'purchase_value': fields.float('Gross Value', required=True, readonly=True, states={'draft':[('readonly',False)]}),
index fe1fcf4..40d99af 100644 (file)
@@ -84,7 +84,9 @@
                 </header>
                 <sheet>
                     <div class="oe_button_box oe_right">
-                        <button name="open_entries" string="Entries" type="object" class="oe_inline"/>
+                        <button class="oe_inline oe_stat_button" name="open_entries"  type="object" icon="fa-pencil-square-o">
+                        <field string="Entries" name="entry_count" widget="statinfo" />
+                    </button>
                     </div>
                     <div class="oe_title">
                         <label for="name" class="oe_edit_only"/>
                                     <field name="method"/>
                                     <field name="method_progress_factor" attrs="{'invisible':[('method','=','linear')], 'required':[('method','=','degressive')]}"/>
                                     <label for="method_time"/>
-                                    <div>
+                                    <div class="oe_button_box">
                                         <field name="method_time" on_change="onchange_method_time(method_time)" class="oe_inline"/>
-                                        <button name="%(action_asset_modify)d" states="open" string="Change Duration" type="action" icon="terp-stock_effects-object-colorize" class="oe_inline" colspan="1"/>
+                                        <button name="%(action_asset_modify)d" states="open" string="Change Duration" type="action" icon="fa-cogs" class="oe_inline oe_stat_button" colspan="1" widget="statinfo"/>
                                     </div>
                                     <field name="prorata" attrs="{'invisible': [('method_time','=','end')]}"/>
                                     <field name="method_number" attrs="{'invisible':[('method_time','=','end')], 'required':[('method_time','=','number')]}"/>
index e49d6df..4de42a5 100644 (file)
@@ -70,8 +70,8 @@
                 </header>
                 <sheet string="Payment order">
                     <div class="oe_button_box">
-                        <button name="%(action_create_payment_order)d" string="Select Invoices to Pay"
-                               type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/>
+                        <button class="oe_inline oe_stat_button oe_right" name="%(action_create_payment_order)d" string="Select Invoices to Pay"
+                               type="action" attrs="{'invisible':[('state','=','done')]}" icon="fa-search" widget="statinfo"/>
                     </div>
                     <div class="oe_title">
                         <label for="reference" class="oe_edit_only"/>
             <field name="inherit_id" ref="account.view_bank_statement_form"/>
             <field name="arch" type="xml">
                    <xpath expr="//div[@name='import_buttons']" position="inside">
-                       <button name="%(action_account_populate_statement_confirm)d" attrs="{'invisible':[('state','=','confirm')]}" string="Import Payment Lines" type="action" icon="gtk-execute"/>
+                       <button class="oe_inline oe_stat_button" name="%(action_account_populate_statement_confirm)d" attrs="{'invisible':[('state','=','confirm')]}" string="Import Payment Lines" type="action" icon="fa-cogs" widget="statinfo"/>
                    </xpath>
             </field>
         </record>
index 288f8ce..aae4d5d 100644 (file)
             <field name="inherit_id" ref="account.view_bank_statement_form"/>
             <field name="arch" type="xml">
                 <xpath expr="//div[@name='import_buttons']" position="inside">
-                    <button name="%(action_view_account_statement_from_invoice_lines)d"
+                    <button class="oe_inline oe_stat_button" name="%(action_view_account_statement_from_invoice_lines)d"
                             string="Import Invoices" type="action"
-                            attrs="{'invisible':[('state','=','confirm')]}"/>
+                            attrs="{'invisible':[('state','=','confirm')]}" widget="statinfo" icon="fa-pencil-square-o"/>
                 </xpath>
             </field>
         </record>
index 4f7828c..dfa2697 100644 (file)
                         </div>
                         <div class="oe_right oe_button_box" name="buttons">
                             <field name="ref_ir_act_window" invisible="1"/>
-                            <button name="create_action" string="Add context action" type="object"
-                                    attrs="{'invisible':[('ref_ir_act_window','!=',False)]}"
-                                    help="Display an option on related documents to open a composition wizard with this template"/>
+                            <button class="oe_inline oe_stat_button" name="create_action" string="Add context action" type="object"
+                                    attrs="{'invisible':[('ref_ir_act_window','!=',False)]}" icon="fa-adn"
+                                    help="Display an option on related documents to open a composition wizard with this template" widget="statinfo"/>
                             <button name="unlink_action" string="Remove context action" type="object" 
                                     attrs="{'invisible':[('ref_ir_act_window','=',False)]}"
                                     help="Remove the contextual action to use this template on related documents"/>
-                            <button name="%(wizard_email_template_preview)d" string="Preview"
+                            <button class="oe_inline oe_stat_button" name="%(wizard_email_template_preview)d" icon="fa-search-plus" string="Preview"
                                     type="action" target="new"
-                                    context="{'template_id':active_id}"/>
+                                    context="{'template_id':active_id}" widget="statinfo"/>
                         </div>
                         <notebook>
                             <page string="Mailing Template">
index a950907..aee4f66 100644 (file)
@@ -98,7 +98,14 @@ class project_phase(osv.osv):
             else:
                 res[phase.id] = round(100.0 * done / tot, 2)
         return res
-
+    def _tasks_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for task in self.browse(cr, uid, ids, context=context):
+                res[task.id] = len(task.task_ids)
+        except:
+            pass
+        return res
     _columns = {
         'name': fields.char("Name", size=64, required=True),
         'date_start': fields.datetime('Start Date', select=True, help="It's computed by the scheduler according the project date or the end date of the previous phase.", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
@@ -119,6 +126,7 @@ class project_phase(osv.osv):
                                   help='If the phase is created the status \'Draft\'.\n If the phase is started, the status becomes \'In Progress\'.\n If review is needed the phase is in \'Pending\' status.\
                                   \n If the phase is over, the status is set to \'Done\'.'),
         'progress': fields.function(_compute_progress, string='Progress', help="Computed based on related tasks"),
+        'tasks_count': fields.function(_tasks_count, string='# Related Tasks', type='integer'),
      }
     _defaults = {
         'state': 'draft',
index d6b118e..9e4b11c 100644 (file)
                     <field name="state" widget="statusbar" statusbar_visible="draft,open,done" statusbar_colors='{"pending":"blue"}'/>
                 </header>
                 <sheet>
-                    <button name="%(project_phase_task_list)d" string="Related Tasks" type="action" class="oe_right"/>
+                    <div class="oe_button_box oe_right">
+                    <button class=" oe_inline oe_stat_button " name= "%(project_phase_task_list)d" type="action" icon="fa-tasks">
+                        <field string="Related Tasks" name="tasks_count" widget="statinfo"/>
+                    </button>
+                    </div>
                     <div class="oe_title">
                         <label for="name" class="oe_edit_only"/>
                         <h1><field name="name"/></h1>
index d8cda9b..b7757c2 100644 (file)
@@ -26,15 +26,14 @@ class res_partner(osv.osv):
     _inherit = 'res.partner'
 
     def _purchase_order_count(self, cr, uid, ids, field_name, arg, context=None):
-        res = dict(map(lambda x: (x,0), ids))
-        # this user may not have access to user rights
-        try:
-            for partner in self.browse(cr, uid, ids, context=context):
-                res[partner.id] = len(partner.purchase_order_ids)
-        except:
-            pass
+        res = dict(map(lambda x: (x,{'purchase_order_count': 0, 'supplier_invoice_count': 0}), ids))
+        invoice_ids = self.pool.get('account.invoice').search(cr,uid, [('type', '=', 'in_invoice'), ('partner_id', '=', ids[0])])
+        for partner in self.browse(cr, uid, ids, context=context):
+            res[partner.id] = {
+                    'purchase_order_count': len(partner.purchase_order_ids),
+                    'supplier_invoice_count': len(invoice_ids),
+                }
         return res
-
     def copy(self, cr, uid, id, default=None, context=None):
         if default is None:
             default = {}
@@ -53,8 +52,10 @@ class res_partner(osv.osv):
           domain=[('type','=','purchase')],
           string="Purchase Pricelist", 
           help="This pricelist will be used, instead of the default one, for purchases from the current partner"),
-        'purchase_order_count': fields.function(_purchase_order_count, string='# of Purchase Order', type='integer'),
-        'purchase_order_ids': fields.one2many('purchase.order','partner_id','Purchase Order')
+        'purchase_order_count': fields.function(_purchase_order_count, string='# of Purchase Order', type='integer', multi="count"),
+        'purchase_order_ids': fields.one2many('purchase.order','partner_id','Purchase Order'),
+        'invoice_ids': fields.one2many('account.invoice','partner_id','Supplier Invoices'),
+        'supplier_invoice_count': fields.function(_purchase_order_count, string='# Supplier Invoices', type='integer', multi="count"),
     }
 
 
index 25aeb3d..77fe49a 100644 (file)
             <field name="priority" eval="20"/>
             <field name="arch" type="xml">
                 <xpath expr="//div[@name='buttons']" position="inside">
-                    <button name="%(purchase.act_res_partner_2_purchase_order)d" type="action"
-                        string="Purchase Orders"
+                    <button class="oe_inline oe_stat_button" name="%(purchase.act_res_partner_2_purchase_order)d" type="action"
                         attrs="{'invisible': [('supplier', '=', False)]}"
-                        groups="purchase.group_purchase_user"/>
-                    <button name="%(purchase.act_res_partner_2_supplier_invoices)d" type="action"
-                        attrs="{'invisible': [('supplier', '=', False)]}"
-                        string="Supplier Invoices"/>
+                        groups="purchase.group_purchase_user" icon="fa-list-alt">
+                        <field string="Purchase Orders" name="purchase_order_count" widget="statinfo"/>
+                    </button>
+                    <button class="oe_inline oe_stat_button" name="%(purchase.act_res_partner_2_supplier_invoices)d" type="action"
+                        attrs="{'invisible': [('supplier', '=', False)]}" icon="fa-pencil-square-o">
+                        <field string="Supplier Invoices" name="supplier_invoice_count" widget="statinfo"/>
+                    </button>
                 </xpath>
             </field>
         </record>