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 | ############################################################################## |
6 | import hours_block |
7 | import report |
8 | +import project |
9 | \ No newline at end of file |
10 | |
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 | "depends": [ |
16 | "account", |
17 | "hr_timesheet_invoice", |
18 | - "analytic" |
19 | + "analytic", |
20 | + "project", |
21 | ], |
22 | "data": [ |
23 | "report.xml", |
24 | "hours_block_view.xml", |
25 | "hours_block_data.xml", |
26 | "hours_block_menu.xml", |
27 | + "project_view.xml", |
28 | + "report.xml", |
29 | "security/hours_block_security.xml", |
30 | "security/ir.model.access.csv", |
31 | ], |
32 | |
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 | 'invoice_id', 'date_invoice', |
38 | type="date", |
39 | string="Invoice Date", |
40 | - store=True, |
41 | + store={ |
42 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
43 | + ['invoice_id'], 10), |
44 | + 'account.invoice': (_get_invoice, ['date_invoice'], 10), |
45 | + }, |
46 | readonly=True), |
47 | 'user_id': fields.related( |
48 | 'invoice_id', 'user_id', |
49 | type="many2one", |
50 | relation="res.users", |
51 | string="Salesman", |
52 | - store=True, |
53 | + store={ |
54 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
55 | + ['invoice_id'], 10), |
56 | + 'account.invoice': (_get_invoice, ['user_id'], 10), |
57 | + }, |
58 | readonly=True), |
59 | 'partner_id': fields.related( |
60 | 'invoice_id', 'partner_id', |
61 | type="many2one", |
62 | relation="res.partner", |
63 | string="Partner", |
64 | - store=True, |
65 | + store={ |
66 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
67 | + ['invoice_id'], 10), |
68 | + 'account.invoice': (_get_invoice, ['partner_id'], 10), |
69 | + }, |
70 | readonly=True), |
71 | 'name': fields.related( |
72 | 'invoice_id', 'name', |
73 | type="char", |
74 | string="Description", |
75 | - store=True, |
76 | + store={ |
77 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
78 | + ['invoice_id'], 10), |
79 | + 'account.invoice': (_get_invoice, ['name'], 10), |
80 | + }, |
81 | readonly=True), |
82 | 'number': fields.related( |
83 | 'invoice_id', 'number', |
84 | type="char", |
85 | string="Number", |
86 | - store=True, |
87 | + store={ |
88 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
89 | + ['invoice_id'], 10), |
90 | + 'account.invoice': (_get_invoice, ['number'], 10), |
91 | + }, |
92 | readonly=True), |
93 | 'journal_id': fields.related( |
94 | 'invoice_id', 'journal_id', |
95 | type="many2one", |
96 | relation="account.journal", |
97 | string="Journal", |
98 | - store=True, |
99 | + store={ |
100 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
101 | + ['invoice_id'], 10), |
102 | + 'account.invoice': (_get_invoice, ['journal_id'], 10), |
103 | + }, |
104 | readonly=True), |
105 | 'period_id': fields.related( |
106 | 'invoice_id', 'period_id', |
107 | type="many2one", |
108 | relation="account.period", |
109 | string="Period", |
110 | - store=True, |
111 | + store={ |
112 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
113 | + ['invoice_id'], 10), |
114 | + 'account.invoice': (_get_invoice, ['period_id'], 10), |
115 | + }, |
116 | readonly=True), |
117 | 'company_id': fields.related( |
118 | 'invoice_id', 'company_id', |
119 | type="many2one", |
120 | relation="res.company", |
121 | string="Company", |
122 | - store=True, |
123 | + store={ |
124 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
125 | + ['invoice_id'], 10), |
126 | + 'account.invoice': (_get_invoice, ['company_id'], 10), |
127 | + }, |
128 | readonly=True), |
129 | 'currency_id': fields.related( |
130 | 'invoice_id', 'currency_id', |
131 | type="many2one", |
132 | relation="res.currency", |
133 | string="Currency", |
134 | - store=True, |
135 | + store={ |
136 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
137 | + ['invoice_id'], 10), |
138 | + 'account.invoice': (_get_invoice, ['currency_id'], 10), |
139 | + }, |
140 | readonly=True), |
141 | 'residual': fields.related( |
142 | 'invoice_id', 'residual', |
143 | type="float", |
144 | string="Residual", |
145 | - store=True, |
146 | + store={ |
147 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
148 | + ['invoice_id'], 10), |
149 | + 'account.invoice': (_get_invoice, ['residual'], 10), |
150 | + }, |
151 | readonly=True), |
152 | 'amount_total': fields.related( |
153 | 'invoice_id', 'amount_total', |
154 | type="float", |
155 | string="Total", |
156 | - store=True, |
157 | + store={ |
158 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
159 | + ['invoice_id'], 10), |
160 | + 'account.invoice': (_get_invoice, ['amount_total'], 10), |
161 | + }, |
162 | readonly=True), |
163 | + 'department_id': fields.related( |
164 | + 'invoice_id', 'department_id', |
165 | + type='many2one', |
166 | + relation='hr.department', |
167 | + string='Department', |
168 | + store={ |
169 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
170 | + ['invoice_id'], 10), |
171 | + 'account.invoice': (_get_invoice, ['department_id'], 10), |
172 | + }, |
173 | + readonly=True), |
174 | + |
175 | 'state': fields.related( |
176 | 'invoice_id', 'state', |
177 | type='selection', |
178 | @@ -348,7 +404,11 @@ |
179 | ], |
180 | string='State', |
181 | readonly=True, |
182 | - store=True), |
183 | + store={ |
184 | + 'account.hours.block': (lambda self, cr, uid, ids, c=None: ids, |
185 | + ['invoice_id'], 10), |
186 | + 'account.invoice': (_get_invoice, ['state'], 10), |
187 | + }), |
188 | } |
189 | |
190 | |
191 | |
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 | Hours block menu |
197 | --> |
198 | <record model="ir.actions.act_window" id="action_all_block_hour"> |
199 | + <field name="context">{'search_default_running': 1, 'search_default_group_department_id': 1}</field> |
200 | <field name="name">Hours Blocks</field> |
201 | <field name="res_model">account.hours.block</field> |
202 | <field name="view_type">form</field> |
203 | |
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 | <separator orientation="vertical"/> |
209 | <field name="number"/> |
210 | <field name="partner_id"/> |
211 | + <field name="department_id" string="Department"/> |
212 | <field name="user_id" select="1" widget="selection" string="Salesman"> |
213 | <filter domain="[('user_id','=',uid)]" help="My invoices" icon="terp-personal" separator="1"/> |
214 | </field> |
215 | + |
216 | <field name="company_id" widget="selection"/> |
217 | </group> |
218 | <newline/> |
219 | <group expand="0" string="Group By..."> |
220 | <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> |
221 | <filter string="Responsible" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/> |
222 | + <filter string="Department" icon="terp-personal" domain="[]" context="{'group_by':'department_id'}"/> |
223 | <filter string="Invoice State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> |
224 | </group> |
225 | </search> |
226 | @@ -71,6 +74,7 @@ |
227 | <field name="partner_id" groups="base.group_user"/> |
228 | <field name="user_id"/> |
229 | <field name="company_id" groups="base.group_multi_company" widget="selection"/> |
230 | + <field name="department_id" widget="selection"/> |
231 | |
232 | <field name="journal_id" invisible="1"/> |
233 | <field name="period_id" invisible="1" groups="account.group_account_user"/> |
234 | @@ -108,6 +112,7 @@ |
235 | <field name="journal_id" invisible="1"/> |
236 | <field name="period_id" invisible="1" groups="account.group_account_user"/> |
237 | <field name="company_id" groups="base.group_multi_company" widget="selection"/> |
238 | + <field name="department_id" widget="selection"/> |
239 | <field name="user_id"/> |
240 | <field name="currency_id"/> |
241 | <field name="residual" sum="Residual Amount"/> |
242 | |
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 | +# -*- coding: utf-8 -*- |
248 | +from osv import orm |
249 | +from openerp.tools.translate import _ |
250 | + |
251 | + |
252 | +class project_project(orm.Model): |
253 | + _inherit = 'project.project' |
254 | + |
255 | + def hours_block_tree_view(self, cr, uid, ids, context): |
256 | + invoice_line_obj = self.pool.get('account.invoice.line') |
257 | + hours_block_obj = self.pool.get('account.hours.block') |
258 | + project = self.browse(cr, uid , ids)[0] |
259 | + invoice_line_ids = invoice_line_obj.search(cr, uid, [('account_analytic_id', '=', project.analytic_account_id.id)]) |
260 | + invoice_lines = invoice_line_obj.browse(cr, uid, invoice_line_ids) |
261 | + invoice_ids = [x.invoice_id.id for x in invoice_lines] |
262 | + res_ids = hours_block_obj.search(cr, uid, [('invoice_id','in',invoice_ids)]) |
263 | + domain=False |
264 | + if res_ids: |
265 | + domain = [('id', 'in', res_ids)] |
266 | + else: |
267 | + raise orm.except_orm(_('Warning'), _("No Hours Block for this project")) |
268 | + |
269 | + return { |
270 | + 'name': _('Hours Blocks'), |
271 | + 'domain': domain, |
272 | + 'res_model': 'account.hours.block', |
273 | + 'type': 'ir.actions.act_window', |
274 | + 'view_id': False, |
275 | + 'view_mode': 'tree,form', |
276 | + 'view_type': 'form', |
277 | + 'limit': 80, |
278 | + 'res_id' : res_ids or False, |
279 | + } |
280 | |
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 | +<?xml version="1.0" ?> |
286 | +<openerp> |
287 | + <data> |
288 | + |
289 | + <record model="ir.ui.view" id="edit_project_hours_block_link"> |
290 | + <field name="name">project.project.form.hours.block.link</field> |
291 | + <field name="model">project.project</field> |
292 | + <field name="inherit_id" ref="project.edit_project"/> |
293 | + <field name="type">form</field> |
294 | + <field name="arch" type="xml"> |
295 | + <xpath expr="//button[@name='attachment_tree_view']" position="after"> |
296 | + <button name="hours_block_tree_view" string="Hours Block" type="object"/> |
297 | + </xpath> |
298 | + </field> |
299 | + </record> |
300 | + |
301 | + |
302 | + </data> |
303 | +</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.