openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #03520
[Merge] lp:~camptocamp/contract-management/hours_block_vre into lp:contract-management
Matthieu Dietrich @ camptocamp has proposed merging lp:~camptocamp/contract-management/hours_block_vre into lp:contract-management.
Requested reviews:
Contract Management Core Editors (contract-management-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/contract-management/hours_block_vre/+merge/205116
A few developments on contract management (department in hours block, button to add an hours block in project).
--
https://code.launchpad.net/~camptocamp/contract-management/hours_block_vre/+merge/205116
Your team Contract Management Core Editors is requested to review the proposed merge of lp:~camptocamp/contract-management/hours_block_vre into lp:contract-management.
=== modified file 'analytic_hours_block/__init__.py'
--- analytic_hours_block/__init__.py 2012-12-17 12:31:50 +0000
+++ analytic_hours_block/__init__.py 2014-02-06 10:32:26 +0000
@@ -20,3 +20,4 @@
##############################################################################
import hours_block
import report
+import project
\ No newline at end of file
=== modified file 'analytic_hours_block/__openerp__.py'
--- analytic_hours_block/__openerp__.py 2014-01-08 11:55:30 +0000
+++ analytic_hours_block/__openerp__.py 2014-02-06 10:32:26 +0000
@@ -40,12 +40,14 @@
"depends": [
"account",
"hr_timesheet_invoice",
- "analytic"
+ "analytic",
+ "project",
],
"data": [
"hours_block_view.xml",
"hours_block_data.xml",
"hours_block_menu.xml",
+ "project_view.xml",
"report.xml",
"security/hours_block_security.xml",
"security/ir.model.access.csv",
=== modified file 'analytic_hours_block/hours_block.py'
--- analytic_hours_block/hours_block.py 2014-01-31 14:45:54 +0000
+++ analytic_hours_block/hours_block.py 2014-02-06 10:32:26 +0000
@@ -335,6 +335,14 @@
string="Total",
store=True,
readonly=True),
+ 'department_id': fields.related(
+ 'invoice_id', 'department_id',
+ type='many2one',
+ relation='hr.department',
+ string='Department',
+ store=True,
+ readonly=True),
+
'state': fields.related(
'invoice_id', 'state',
type='selection',
=== modified file 'analytic_hours_block/hours_block_menu.xml'
--- analytic_hours_block/hours_block_menu.xml 2012-12-17 15:37:44 +0000
+++ analytic_hours_block/hours_block_menu.xml 2014-02-06 10:32:26 +0000
@@ -6,6 +6,7 @@
Hours block menu
-->
<record model="ir.actions.act_window" id="action_all_block_hour">
+ <field name="context">{'search_default_running': 1, 'search_default_group_department_id': 1}</field>
<field name="name">Hours Blocks</field>
<field name="res_model">account.hours.block</field>
<field name="view_type">form</field>
=== modified file 'analytic_hours_block/hours_block_view.xml'
--- analytic_hours_block/hours_block_view.xml 2014-01-08 11:55:30 +0000
+++ analytic_hours_block/hours_block_view.xml 2014-02-06 10:32:26 +0000
@@ -18,15 +18,18 @@
<separator orientation="vertical"/>
<field name="number"/>
<field name="partner_id"/>
+ <field name="department_id" string="Department"/>
<field name="user_id" select="1" widget="selection" string="Salesman">
<filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/>
</field>
+
<field name="company_id" widget="selection"/>
</group>
<newline/>
<group expand="0" string="Group By...">
<filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
<filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
+ <filter string="Department" icon="terp-personal" domain="[]" context="{'group_by':'department_id'}"/>
<filter string="Invoice State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
</group>
</search>
@@ -41,6 +44,8 @@
<field name="model">account.hours.block</field>
<field name="arch" type="xml">
<form string="Hours Blocks" version="7.0">
+ <label for="type" string="Based on:" class="oe_inline"/>
+ <field name="type" class="oe_inline"/>
<header>
<button name="action_send_block" type="object" string="Send by Email" class="oe_highlight"/>
</header>
@@ -71,6 +76,7 @@
<field name="partner_id" groups="base.group_user"/>
<field name="user_id"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
+ <field name="department_id" widget="selection"/>
<field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1" groups="account.group_account_user"/>
@@ -108,6 +114,7 @@
<field name="journal_id" invisible="1"/>
<field name="period_id" invisible="1" groups="account.group_account_user"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
+ <field name="department_id" widget="selection"/>
<field name="user_id"/>
<field name="currency_id"/>
<field name="residual" sum="Residual Amount"/>
=== added file 'analytic_hours_block/project.py'
--- analytic_hours_block/project.py 1970-01-01 00:00:00 +0000
+++ analytic_hours_block/project.py 2014-02-06 10:32:26 +0000
@@ -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,
+ }
=== added file 'analytic_hours_block/project_view.xml'
--- analytic_hours_block/project_view.xml 1970-01-01 00:00:00 +0000
+++ analytic_hours_block/project_view.xml 2014-02-06 10:32:26 +0000
@@ -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>