bzr revid: apa@tinyerp.com-20120330115152-lj292dxh9ie12zj7
This commit is contained in:
Amit Patel (OpenERP) 2012-03-30 17:21:52 +05:30
commit e88de50eb8
2 changed files with 21 additions and 2 deletions

View File

@ -29,12 +29,28 @@ 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):
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
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")
}
_defaults = {
'timesheets' : True,
}
def onchange_partner_id(self, cr, uid, ids, part=False, context=None):
res = super(project_project, self).onchange_partner_id(cr, uid, ids, part, context)
if part and res and ('value' in res):

View File

@ -8,7 +8,8 @@
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='task']" position='after'>
<field name="timesheets"/>
<field name="timesheets"/>
<field name="to_amt_invoice" invisible="True"/>
</xpath>
<field name="warn_customer" position="after">
@ -33,6 +34,7 @@
<field name="timesheets"/>
<field name="total_hours"/>
<field name="effective_hours"/>
<field name="to_amt_invoice"/>
</field>
<xpath expr="//t[@t-name='tasks']" position="after">
<t t-name="timesheets">
@ -52,12 +54,13 @@
<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="amount_invoiced"/> <field name="currency_id"/></b></div>
<div class="manager"><b><field name="to_amt_invoice"/> <field name="currency_id"/></b></div>
</div>
<div class="sequence">
<kbd class="user">Rem. Hours</kbd>