Merge lp:~camptocamp/contract-management/hours_block_vre into lp:~contract-management-core-editors/contract-management/7.0

Proposed by Matthieu Dietrich @ camptocamp
Status: Merged
Merged at revision: 12
Proposed branch: lp:~camptocamp/contract-management/hours_block_vre
Merge into: lp:~contract-management-core-editors/contract-management/7.0
Diff against target: 303 lines (+135/-13)
7 files modified
analytic_hours_block/__init__.py (+1/-0)
analytic_hours_block/__openerp__.py (+4/-1)
analytic_hours_block/hours_block.py (+72/-12)
analytic_hours_block/hours_block_menu.xml (+1/-0)
analytic_hours_block/hours_block_view.xml (+5/-0)
analytic_hours_block/project.py (+33/-0)
analytic_hours_block/project_view.xml (+19/-0)
To merge this branch: bzr merge lp:~camptocamp/contract-management/hours_block_vre
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Yannick Vaucher @ Camptocamp code review, no test Approve
Review via email: mp+205212@code.launchpad.net

Description of the change

- a new field for the department, which is filterable/searchable,
- a new button in the form view in order to display the hours block related to a project.

To post a comment you must log in.
9. By Lorenzo Battistini

[FIX] Can't install analytic_hours_block

10. By Daniel Reis

New project_sla module

Revision history for this message
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote :

To expand a bit: this MP is to add 2 things related to hours block:
- a new field for the department, which is filterable/searchable,
- a new button in the project form view, in order to get the hours block related to a project.

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

If department is changed in invoice the related field won't be updated.

Please set the proper store triggers.

Cheers,

review: Needs Fixing
11. By Matthieu Dietrich @ camptocamp

[FIX] fixed conflict with latest version + modified store conditions for related fields

Revision history for this message
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote :

I fixed the store fields (not only department_id; other related() as well) to be refreshed if the distant field is modified.

Regards,
Matthieu

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Well done Thanks

LGTM

review: Approve (code review, no test)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

42 + 'account.hours.block': (lambda self, cr, uid, ids, c=None:
43 + ids, ['invoice_id'], 10),

this is a very bad line split, please keep the 'ids' on the same line as the lambda

missing i18n update

review: Needs Fixing (code review, no test)
12. By Matthieu Dietrich @ camptocamp

[FIX] reformatting

Revision history for this message
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote :

