[IMP]: Convert buttons into stat button in purchase module
bzr revid: ypa@tinyerp.com-20140326124002-lj4wd30vd6hy5k9x
This commit is contained in:
parent
e264864ba1
commit
5e75ce212b
|
@ -150,6 +150,17 @@ class purchase_order(osv.osv):
|
|||
limit=1)
|
||||
return res and res[0] or False
|
||||
|
||||
def _count_all(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict(map(lambda x: (x,{'shipment_count': 0, 'invoice_count': 0,}), ids))
|
||||
try:
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
res[data.id] = {'shipment_count': len(data.picking_ids),
|
||||
'invoice_count': len(data.invoice_ids),
|
||||
}
|
||||
except:
|
||||
pass
|
||||
return res
|
||||
|
||||
STATE_SELECTION = [
|
||||
('draft', 'Draft PO'),
|
||||
('sent', 'RFQ Sent'),
|
||||
|
@ -226,6 +237,8 @@ class purchase_order(osv.osv):
|
|||
'create_uid': fields.many2one('res.users', 'Responsible'),
|
||||
'company_id': fields.many2one('res.company','Company',required=True,select=1, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal'),
|
||||
'shipment_count': fields.function(_count_all, type='integer', string='Incoming Shipments', multi=True),
|
||||
'invoice_count': fields.function(_count_all, type='integer', string='Invoices', multi=True)
|
||||
}
|
||||
_defaults = {
|
||||
'date_order': fields.date.context_today,
|
||||
|
|
|
@ -47,9 +47,17 @@
|
|||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button type="object"
|
||||
name="view_picking"
|
||||
string="Incoming Shipments" states="approved"/>
|
||||
class="oe_stat_button"
|
||||
icon="fa-truck"
|
||||
states="approved">
|
||||
<field name="shipment_count" widget="statinfo" string="Incoming Shipments"/>
|
||||
</button>
|
||||
<button type="object" name="invoice_open"
|
||||
string="Invoices" attrs="{'invisible': [('state', 'in', ['draft','sent'])]}"/>
|
||||
class="oe_stat_button"
|
||||
icon="fa-file-o"
|
||||
attrs="{'invisible': [('state', 'in', ['draft','sent'])]}">
|
||||
<field name="invoice_count" widget="statinfo" string="Invoices"/>
|
||||
</button>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue