[IMP] change related button into stat for account,project

bzr revid: rma@tinyerp.com-20140325124531-kkwm1v8bhndzs846
This commit is contained in:
Randhir Mayatra rma-openerp 2014-03-25 18:15:31 +05:30
parent 96ea9392aa
commit 3caf591550
10 changed files with 60 additions and 33 deletions

View File

@ -1532,7 +1532,9 @@
<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>

View 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)]}),

View 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"/>
@ -117,9 +119,9 @@
<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')]}"/>

View 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"/>
@ -292,7 +292,7 @@
<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>

View File

@ -200,9 +200,9 @@
<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>

View File

@ -14,15 +14,15 @@
</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">

View 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',

View File

@ -152,7 +152,11 @@
<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>

View 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"),
}

View File

@ -74,13 +74,15 @@
<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>