summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Patel (OpenERP) <apa@tinyerp.com>2012-03-30 17:34:11 +0530
committerAmit Patel (OpenERP) <apa@tinyerp.com>2012-03-30 17:34:11 +0530
commit53e1f2a4272a2f6db524ae4eaa54ea0c9da7325f (patch)
treecdff5fa570c73b0e408120bbe075c4fefa5f050c
parente88de50eb8931eb75ef4fc92cdc351811c1e8603 (diff)
[IMP]
bzr revid: apa@tinyerp.com-20120330120411-ddorwd83ocdb2qsw
-rw-r--r--addons/project_timesheet/project_timesheet.py24
-rw-r--r--addons/project_timesheet/project_timesheet_view.xml7
2 files changed, 14 insertions, 17 deletions
diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py
index 1783d871334..0a9cb910b45 100644
--- a/addons/project_timesheet/project_timesheet.py
+++ b/addons/project_timesheet/project_timesheet.py
@@ -29,23 +29,21 @@ from tools.translate import _
class project_project(osv.osv):
_inherit = 'project.project'
- def _amt_to_invoiced(self, cr, uid, ids,field_name, arg, context=None):
+ def _amt_to_invoice(self, cr, uid, ids,field_name, arg, context=None):
res = {}
- task_pool=self.pool.get('project.task')
- for id in ids:
- task_ids = task_pool.search(cr, uid, [('project_id', '=', id)])
- total = 0.0
- project_record = self.browse(cr,uid,id)
- acc_model = self.pool.get("account.analytic.line")
- acc_id = acc_model.search(cr, uid, [('account_id', '=', project_record.analytic_account_id.id),('to_invoice', '=', 1),('invoice_id', '=', False)])
- if acc_id:
- for record in acc_model.browse(cr,uid,acc_id):
- total += record.amount
- res[id]= total
+ aal_pool = self.pool.get("account.analytic.line")
+ for project in self.browse(cr,uid,ids,context=context):
+ line_ids = aal_pool.search(cr, uid, [('account_id','=',project.analytic_account_id.id),('to_invoice','=',1),('invoice_id','=',False)])
+ amt_to_invoice = 0.0
+ if line_ids:
+ for line in aal_pool.browse(cr,uid,line_ids,context=context):
+ amt_to_invoice += line.amount
+ res[project.id] = (amt_to_invoice)*-1
return res
+
_columns = {
'timesheets' : fields.boolean('Timesheets',help = "If you check this field timesheets appears in kanban view"),
- 'to_amt_invoice': fields.function(_amt_to_invoiced,string="Open Tasks")
+ 'amt_to_invoice': fields.function(_amt_to_invoice,string="Amount to Invoice")
}
_defaults = {
'timesheets' : True,
diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml
index 3be2a8437ac..a20400c6f2e 100644
--- a/addons/project_timesheet/project_timesheet_view.xml
+++ b/addons/project_timesheet/project_timesheet_view.xml
@@ -9,7 +9,7 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='task']" position='after'>
<field name="timesheets"/>
- <field name="to_amt_invoice" invisible="True"/>
+ <field name="amt_to_invoice" invisible="True"/>
</xpath>
<field name="warn_customer" position="after">
@@ -34,7 +34,7 @@
<field name="timesheets"/>
<field name="total_hours"/>
<field name="effective_hours"/>
- <field name="to_amt_invoice"/>
+ <field name="amt_to_invoice"/>
</field>
<xpath expr="//t[@t-name='tasks']" position="after">
<t t-name="timesheets">
@@ -54,13 +54,12 @@
<t t-if="record.timesheets.raw_value">
<button name="open_timesheets" class="oe_project_buttons" type="object" tooltip="timesheets"><img src="/project_timesheet/static/src/img/timesheet_icon.png" class="project_icon"/></button>
</t>
- <t t-esc = "to_amt_invoice"/>
</xpath>
<xpath expr="//td[@class='td_name']" position="after">
<td class="td_deadline">
<div class="sequence">
<kbd class="user">To invoice</kbd>
- <div class="manager"><b><field name="to_amt_invoice"/> <field name="currency_id"/></b></div>
+ <div class="manager"><b><field name="amt_to_invoice"/> <field name="currency_id"/></b></div>
</div>
<div class="sequence">
<kbd class="user">Rem. Hours</kbd>