Merge lp:~camptocamp/contract-management/hours_block_vre into lp:~contract-management-core-editors/contract-management/7.0
- hours_block_vre
- Merge into 7.0
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 |
Related bugs: |
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 |
Commit message
Description of the change
- a new field for the department, which is filterable/
- a new button in the form view in order to display the hours block related to a project.
- 9. By Lorenzo Battistini
-
[FIX] Can't install analytic_
hours_block - 10. By Daniel Reis
-
New project_sla module
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote : | # |
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,
- 11. By Matthieu Dietrich @ camptocamp
-
[FIX] fixed conflict with latest version + modified store conditions for related fields
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
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Well done Thanks
LGTM
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
42 + 'account.
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
- 12. By Matthieu Dietrich @ camptocamp
-
[FIX] reformatting
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote : | # |
@afayolle: thanks, I re-formatted it now.
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) : | # |
Preview Diff
1 | === modified file 'analytic_hours_block/__init__.py' | |||
2 | --- analytic_hours_block/__init__.py 2012-12-17 12:31:50 +0000 | |||
3 | +++ analytic_hours_block/__init__.py 2014-04-02 14:53:22 +0000 | |||
4 | @@ -20,3 +20,4 @@ | |||
5 | 20 | ############################################################################## | 20 | ############################################################################## |
6 | 21 | import hours_block | 21 | import hours_block |
7 | 22 | import report | 22 | import report |
8 | 23 | import project | ||
9 | 23 | \ No newline at end of file | 24 | \ No newline at end of file |
10 | 24 | 25 | ||
11 | === modified file 'analytic_hours_block/__openerp__.py' | |||
12 | --- analytic_hours_block/__openerp__.py 2014-02-17 08:33:04 +0000 | |||
13 | +++ analytic_hours_block/__openerp__.py 2014-04-02 14:53:22 +0000 | |||
14 | @@ -40,13 +40,16 @@ | |||
15 | 40 | "depends": [ | 40 | "depends": [ |
16 | 41 | "account", | 41 | "account", |
17 | 42 | "hr_timesheet_invoice", | 42 | "hr_timesheet_invoice", |
19 | 43 | "analytic" | 43 | "analytic", |
20 | 44 | "project", | ||
21 | 44 | ], | 45 | ], |
22 | 45 | "data": [ | 46 | "data": [ |
23 | 46 | "report.xml", | 47 | "report.xml", |
24 | 47 | "hours_block_view.xml", | 48 | "hours_block_view.xml", |
25 | 48 | "hours_block_data.xml", | 49 | "hours_block_data.xml", |
26 | 49 | "hours_block_menu.xml", | 50 | "hours_block_menu.xml", |
27 | 51 | "project_view.xml", | ||
28 | 52 | "report.xml", | ||
29 | 50 | "security/hours_block_security.xml", | 53 | "security/hours_block_security.xml", |
30 | 51 | "security/ir.model.access.csv", | 54 | "security/ir.model.access.csv", |
31 | 52 | ], | 55 | ], |
32 | 53 | 56 | ||
33 | === modified file 'analytic_hours_block/hours_block.py' | |||
34 | --- analytic_hours_block/hours_block.py 2014-01-31 14:45:54 +0000 | |||
35 | +++ analytic_hours_block/hours_block.py 2014-04-02 14:53:22 +0000 | |||
36 | @@ -267,74 +267,130 @@ | |||
37 | 267 | 'invoice_id', 'date_invoice', | 267 | 'invoice_id', 'date_invoice', |
38 | 268 | type="date", | 268 | type="date", |
39 | 269 | string="Invoice Date", | 269 | string="Invoice Date", |
41 | 270 | store=True, | 270 | store={ |
42 | 271 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
43 | 272 | ['invoice_id'], 10), | ||
44 | 273 | 'account.invoice': (_get_invoice, ['date_invoice'], 10), | ||
45 | 274 | }, | ||
46 | 271 | readonly=True), | 275 | readonly=True), |
47 | 272 | 'user_id': fields.related( | 276 | 'user_id': fields.related( |
48 | 273 | 'invoice_id', 'user_id', | 277 | 'invoice_id', 'user_id', |
49 | 274 | type="many2one", | 278 | type="many2one", |
50 | 275 | relation="res.users", | 279 | relation="res.users", |
51 | 276 | string="Salesman", | 280 | string="Salesman", |
53 | 277 | store=True, | 281 | store={ |
54 | 282 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
55 | 283 | ['invoice_id'], 10), | ||
56 | 284 | 'account.invoice': (_get_invoice, ['user_id'], 10), | ||
57 | 285 | }, | ||
58 | 278 | readonly=True), | 286 | readonly=True), |
59 | 279 | 'partner_id': fields.related( | 287 | 'partner_id': fields.related( |
60 | 280 | 'invoice_id', 'partner_id', | 288 | 'invoice_id', 'partner_id', |
61 | 281 | type="many2one", | 289 | type="many2one", |
62 | 282 | relation="res.partner", | 290 | relation="res.partner", |
63 | 283 | string="Partner", | 291 | string="Partner", |
65 | 284 | store=True, | 292 | store={ |
66 | 293 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
67 | 294 | ['invoice_id'], 10), | ||
68 | 295 | 'account.invoice': (_get_invoice, ['partner_id'], 10), | ||
69 | 296 | }, | ||
70 | 285 | readonly=True), | 297 | readonly=True), |
71 | 286 | 'name': fields.related( | 298 | 'name': fields.related( |
72 | 287 | 'invoice_id', 'name', | 299 | 'invoice_id', 'name', |
73 | 288 | type="char", | 300 | type="char", |
74 | 289 | string="Description", | 301 | string="Description", |
76 | 290 | store=True, | 302 | store={ |
77 | 303 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
78 | 304 | ['invoice_id'], 10), | ||
79 | 305 | 'account.invoice': (_get_invoice, ['name'], 10), | ||
80 | 306 | }, | ||
81 | 291 | readonly=True), | 307 | readonly=True), |
82 | 292 | 'number': fields.related( | 308 | 'number': fields.related( |
83 | 293 | 'invoice_id', 'number', | 309 | 'invoice_id', 'number', |
84 | 294 | type="char", | 310 | type="char", |
85 | 295 | string="Number", | 311 | string="Number", |
87 | 296 | store=True, | 312 | store={ |
88 | 313 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
89 | 314 | ['invoice_id'], 10), | ||
90 | 315 | 'account.invoice': (_get_invoice, ['number'], 10), | ||
91 | 316 | }, | ||
92 | 297 | readonly=True), | 317 | readonly=True), |
93 | 298 | 'journal_id': fields.related( | 318 | 'journal_id': fields.related( |
94 | 299 | 'invoice_id', 'journal_id', | 319 | 'invoice_id', 'journal_id', |
95 | 300 | type="many2one", | 320 | type="many2one", |
96 | 301 | relation="account.journal", | 321 | relation="account.journal", |
97 | 302 | string="Journal", | 322 | string="Journal", |
99 | 303 | store=True, | 323 | store={ |
100 | 324 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
101 | 325 | ['invoice_id'], 10), | ||
102 | 326 | 'account.invoice': (_get_invoice, ['journal_id'], 10), | ||
103 | 327 | }, | ||
104 | 304 | readonly=True), | 328 | readonly=True), |
105 | 305 | 'period_id': fields.related( | 329 | 'period_id': fields.related( |
106 | 306 | 'invoice_id', 'period_id', | 330 | 'invoice_id', 'period_id', |
107 | 307 | type="many2one", | 331 | type="many2one", |
108 | 308 | relation="account.period", | 332 | relation="account.period", |
109 | 309 | string="Period", | 333 | string="Period", |
111 | 310 | store=True, | 334 | store={ |
112 | 335 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
113 | 336 | ['invoice_id'], 10), | ||
114 | 337 | 'account.invoice': (_get_invoice, ['period_id'], 10), | ||
115 | 338 | }, | ||
116 | 311 | readonly=True), | 339 | readonly=True), |
117 | 312 | 'company_id': fields.related( | 340 | 'company_id': fields.related( |
118 | 313 | 'invoice_id', 'company_id', | 341 | 'invoice_id', 'company_id', |
119 | 314 | type="many2one", | 342 | type="many2one", |
120 | 315 | relation="res.company", | 343 | relation="res.company", |
121 | 316 | string="Company", | 344 | string="Company", |
123 | 317 | store=True, | 345 | store={ |
124 | 346 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
125 | 347 | ['invoice_id'], 10), | ||
126 | 348 | 'account.invoice': (_get_invoice, ['company_id'], 10), | ||
127 | 349 | }, | ||
128 | 318 | readonly=True), | 350 | readonly=True), |
129 | 319 | 'currency_id': fields.related( | 351 | 'currency_id': fields.related( |
130 | 320 | 'invoice_id', 'currency_id', | 352 | 'invoice_id', 'currency_id', |
131 | 321 | type="many2one", | 353 | type="many2one", |
132 | 322 | relation="res.currency", | 354 | relation="res.currency", |
133 | 323 | string="Currency", | 355 | string="Currency", |
135 | 324 | store=True, | 356 | store={ |
136 | 357 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
137 | 358 | ['invoice_id'], 10), | ||
138 | 359 | 'account.invoice': (_get_invoice, ['currency_id'], 10), | ||
139 | 360 | }, | ||
140 | 325 | readonly=True), | 361 | readonly=True), |
141 | 326 | 'residual': fields.related( | 362 | 'residual': fields.related( |
142 | 327 | 'invoice_id', 'residual', | 363 | 'invoice_id', 'residual', |
143 | 328 | type="float", | 364 | type="float", |
144 | 329 | string="Residual", | 365 | string="Residual", |
146 | 330 | store=True, | 366 | store={ |
147 | 367 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
148 | 368 | ['invoice_id'], 10), | ||
149 | 369 | 'account.invoice': (_get_invoice, ['residual'], 10), | ||
150 | 370 | }, | ||
151 | 331 | readonly=True), | 371 | readonly=True), |
152 | 332 | 'amount_total': fields.related( | 372 | 'amount_total': fields.related( |
153 | 333 | 'invoice_id', 'amount_total', | 373 | 'invoice_id', 'amount_total', |
154 | 334 | type="float", | 374 | type="float", |
155 | 335 | string="Total", | 375 | string="Total", |
157 | 336 | store=True, | 376 | store={ |
158 | 377 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
159 | 378 | ['invoice_id'], 10), | ||
160 | 379 | 'account.invoice': (_get_invoice, ['amount_total'], 10), | ||
161 | 380 | }, | ||
162 | 337 | readonly=True), | 381 | readonly=True), |
163 | 382 | 'department_id': fields.related( | ||
164 | 383 | 'invoice_id', 'department_id', | ||
165 | 384 | type='many2one', | ||
166 | 385 | relation='hr.department', | ||
167 | 386 | string='Department', | ||
168 | 387 | store={ | ||
169 | 388 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
170 | 389 | ['invoice_id'], 10), | ||
171 | 390 | 'account.invoice': (_get_invoice, ['department_id'], 10), | ||
172 | 391 | }, | ||
173 | 392 | readonly=True), | ||
174 | 393 | |||
175 | 338 | 'state': fields.related( | 394 | 'state': fields.related( |
176 | 339 | 'invoice_id', 'state', | 395 | 'invoice_id', 'state', |
177 | 340 | type='selection', | 396 | type='selection', |
178 | @@ -348,7 +404,11 @@ | |||
179 | 348 | ], | 404 | ], |
180 | 349 | string='State', | 405 | string='State', |
181 | 350 | readonly=True, | 406 | readonly=True, |
183 | 351 | store=True), | 407 | store={ |
184 | 408 | 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, | ||
185 | 409 | ['invoice_id'], 10), | ||
186 | 410 | 'account.invoice': (_get_invoice, ['state'], 10), | ||
187 | 411 | }), | ||
188 | 352 | } | 412 | } |
189 | 353 | 413 | ||
190 | 354 | 414 | ||
191 | 355 | 415 | ||
192 | === modified file 'analytic_hours_block/hours_block_menu.xml' | |||
193 | --- analytic_hours_block/hours_block_menu.xml 2012-12-17 15:37:44 +0000 | |||
194 | +++ analytic_hours_block/hours_block_menu.xml 2014-04-02 14:53:22 +0000 | |||
195 | @@ -6,6 +6,7 @@ | |||
196 | 6 | Hours block menu | 6 | Hours block menu |
197 | 7 | --> | 7 | --> |
198 | 8 | <record model="ir.actions.act_window" id="action_all_block_hour"> | 8 | <record model="ir.actions.act_window" id="action_all_block_hour"> |
199 | 9 | <field name="context">{'search_default_running': 1, 'search_default_group_department_id': 1}</field> | ||
200 | 9 | <field name="name">Hours Blocks</field> | 10 | <field name="name">Hours Blocks</field> |
201 | 10 | <field name="res_model">account.hours.block</field> | 11 | <field name="res_model">account.hours.block</field> |
202 | 11 | <field name="view_type">form</field> | 12 | <field name="view_type">form</field> |
203 | 12 | 13 | ||
204 | === modified file 'analytic_hours_block/hours_block_view.xml' | |||
205 | --- analytic_hours_block/hours_block_view.xml 2014-01-08 11:55:30 +0000 | |||
206 | +++ analytic_hours_block/hours_block_view.xml 2014-04-02 14:53:22 +0000 | |||
207 | @@ -18,15 +18,18 @@ | |||
208 | 18 | <separator orientation="vertical"/> | 18 | <separator orientation="vertical"/> |
209 | 19 | <field name="number"/> | 19 | <field name="number"/> |
210 | 20 | <field name="partner_id"/> | 20 | <field name="partner_id"/> |
211 | 21 | <field name="department_id" string="Department"/> | ||
212 | 21 | <field name="user_id" select="1" widget="selection" string="Salesman"> | 22 | <field name="user_id" select="1" widget="selection" string="Salesman"> |
213 | 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"/> |
214 | 23 | </field> | 24 | </field> |
215 | 25 | |||
216 | 24 | <field name="company_id" widget="selection"/> | 26 | <field name="company_id" widget="selection"/> |
217 | 25 | </group> | 27 | </group> |
218 | 26 | <newline/> | 28 | <newline/> |
219 | 27 | <group expand="0" string="Group By..."> | 29 | <group expand="0" string="Group By..."> |
220 | 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'}"/> |
221 | 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'}"/> |
222 | 32 | <filter string="Department" icon="terp-personal" domain="[]" context="{'group_by':'department_id'}"/> | ||
223 | 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'}"/> |
224 | 31 | </group> | 34 | </group> |
225 | 32 | </search> | 35 | </search> |
226 | @@ -71,6 +74,7 @@ | |||
227 | 71 | <field name="partner_id" groups="base.group_user"/> | 74 | <field name="partner_id" groups="base.group_user"/> |
228 | 72 | <field name="user_id"/> | 75 | <field name="user_id"/> |
229 | 73 | <field name="company_id" groups="base.group_multi_company" widget="selection"/> | 76 | <field name="company_id" groups="base.group_multi_company" widget="selection"/> |
230 | 77 | <field name="department_id" widget="selection"/> | ||
231 | 74 | 78 | ||
232 | 75 | <field name="journal_id" invisible="1"/> | 79 | <field name="journal_id" invisible="1"/> |
233 | 76 | <field name="period_id" invisible="1" groups="account.group_account_user"/> | 80 | <field name="period_id" invisible="1" groups="account.group_account_user"/> |
234 | @@ -108,6 +112,7 @@ | |||
235 | 108 | <field name="journal_id" invisible="1"/> | 112 | <field name="journal_id" invisible="1"/> |
236 | 109 | <field name="period_id" invisible="1" groups="account.group_account_user"/> | 113 | <field name="period_id" invisible="1" groups="account.group_account_user"/> |
237 | 110 | <field name="company_id" groups="base.group_multi_company" widget="selection"/> | 114 | <field name="company_id" groups="base.group_multi_company" widget="selection"/> |
238 | 115 | <field name="department_id" widget="selection"/> | ||
239 | 111 | <field name="user_id"/> | 116 | <field name="user_id"/> |
240 | 112 | <field name="currency_id"/> | 117 | <field name="currency_id"/> |
241 | 113 | <field name="residual" sum="Residual Amount"/> | 118 | <field name="residual" sum="Residual Amount"/> |
242 | 114 | 119 | ||
243 | === added file 'analytic_hours_block/project.py' | |||
244 | --- analytic_hours_block/project.py 1970-01-01 00:00:00 +0000 | |||
245 | +++ analytic_hours_block/project.py 2014-04-02 14:53:22 +0000 | |||
246 | @@ -0,0 +1,33 @@ | |||
247 | 1 | # -*- coding: utf-8 -*- | ||
248 | 2 | from osv import orm | ||
249 | 3 | from openerp.tools.translate import _ | ||
250 | 4 | |||
251 | 5 | |||
252 | 6 | class project_project(orm.Model): | ||
253 | 7 | _inherit = 'project.project' | ||
254 | 8 | |||
255 | 9 | def hours_block_tree_view(self, cr, uid, ids, context): | ||
256 | 10 | invoice_line_obj = self.pool.get('account.invoice.line') | ||
257 | 11 | hours_block_obj = self.pool.get('account.hours.block') | ||
258 | 12 | project = self.browse(cr, uid , ids)[0] | ||
259 | 13 | invoice_line_ids = invoice_line_obj.search(cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)]) | ||
260 | 14 | invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids) | ||
261 | 15 | invoice_ids = [x.invoice_id.id for x in invoice_lines] | ||
262 | 16 | res_ids = hours_block_obj.search(cr, uid, [('invoice_id','in',invoice_ids)]) | ||
263 | 17 | domain=False | ||
264 | 18 | if res_ids: | ||
265 | 19 | domain = [('id', 'in', res_ids)] | ||
266 | 20 | else: | ||
267 | 21 | raise orm.except_orm(_('Warning'), _("No Hours Block for this project")) | ||
268 | 22 | |||
269 | 23 | return { | ||
270 | 24 | 'name': _('Hours Blocks'), | ||
271 | 25 | 'domain': domain, | ||
272 | 26 | 'res_model': 'account.hours.block', | ||
273 | 27 | 'type': 'ir.actions.act_window', | ||
274 | 28 | 'view_id': False, | ||
275 | 29 | 'view_mode': 'tree,form', | ||
276 | 30 | 'view_type': 'form', | ||
277 | 31 | 'limit': 80, | ||
278 | 32 | 'res_id' : res_ids or False, | ||
279 | 33 | } | ||
280 | 0 | 34 | ||
281 | === added file 'analytic_hours_block/project_view.xml' | |||
282 | --- analytic_hours_block/project_view.xml 1970-01-01 00:00:00 +0000 | |||
283 | +++ analytic_hours_block/project_view.xml 2014-04-02 14:53:22 +0000 | |||
284 | @@ -0,0 +1,19 @@ | |||
285 | 1 | <?xml version="1.0" ?> | ||
286 | 2 | <openerp> | ||
287 | 3 | <data> | ||
288 | 4 | |||
289 | 5 | <record model="ir.ui.view" id="edit_project_hours_block_link"> | ||
290 | 6 | <field name="name">project.project.form.hours.block.link</field> | ||
291 | 7 | <field name="model">project.project</field> | ||
292 | 8 | <field name="inherit_id" ref="project.edit_project"/> | ||
293 | 9 | <field name="type">form</field> | ||
294 | 10 | <field name="arch" type="xml"> | ||
295 | 11 | <xpath expr="//button[@name='attachment_tree_view']" position="after"> | ||
296 | 12 | <button name="hours_block_tree_view" string="Hours Block" type="object"/> | ||
297 | 13 | </xpath> | ||
298 | 14 | </field> | ||
299 | 15 | </record> | ||
300 | 16 | |||
301 | 17 | |||
302 | 18 | </data> | ||
303 | 19 | </openerp> |
To expand a bit: this MP is to add 2 things related to hours block: searchable,
- a new field for the department, which is filterable/
- a new button in the project form view, in order to get the hours block related to a project.