@afayolle: thanks, I re-formatted it now.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) :
review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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-04-02 14:53:22 +0000
@@ -20,3 +20,4 @@
20##############################################################################20##############################################################################
21import hours_block21import hours_block
22import report22import report
23import project
23\ No newline at end of file24\ No newline at end of file
2425
=== modified file 'analytic_hours_block/__openerp__.py'
--- analytic_hours_block/__openerp__.py 2014-02-17 08:33:04 +0000
+++ analytic_hours_block/__openerp__.py 2014-04-02 14:53:22 +0000
@@ -40,13 +40,16 @@
40 "depends": [40 "depends": [
41 "account",41 "account",
42 "hr_timesheet_invoice",42 "hr_timesheet_invoice",
43 "analytic"43 "analytic",
44 "project",
44 ],45 ],
45 "data": [46 "data": [
46 "report.xml",47 "report.xml",
47 "hours_block_view.xml",48 "hours_block_view.xml",
48 "hours_block_data.xml",49 "hours_block_data.xml",
49 "hours_block_menu.xml",50 "hours_block_menu.xml",
51 "project_view.xml",
52 "report.xml",
50 "security/hours_block_security.xml",53 "security/hours_block_security.xml",
51 "security/ir.model.access.csv",54 "security/ir.model.access.csv",
52 ],55 ],
5356
=== 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-04-02 14:53:22 +0000
@@ -267,74 +267,130 @@
267 'invoice_id', 'date_invoice',267 'invoice_id', 'date_invoice',
268 type="date",268 type="date",
269 string="Invoice Date",269 string="Invoice Date",
270 store=True,270 store={
271 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
272 ['invoice_id'], 10),
273 'account.invoice': (_get_invoice, ['date_invoice'], 10),
274 },
271 readonly=True),275 readonly=True),
272 'user_id': fields.related(276 'user_id': fields.related(
273 'invoice_id', 'user_id',277 'invoice_id', 'user_id',
274 type="many2one",278 type="many2one",
275 relation="res.users",279 relation="res.users",
276 string="Salesman",280 string="Salesman",
277 store=True,281 store={
282 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
283 ['invoice_id'], 10),
284 'account.invoice': (_get_invoice, ['user_id'], 10),
285 },
278 readonly=True),286 readonly=True),
279 'partner_id': fields.related(287 'partner_id': fields.related(
280 'invoice_id', 'partner_id',288 'invoice_id', 'partner_id',
281 type="many2one",289 type="many2one",
282 relation="res.partner",290 relation="res.partner",
283 string="Partner",291 string="Partner",
284 store=True,292 store={
293 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
294 ['invoice_id'], 10),
295 'account.invoice': (_get_invoice, ['partner_id'], 10),
296 },
285 readonly=True),297 readonly=True),
286 'name': fields.related(298 'name': fields.related(
287 'invoice_id', 'name',299 'invoice_id', 'name',
288 type="char",300 type="char",
289 string="Description",301 string="Description",
290 store=True,302 store={
303 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
304 ['invoice_id'], 10),
305 'account.invoice': (_get_invoice, ['name'], 10),
306 },
291 readonly=True),307 readonly=True),
292 'number': fields.related(308 'number': fields.related(
293 'invoice_id', 'number',309 'invoice_id', 'number',
294 type="char",310 type="char",
295 string="Number",311 string="Number",
296 store=True,312 store={
313 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
314 ['invoice_id'], 10),
315 'account.invoice': (_get_invoice, ['number'], 10),
316 },
297 readonly=True),317 readonly=True),
298 'journal_id': fields.related(318 'journal_id': fields.related(
299 'invoice_id', 'journal_id',319 'invoice_id', 'journal_id',
300 type="many2one",320 type="many2one",
301 relation="account.journal",321 relation="account.journal",
302 string="Journal",322 string="Journal",
303 store=True,323 store={
324 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
325 ['invoice_id'], 10),
326 'account.invoice': (_get_invoice, ['journal_id'], 10),
327 },
304 readonly=True),328 readonly=True),
305 'period_id': fields.related(329 'period_id': fields.related(
306 'invoice_id', 'period_id',330 'invoice_id', 'period_id',
307 type="many2one",331 type="many2one",
308 relation="account.period",332 relation="account.period",
309 string="Period",333 string="Period",
310 store=True,334 store={
335 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
336 ['invoice_id'], 10),
337 'account.invoice': (_get_invoice, ['period_id'], 10),
338 },
311 readonly=True),339 readonly=True),
312 'company_id': fields.related(340 'company_id': fields.related(
313 'invoice_id', 'company_id',341 'invoice_id', 'company_id',
314 type="many2one",342 type="many2one",
315 relation="res.company",343 relation="res.company",
316 string="Company",344 string="Company",
317 store=True,345 store={
346 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
347 ['invoice_id'], 10),
348 'account.invoice': (_get_invoice, ['company_id'], 10),
349 },
318 readonly=True),350 readonly=True),
319 'currency_id': fields.related(351 'currency_id': fields.related(
320 'invoice_id', 'currency_id',352 'invoice_id', 'currency_id',
321 type="many2one",353 type="many2one",
322 relation="res.currency",354 relation="res.currency",
323 string="Currency",355 string="Currency",
324 store=True,356 store={
357 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
358 ['invoice_id'], 10),
359 'account.invoice': (_get_invoice, ['currency_id'], 10),
360 },
325 readonly=True),361 readonly=True),
326 'residual': fields.related(362 'residual': fields.related(
327 'invoice_id', 'residual',363 'invoice_id', 'residual',
328 type="float",364 type="float",
329 string="Residual",365 string="Residual",
330 store=True,366 store={
367 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
368 ['invoice_id'], 10),
369 'account.invoice': (_get_invoice, ['residual'], 10),
370 },
331 readonly=True),371 readonly=True),
332 'amount_total': fields.related(372 'amount_total': fields.related(
333 'invoice_id', 'amount_total',373 'invoice_id', 'amount_total',
334 type="float",374 type="float",
335 string="Total",375 string="Total",
336 store=True,376 store={
377 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
378 ['invoice_id'], 10),
379 'account.invoice': (_get_invoice, ['amount_total'], 10),
380 },
337 readonly=True),381 readonly=True),
382 'department_id': fields.related(
383 'invoice_id', 'department_id',
384 type='many2one',
385 relation='hr.department',
386 string='Department',
387 store={
388 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
389 ['invoice_id'], 10),
390 'account.invoice': (_get_invoice, ['department_id'], 10),
391 },
392 readonly=True),
393
338 'state': fields.related(394 'state': fields.related(
339 'invoice_id', 'state',395 'invoice_id', 'state',
340 type='selection',396 type='selection',
@@ -348,7 +404,11 @@
348 ],404 ],
349 string='State',405 string='State',
350 readonly=True,406 readonly=True,
351 store=True),407 store={
408 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids,
409 ['invoice_id'], 10),
410 'account.invoice': (_get_invoice, ['state'], 10),
411 }),
352 }412 }
353413
354414
355415
=== 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-04-02 14:53:22 +0000
@@ -6,6 +6,7 @@
6 Hours block menu6 Hours block menu
7 -->7 -->
8 <record model="ir.actions.act_window" id="action_all_block_hour">8 <record model="ir.actions.act_window" id="action_all_block_hour">
9 <field name="context">{'search_default_running': 1, 'search_default_group_department_id': 1}</field>
9 <field name="name">Hours Blocks</field>10 <field name="name">Hours Blocks</field>
10 <field name="res_model">account.hours.block</field>11 <field name="res_model">account.hours.block</field>
11 <field name="view_type">form</field>12 <field name="view_type">form</field>
1213
=== 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-04-02 14:53:22 +0000
@@ -18,15 +18,18 @@
18 <separator orientation="vertical"/>18 <separator orientation="vertical"/>
19 <field name="number"/>19 <field name="number"/>
20 <field name="partner_id"/>20 <field name="partner_id"/>
21 <field name="department_id" string="Department"/>
21 <field name="user_id" select="1" widget="selection" string="Salesman">22 <field name="user_id" select="1" widget="selection" string="Salesman">
22 <filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/>23 <filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/>
23 </field>24 </field>
25
24 <field name="company_id" widget="selection"/>26 <field name="company_id" widget="selection"/>
25 </group>27 </group>
26 <newline/>28 <newline/>
27 <group expand="0" string="Group By...">29 <group expand="0" string="Group By...">
28 <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>30 <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
29 <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>31 <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
32 <filter string="Department" icon="terp-personal" domain="[]" context="{'group_by':'department_id'}"/>
30 <filter string="Invoice State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>33 <filter string="Invoice State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
31 </group>34 </group>
32 </search>35 </search>
@@ -71,6 +74,7 @@
71 <field name="partner_id" groups="base.group_user"/>74 <field name="partner_id" groups="base.group_user"/>
72 <field name="user_id"/>75 <field name="user_id"/>
73 <field name="company_id" groups="base.group_multi_company" widget="selection"/>76 <field name="company_id" groups="base.group_multi_company" widget="selection"/>
77 <field name="department_id" widget="selection"/>
7478
75 <field name="journal_id" invisible="1"/>79 <field name="journal_id" invisible="1"/>
76 <field name="period_id" invisible="1" groups="account.group_account_user"/>80 <field name="period_id" invisible="1" groups="account.group_account_user"/>
@@ -108,6 +112,7 @@
108 <field name="journal_id" invisible="1"/>112 <field name="journal_id" invisible="1"/>
109 <field name="period_id" invisible="1" groups="account.group_account_user"/>113 <field name="period_id" invisible="1" groups="account.group_account_user"/>
110 <field name="company_id" groups="base.group_multi_company" widget="selection"/>114 <field name="company_id" groups="base.group_multi_company" widget="selection"/>
115 <field name="department_id" widget="selection"/>
111 <field name="user_id"/>116 <field name="user_id"/>
112 <field name="currency_id"/>117 <field name="currency_id"/>
113 <field name="residual" sum="Residual Amount"/>118 <field name="residual" sum="Residual Amount"/>
114119
=== 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-04-02 14:53:22 +0000
@@ -0,0 +1,33 @@
1# -*- coding: utf-8 -*-
2from osv import orm
3from openerp.tools.translate import _
4
5
6class project_project(orm.Model):
7 _inherit = 'project.project'
8
9 def hours_block_tree_view(self, cr, uid, ids, context):
10 invoice_line_obj = self.pool.get('account.invoice.line')
11 hours_block_obj = self.pool.get('account.hours.block')
12 project = self.browse(cr, uid , ids)[0]
13 invoice_line_ids = invoice_line_obj.search(cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)])
14 invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids)
15 invoice_ids = [x.invoice_id.id for x in invoice_lines]
16 res_ids = hours_block_obj.search(cr, uid, [('invoice_id','in',invoice_ids)])
17 domain=False
18 if res_ids:
19 domain = [('id', 'in', res_ids)]
20 else:
21 raise orm.except_orm(_('Warning'), _("No Hours Block for this project"))
22
23 return {
24 'name': _('Hours Blocks'),
25 'domain': domain,
26 'res_model': 'account.hours.block',
27 'type': 'ir.actions.act_window',
28 'view_id': False,
29 'view_mode': 'tree,form',
30 'view_type': 'form',
31 'limit': 80,
32 'res_id' : res_ids or False,
33 }
034
=== 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-04-02 14:53:22 +0000
@@ -0,0 +1,19 @@
1<?xml version="1.0" ?>
2<openerp>
3 <data>
4
5 <record model="ir.ui.view" id="edit_project_hours_block_link">
6 <field name="name">project.project.form.hours.block.link</field>
7 <field name="model">project.project</field>
8 <field name="inherit_id" ref="project.edit_project"/>
9 <field name="type">form</field>
10 <field name="arch" type="xml">
11 <xpath expr="//button[@name='attachment_tree_view']" position="after">
12 <button name="hours_block_tree_view" string="Hours Block" type="object"/>
13 </xpath>
14 </field>
15 </record>
16
17
18 </data>
19</openerp>

Subscribers

People subscribed via source and target branches