add progress bar on purchase order tree view
bzr revid: hda@tinyerp.com-20080827112637-lvcujd4wdpted0ry
This commit is contained in:
parent
b8a0b23e64
commit
9e2c13ff15
|
@ -77,7 +77,7 @@ class purchase_order(osv.osv):
|
|||
|
||||
def _amount_total(self, cr, uid, ids, field_name, arg, context):
|
||||
res = {}
|
||||
untax = self._amount_untaxed(cr, uid, ids, field_name, arg, context)
|
||||
untax = self._amount_untaxed(cr, uid, ids, field_name, arg, context)
|
||||
tax = self._amount_tax(cr, uid, ids, field_name, arg, context)
|
||||
cur_obj=self.pool.get('res.currency')
|
||||
for id in ids:
|
||||
|
@ -86,6 +86,48 @@ class purchase_order(osv.osv):
|
|||
res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
|
||||
return res
|
||||
|
||||
def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for purchase in self.browse(cursor, user, ids, context=context):
|
||||
tot = 0.0
|
||||
|
||||
if purchase.invoice_id.state not in ('draft','cancel'):
|
||||
tot += purchase.invoice_id.amount_untaxed
|
||||
if tot:
|
||||
res[purchase.id] = tot * 100.0 / purchase.amount_untaxed
|
||||
else:
|
||||
res[purchase.id] = 0.0
|
||||
return res
|
||||
|
||||
def _shipped_rate(self, cr, uid, ids, name, arg, context=None):
|
||||
if not ids: return {}
|
||||
res = {}
|
||||
for id in ids:
|
||||
res[id] = [0.0,0.0]
|
||||
cr.execute('''SELECT
|
||||
p.purchase_id,sum(m.product_qty), m.state
|
||||
FROM
|
||||
stock_move m
|
||||
LEFT JOIN
|
||||
stock_picking p on (p.id=m.picking_id)
|
||||
WHERE
|
||||
p.purchase_id in ('''+','.join(map(str,ids))+''')
|
||||
GROUP BY m.state, p.purchase_id''')
|
||||
for oid,nbr,state in cr.fetchall():
|
||||
if state=='cancel':
|
||||
continue
|
||||
if state=='done':
|
||||
res[oid][0] += nbr or 0.0
|
||||
res[oid][1] += nbr or 0.0
|
||||
else:
|
||||
res[oid][1] += nbr or 0.0
|
||||
for r in res:
|
||||
if not res[r][1]:
|
||||
res[r] = 0.0
|
||||
else:
|
||||
res[r] = 100.0 * res[r][0] / res[r][1]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Order Reference', size=64, required=True, select=True),
|
||||
'origin': fields.char('Origin', size=64),
|
||||
|
@ -108,7 +150,9 @@ class purchase_order(osv.osv):
|
|||
'invoice_id': fields.many2one('account.invoice', 'Invoice', readonly=True),
|
||||
'picking_ids': fields.one2many('stock.picking', 'purchase_id', 'Picking List', readonly=True, help="This is the list of picking list that have been generated for this purchase"),
|
||||
'shipped':fields.boolean('Received', readonly=True, select=True),
|
||||
'shipped_rate': fields.function(_shipped_rate, method=True, string='Received', type='float'),
|
||||
'invoiced':fields.boolean('Invoiced & Paid', readonly=True, select=True),
|
||||
'invoiced_rate': fields.function(_invoiced_rate, method=True, string='Invoiced', type='float'),
|
||||
'invoice_method': fields.selection([('manual','Manual'),('order','From order'),('picking','From picking')], 'Invoicing Control', required=True),
|
||||
|
||||
'amount_untaxed': fields.function(_amount_untaxed, method=True, string='Untaxed Amount'),
|
||||
|
@ -164,7 +208,7 @@ class purchase_order(osv.osv):
|
|||
for id in ids:
|
||||
self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
|
||||
return True
|
||||
|
||||
|
||||
def wkf_warn_buyer(self, cr, uid, ids):
|
||||
self.write(cr, uid, ids, {'state' : 'wait', 'validator' : uid})
|
||||
request = pooler.get_pool(cr.dbname).get('res.request')
|
||||
|
@ -175,7 +219,7 @@ class purchase_order(osv.osv):
|
|||
if manager and not (manager.id in managers):
|
||||
managers.append(manager.id)
|
||||
for manager_id in managers:
|
||||
request.create(cr, uid,
|
||||
request.create(cr, uid,
|
||||
{'name' : "Purchase amount over the limit",
|
||||
'act_from' : uid,
|
||||
'act_to' : manager_id,
|
||||
|
@ -310,7 +354,7 @@ class purchase_order_line(osv.osv):
|
|||
cur = line.order_id.pricelist_id.currency_id
|
||||
res[line.id] = cur_obj.round(cr, uid, cur, line.price_unit * line.product_qty)
|
||||
return res
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64, required=True),
|
||||
'product_qty': fields.float('Quantity', required=True, digits=(16,2)),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<terp>
|
||||
<data>
|
||||
<menuitem icon="terp-purchase" id="menu_purchase_root" name="Purchase Management"/>
|
||||
|
||||
|
||||
<record id="purchase_order_form" model="ir.ui.view">
|
||||
<field name="name">purchase.order.form</field>
|
||||
<field name="model">purchase.order</field>
|
||||
|
@ -38,9 +38,9 @@
|
|||
<button name="purchase_appbuyer" states="wait_auth" string="Approve Purchase"/>
|
||||
<button name="purchase_approve" states="confirmed" string="Approved by Supplier"/>
|
||||
<button name="purchase_cancel" states="draft,confirmed,wait_auth" string="Cancel Purchase Order"/>
|
||||
|
||||
|
||||
<button name="purchase_cancel" states="approved" string="Cancel Purchase Order"/>
|
||||
|
||||
|
||||
<button name="shipping_ok" states="except_shipping" string="Shipping Done"/>
|
||||
<button name="invoice_ok" states="except_invoice" string="Invoice Done"/>
|
||||
</group>
|
||||
|
@ -60,7 +60,7 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="purchase_form_action" model="ir.actions.act_window">
|
||||
<field name="name">Purchase Orders</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
@ -107,7 +107,7 @@
|
|||
</record>
|
||||
<menuitem action="purchase_form_action_new" id="menu_purchase_form_action_new" parent="purchase.menu_purchase_root"/>
|
||||
|
||||
|
||||
|
||||
<record id="purchase_order_tree" model="ir.ui.view">
|
||||
<field name="name">purchase.order.tree</field>
|
||||
<field name="model">purchase.order</field>
|
||||
|
@ -118,15 +118,15 @@
|
|||
<field name="date_order"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="invoiced" string="Paid"/>
|
||||
<field name="shipped"/>
|
||||
<field name="invoiced_rate" widget="progressbar"/>
|
||||
<field name="shipped_rate" widget="progressbar"/>
|
||||
<field name="amount_untaxed"/>
|
||||
<field name="origin"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="purchase_order_line_form" model="ir.ui.view">
|
||||
<field name="name">purchase.order.line.form</field>
|
||||
<field name="model">purchase.order.line</field>
|
||||
|
@ -152,7 +152,7 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="purchase_order_line_tree" model="ir.ui.view">
|
||||
<field name="name">purchase.order.line.tree</field>
|
||||
<field name="model">purchase.order.line</field>
|
||||
|
@ -169,7 +169,7 @@
|
|||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<act_window context="{'partner_id': active_id}" domain="[('partner_id', '=', active_id)]" id="act_res_partner_2_purchase_order" name="Purchase orders" res_model="purchase.order" src_model="res.partner"/>
|
||||
</data>
|
||||
</terp>
|
||||
|
|
|
@ -124,7 +124,6 @@ class sale_order(osv.osv):
|
|||
res[oid][1] += nbr or 0.0
|
||||
else:
|
||||
res[oid][1] += nbr or 0.0
|
||||
print res
|
||||
for r in res:
|
||||
if not res[r][1]:
|
||||
res[r] = 0.0
|
||||
|
|
Loading…
Reference in New Issue