Merge lp:~camptocamp/department-mgmt/7.0-port-invoice_department into lp:~department-core-editors/department-mgmt/7.0
- 7.0-port-invoice_department
- Merge into 7.0
Proposed by
Yannick Vaucher @ Camptocamp
Status: | Merged |
---|---|
Merged at revision: | 12 |
Proposed branch: | lp:~camptocamp/department-mgmt/7.0-port-invoice_department |
Merge into: | lp:~department-core-editors/department-mgmt/7.0 |
Diff against target: |
345 lines (+136/-163) 4 files modified
invoice_department/__init__.py (+17/-25) invoice_department/__openerp__.py (+33/-44) invoice_department/invoice.py (+31/-35) invoice_department/invoice_view.xml (+55/-59) |
To merge this branch: | bzr merge lp:~camptocamp/department-mgmt/7.0-port-invoice_department |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | code review, no test | Approve | |
Alexandre Fayolle - camptocamp | code review, no test | Approve | |
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
review:
Approve
(code review, no test)
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
LGTM
review:
Approve
(code review, no test)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'invoice_department/__init__.py' | |||
2 | --- invoice_department/__init__.py 2011-08-12 13:27:15 +0000 | |||
3 | +++ invoice_department/__init__.py 2013-05-02 15:54:00 +0000 | |||
4 | @@ -1,31 +1,23 @@ | |||
5 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
6 | 2 | ############################################################################## | 2 | ############################################################################## |
7 | 3 | # | 3 | # |
33 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Joël Grand-guillaume (Camptocamp) |
34 | 5 | # All Right Reserved | 5 | # Copyright 2010 Camptocamp SA |
35 | 6 | # | 6 | # |
36 | 7 | # Author : Joel Grand-guillaume (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
37 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
38 | 9 | # WARNING: This program as such is intended to be used by professional | 9 | # published by the Free Software Foundation, either version 3 of the |
39 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
40 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
41 | 12 | # End users who are looking for a ready-to-use solution with commercial | 12 | # This program is distributed in the hope that it will be useful, |
42 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
43 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44 | 15 | # | 15 | # GNU Affero General Public License for more details. |
45 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
46 | 17 | # modify it under the terms of the GNU General Public License | 17 | # You should have received a copy of the GNU Affero General Public License |
47 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 19 | # of the License, or (at your option) any later version. | ||
24 | 20 | # | ||
25 | 21 | # This program is distributed in the hope that it will be useful, | ||
26 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | 24 | # GNU General Public License for more details. | ||
29 | 25 | # | ||
30 | 26 | # You should have received a copy of the GNU General Public License | ||
31 | 27 | # along with this program; if not, write to the Free Software | ||
32 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
48 | 29 | # | 19 | # |
49 | 30 | ############################################################################## | 20 | ############################################################################## |
50 | 31 | import invoice | 21 | import invoice |
51 | 22 | |||
52 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
53 | 32 | 24 | ||
54 | === modified file 'invoice_department/__openerp__.py' | |||
55 | --- invoice_department/__openerp__.py 2013-01-04 10:32:58 +0000 | |||
56 | +++ invoice_department/__openerp__.py 2013-05-02 15:54:00 +0000 | |||
57 | @@ -1,53 +1,42 @@ | |||
58 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
59 | 2 | ############################################################################## | 2 | ############################################################################## |
60 | 3 | # | 3 | # |
86 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Joël Grand-guillaume (Camptocamp) |
87 | 5 | # All Right Reserved | 5 | # Copyright 2010 Camptocamp SA |
88 | 6 | # | 6 | # |
89 | 7 | # Author : Joel Grand-guillaume (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
90 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
91 | 9 | # WARNING: This program as such is intended to be used by professional | 9 | # published by the Free Software Foundation, either version 3 of the |
92 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
93 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
94 | 12 | # End users who are looking for a ready-to-use solution with commercial | 12 | # This program is distributed in the hope that it will be useful, |
95 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
96 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
97 | 15 | # | 15 | # GNU Affero General Public License for more details. |
98 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
99 | 17 | # modify it under the terms of the GNU General Public License | 17 | # You should have received a copy of the GNU Affero General Public License |
100 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
76 | 19 | # of the License, or (at your option) any later version. | ||
77 | 20 | # | ||
78 | 21 | # This program is distributed in the hope that it will be useful, | ||
79 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
80 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
81 | 24 | # GNU General Public License for more details. | ||
82 | 25 | # | ||
83 | 26 | # You should have received a copy of the GNU General Public License | ||
84 | 27 | # along with this program; if not, write to the Free Software | ||
85 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
101 | 29 | # | 19 | # |
102 | 30 | ############################################################################## | 20 | ############################################################################## |
103 | 31 | 21 | ||
104 | 32 | { | 22 | { |
111 | 33 | "name" : "Invoices with Department Categorization", | 23 | 'name' : 'Invoices with Department Categorization', |
112 | 34 | "version" : "1.0", | 24 | 'version' : '1.0', |
113 | 35 | "author" : "Camptocamp", | 25 | 'category' : 'Generic Modules/Sales & Purchases', |
114 | 36 | "category" : "Generic Modules/Sales & Purchases", | 26 | 'description': |
115 | 37 | "description": | 27 | ''' |
116 | 38 | """Add the department on Invoices. | 28 | Add the department on Invoices as well as the related filter and button in the search form. |
117 | 39 | 29 | ||
131 | 40 | The views are adapted to use the information in the search form.""", | 30 | ''', |
132 | 41 | "website": "http://camptocamp.com", | 31 | 'author' : 'Camptocamp', |
133 | 42 | "depends" : [ | 32 | 'website': 'http://camptocamp.com', |
134 | 43 | "account", | 33 | 'depends' : ['account', 'hr'], |
135 | 44 | "hr" | 34 | 'data' : ['invoice_view.xml',], |
136 | 45 | ], | 35 | 'demo' : [], |
137 | 46 | "init_xml" : [], | 36 | 'test': [], |
138 | 47 | "demo_xml" : [], | 37 | 'installable': True, |
139 | 48 | "update_xml" : [ | 38 | 'auto_install': False, |
140 | 49 | "invoice_view.xml", | 39 | 'application': False |
128 | 50 | ], | ||
129 | 51 | "active": False, | ||
130 | 52 | 'installable': False | ||
141 | 53 | } | 40 | } |
142 | 41 | |||
143 | 42 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
144 | 54 | 43 | ||
145 | === modified file 'invoice_department/invoice.py' | |||
146 | --- invoice_department/invoice.py 2011-08-12 13:27:15 +0000 | |||
147 | +++ invoice_department/invoice.py 2013-05-02 15:54:00 +0000 | |||
148 | @@ -1,45 +1,41 @@ | |||
149 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
150 | 2 | ############################################################################## | 2 | ############################################################################## |
151 | 3 | # | 3 | # |
177 | 4 | # Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Joël Grand-guillaume (Camptocamp) |
178 | 5 | # All Right Reserved | 5 | # Copyright 2010 Camptocamp SA |
179 | 6 | # | 6 | # |
180 | 7 | # Author : Joel Grand-guillaume (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
181 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
182 | 9 | # WARNING: This program as such is intended to be used by professional | 9 | # published by the Free Software Foundation, either version 3 of the |
183 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
184 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
185 | 12 | # End users who are looking for a ready-to-use solution with commercial | 12 | # This program is distributed in the hope that it will be useful, |
186 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
187 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
188 | 15 | # | 15 | # GNU Affero General Public License for more details. |
189 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
190 | 17 | # modify it under the terms of the GNU General Public License | 17 | # You should have received a copy of the GNU Affero General Public License |
191 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
167 | 19 | # of the License, or (at your option) any later version. | ||
168 | 20 | # | ||
169 | 21 | # This program is distributed in the hope that it will be useful, | ||
170 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
171 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
172 | 24 | # GNU General Public License for more details. | ||
173 | 25 | # | ||
174 | 26 | # You should have received a copy of the GNU General Public License | ||
175 | 27 | # along with this program; if not, write to the Free Software | ||
176 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
192 | 29 | # | 19 | # |
193 | 30 | ############################################################################## | 20 | ############################################################################## |
199 | 31 | 21 | from openerp.osv import orm, fields | |
200 | 32 | from osv import osv | 22 | |
201 | 33 | from osv import fields | 23 | class AccountInvoice(orm.Model): |
197 | 34 | |||
198 | 35 | class account_invoice(osv.osv): | ||
202 | 36 | _inherit = "account.invoice" | 24 | _inherit = "account.invoice" |
203 | 37 | |||
204 | 38 | _columns = { | 25 | _columns = { |
205 | 39 | 'department_id': fields.many2one('hr.department', 'Department'), | 26 | 'department_id': fields.many2one('hr.department', 'Department'), |
207 | 40 | } | 27 | } |
208 | 28 | |||
209 | 29 | def _get_department(self, cr, uid, ids, context=None): | ||
210 | 30 | employee_obj = self.pool.get('hr.employee') | ||
211 | 31 | department_id = False | ||
212 | 32 | employee_ids = employee_obj.search(cr, uid, [('user_id','=', uid)]) | ||
213 | 33 | if employee_ids: | ||
214 | 34 | department_id = employee_obj.browse(cr, uid, employee_ids[0], context=context).department_id.id | ||
215 | 35 | return department_id | ||
216 | 36 | |||
217 | 41 | _defaults = { | 37 | _defaults = { |
220 | 42 | 'department_id': lambda s,cr,uid,c: s.pool.get('res.users').browse(cr,uid,uid).context_department_id.id, | 38 | 'department_id': _get_department, |
221 | 43 | } | 39 | } |
222 | 44 | 40 | ||
224 | 45 | account_invoice() | 41 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
225 | 46 | 42 | ||
226 | === modified file 'invoice_department/invoice_view.xml' | |||
227 | --- invoice_department/invoice_view.xml 2011-08-12 13:27:15 +0000 | |||
228 | +++ invoice_department/invoice_view.xml 2013-05-02 15:54:00 +0000 | |||
229 | @@ -1,60 +1,56 @@ | |||
230 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
231 | 1 | <openerp> | 2 | <openerp> |
232 | 2 | <data> | ||
233 | 3 | <record id="invoice_tree" model="ir.ui.view"> | ||
234 | 4 | <field name="name">account.invoice.tree</field> | ||
235 | 5 | <field name="model">account.invoice</field> | ||
236 | 6 | <field name="inherit_id" ref="account.invoice_tree" /> | ||
237 | 7 | <field name="type">tree</field> | ||
238 | 8 | <field name="arch" type="xml"> | ||
239 | 9 | <xpath expr="/tree/field[@name='company_id']" position="before"> | ||
240 | 10 | <field name="department_id" /> | ||
241 | 11 | </xpath> | ||
242 | 12 | </field> | ||
243 | 13 | </record> | ||
244 | 14 | |||
245 | 15 | <record id="invoice_form" model="ir.ui.view"> | ||
246 | 16 | <field name="name">account.invoice.form</field> | ||
247 | 17 | <field name="model">account.invoice</field> | ||
248 | 18 | <field name="inherit_id" ref="account.invoice_form" /> | ||
249 | 19 | <field name="type">form</field> | ||
250 | 20 | <field name="arch" type="xml"> | ||
251 | 21 | <xpath expr="/form/notebook/page[@string='Other Info']/field[@name='company_id']" position="before"> | ||
252 | 22 | <field name="department_id" widget="selection"/> | ||
253 | 23 | </xpath> | ||
254 | 24 | </field> | ||
255 | 25 | </record> | ||
256 | 26 | |||
257 | 27 | <record id="view_account_invoice_filter" model="ir.ui.view"> | ||
258 | 28 | <field name="name">account.invoice.select</field> | ||
259 | 29 | <field name="model">account.invoice</field> | ||
260 | 30 | <field name="inherit_id" ref="account.view_account_invoice_filter" /> | ||
261 | 31 | <field name="type">search</field> | ||
262 | 32 | <field name="arch" type="xml"> | ||
263 | 33 | <xpath expr="/search/group[2]" position="replace"> | ||
264 | 34 | <group col="10" colspan="4"> | ||
265 | 35 | <field name="journal_id" widget="selection" select='1'/> | ||
266 | 36 | <field name="department_id" select="1" widget="selection"/> | ||
267 | 37 | <field name="period_id" select='1' string="Period"/> | ||
268 | 38 | </group> | ||
269 | 39 | </xpath> | ||
270 | 40 | <xpath expr="/search/group/filter[@string='Partner']" position="after"> | ||
271 | 41 | <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/> | ||
272 | 42 | </xpath> | ||
273 | 43 | </field> | ||
274 | 44 | </record> | ||
275 | 45 | |||
276 | 46 | <record id="invoice_supplier_form" model="ir.ui.view"> | ||
277 | 47 | <field name="name">account.invoice.supplier.form</field> | ||
278 | 48 | <field name="model">account.invoice</field> | ||
279 | 49 | <field name="inherit_id" ref="account.invoice_supplier_form" /> | ||
280 | 50 | <field name="type">form</field> | ||
281 | 51 | <field name="priority">2</field> | ||
282 | 52 | <field name="arch" type="xml"> | ||
283 | 53 | <xpath expr="/form/notebook/page[@string='Other Info']/field[@name='company_id']" position="before"> | ||
284 | 54 | <field name="department_id" widget="selection"/> | ||
285 | 55 | </xpath> | ||
286 | 56 | </field> | ||
287 | 57 | </record> | ||
288 | 58 | |||
289 | 59 | </data> | ||
290 | 60 | </openerp> | ||
291 | 61 | \ No newline at end of file | 3 | \ No newline at end of file |
292 | 4 | <data> | ||
293 | 5 | |||
294 | 6 | <record id="invoice_tree" model="ir.ui.view"> | ||
295 | 7 | <field name="name">account.invoice.tree</field> | ||
296 | 8 | <field name="model">account.invoice</field> | ||
297 | 9 | <field name="inherit_id" ref="account.invoice_tree" /> | ||
298 | 10 | <field name="arch" type="xml"> | ||
299 | 11 | <field name="company_id" position="before"> | ||
300 | 12 | <field name="department_id" /> | ||
301 | 13 | </field> | ||
302 | 14 | </field> | ||
303 | 15 | </record> | ||
304 | 16 | |||
305 | 17 | <record id="invoice_form" model="ir.ui.view"> | ||
306 | 18 | <field name="name">account.invoice.form</field> | ||
307 | 19 | <field name="model">account.invoice</field> | ||
308 | 20 | <field name="inherit_id" ref="account.invoice_form" /> | ||
309 | 21 | <field name="arch" type="xml"> | ||
310 | 22 | <field name="company_id" position="before"> | ||
311 | 23 | <field name="department_id" widget="selection"/> | ||
312 | 24 | </field> | ||
313 | 25 | </field> | ||
314 | 26 | </record> | ||
315 | 27 | |||
316 | 28 | <record id="view_account_invoice_filter" model="ir.ui.view"> | ||
317 | 29 | <field name="name">account.invoice.select</field> | ||
318 | 30 | <field name="model">account.invoice</field> | ||
319 | 31 | <field name="inherit_id" ref="account.view_account_invoice_filter" /> | ||
320 | 32 | <field name="arch" type="xml"> | ||
321 | 33 | <field name="period_id" position="replace"> | ||
322 | 34 | <field name="journal_id" widget="selection"/> | ||
323 | 35 | <field name="department_id" widget="selection"/> | ||
324 | 36 | <field name="period_id" string="Period"/> | ||
325 | 37 | </field> | ||
326 | 38 | <filter string="Partner" position="after"> | ||
327 | 39 | <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/> | ||
328 | 40 | </filter> | ||
329 | 41 | </field> | ||
330 | 42 | </record> | ||
331 | 43 | |||
332 | 44 | <record id="invoice_supplier_form" model="ir.ui.view"> | ||
333 | 45 | <field name="name">account.invoice.supplier.form</field> | ||
334 | 46 | <field name="model">account.invoice</field> | ||
335 | 47 | <field name="inherit_id" ref="account.invoice_supplier_form" /> | ||
336 | 48 | <field name="priority">2</field> | ||
337 | 49 | <field name="arch" type="xml"> | ||
338 | 50 | <field name="company_id" position="before"> | ||
339 | 51 | <field name="department_id" widget="selection"/> | ||
340 | 52 | </field> | ||
341 | 53 | </field> | ||
342 | 54 | </record> | ||
343 | 55 | |||
344 | 56 | </data> | ||
345 | 57 | </openerp> |
LGTM