Browse Source
analytic_hours_block improvements:
analytic_hours_block improvements:
[ADD] a new field for the department, which is filterable/searchable, [ADD] a new button in the form view in order to display the hours block related to a project.pull/2/head
unknown
11 years ago
committed by
Yannick Vaucher
7 changed files with 135 additions and 14 deletions
-
1analytic_hours_block/__init__.py
-
6analytic_hours_block/__openerp__.py
-
84analytic_hours_block/hours_block.py
-
1analytic_hours_block/hours_block_menu.xml
-
5analytic_hours_block/hours_block_view.xml
-
33analytic_hours_block/project.py
-
19analytic_hours_block/project_view.xml
@ -0,0 +1,33 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from osv import orm |
||||
|
from openerp.tools.translate import _ |
||||
|
|
||||
|
|
||||
|
class project_project(orm.Model): |
||||
|
_inherit = 'project.project' |
||||
|
|
||||
|
def hours_block_tree_view(self, cr, uid, ids, context): |
||||
|
invoice_line_obj = self.pool.get('account.invoice.line') |
||||
|
hours_block_obj = self.pool.get('account.hours.block') |
||||
|
project = self.browse(cr, uid , ids)[0] |
||||
|
invoice_line_ids = invoice_line_obj.search(cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)]) |
||||
|
invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids) |
||||
|
invoice_ids = [x.invoice_id.id for x in invoice_lines] |
||||
|
res_ids = hours_block_obj.search(cr, uid, [('invoice_id','in',invoice_ids)]) |
||||
|
domain=False |
||||
|
if res_ids: |
||||
|
domain = [('id', 'in', res_ids)] |
||||
|
else: |
||||
|
raise orm.except_orm(_('Warning'), _("No Hours Block for this project")) |
||||
|
|
||||
|
return { |
||||
|
'name': _('Hours Blocks'), |
||||
|
'domain': domain, |
||||
|
'res_model': 'account.hours.block', |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'view_id': False, |
||||
|
'view_mode': 'tree,form', |
||||
|
'view_type': 'form', |
||||
|
'limit': 80, |
||||
|
'res_id' : res_ids or False, |
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
<?xml version="1.0" ?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<record model="ir.ui.view" id="edit_project_hours_block_link"> |
||||
|
<field name="name">project.project.form.hours.block.link</field> |
||||
|
<field name="model">project.project</field> |
||||
|
<field name="inherit_id" ref="project.edit_project"/> |
||||
|
<field name="type">form</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//button[@name='attachment_tree_view']" position="after"> |
||||
|
<button name="hours_block_tree_view" string="Hours Block" type="object"/> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue