Merge lp:~camptocamp/department-mgmt/7.0-port-invoice_department into lp:~department-core-editors/department-mgmt/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
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: mp+162132@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
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 # -*- coding: utf-8 -*-
6 ##############################################################################
7 #
8-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
9-# All Right Reserved
10-#
11-# Author : Joel Grand-guillaume (Camptocamp)
12-#
13-# WARNING: This program as such is intended to be used by professional
14-# programmers who take the whole responsability of assessing all potential
15-# consequences resulting from its eventual inadequacies and bugs
16-# End users who are looking for a ready-to-use solution with commercial
17-# garantees and support are strongly adviced to contract a Free Software
18-# Service Company
19-#
20-# This program is Free Software; you can redistribute it and/or
21-# modify it under the terms of the GNU General Public License
22-# as published by the Free Software Foundation; either version 2
23-# of the License, or (at your option) any later version.
24-#
25-# This program is distributed in the hope that it will be useful,
26-# but WITHOUT ANY WARRANTY; without even the implied warranty of
27-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28-# GNU General Public License for more details.
29-#
30-# You should have received a copy of the GNU General Public License
31-# along with this program; if not, write to the Free Software
32-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33+# Author: Joël Grand-guillaume (Camptocamp)
34+# Copyright 2010 Camptocamp SA
35+#
36+# This program is free software: you can redistribute it and/or modify
37+# it under the terms of the GNU Affero General Public License as
38+# published by the Free Software Foundation, either version 3 of the
39+# License, or (at your option) any later version.
40+#
41+# This program is distributed in the hope that it will be useful,
42+# but WITHOUT ANY WARRANTY; without even the implied warranty of
43+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44+# GNU Affero General Public License for more details.
45+#
46+# You should have received a copy of the GNU Affero General Public License
47+# along with this program. If not, see <http://www.gnu.org/licenses/>.
48 #
49 ##############################################################################
50 import invoice
51+
52+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
53
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 # -*- coding: utf-8 -*-
59 ##############################################################################
60 #
61-# Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com)
62-# All Right Reserved
63-#
64-# Author : Joel Grand-guillaume (Camptocamp)
65-#
66-# WARNING: This program as such is intended to be used by professional
67-# programmers who take the whole responsability of assessing all potential
68-# consequences resulting from its eventual inadequacies and bugs
69-# End users who are looking for a ready-to-use solution with commercial
70-# garantees and support are strongly adviced to contract a Free Software
71-# Service Company
72-#
73-# This program is Free Software; you can redistribute it and/or
74-# modify it under the terms of the GNU General Public License
75-# as published by the Free Software Foundation; either version 2
76-# of the License, or (at your option) any later version.
77-#
78-# This program is distributed in the hope that it will be useful,
79-# but WITHOUT ANY WARRANTY; without even the implied warranty of
80-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81-# GNU General Public License for more details.
82-#
83-# You should have received a copy of the GNU General Public License
84-# along with this program; if not, write to the Free Software
85-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
86+# Author: Joël Grand-guillaume (Camptocamp)
87+# Copyright 2010 Camptocamp SA
88+#
89+# This program is free software: you can redistribute it and/or modify
90+# it under the terms of the GNU Affero General Public License as
91+# published by the Free Software Foundation, either version 3 of the
92+# License, or (at your option) any later version.
93+#
94+# This program is distributed in the hope that it will be useful,
95+# but WITHOUT ANY WARRANTY; without even the implied warranty of
96+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+# GNU Affero General Public License for more details.
98+#
99+# You should have received a copy of the GNU Affero General Public License
100+# along with this program. If not, see <http://www.gnu.org/licenses/>.
101 #
102 ##############################################################################
103
104 {
105- "name" : "Invoices with Department Categorization",
106- "version" : "1.0",
107- "author" : "Camptocamp",
108- "category" : "Generic Modules/Sales & Purchases",
109- "description":
110-"""Add the department on Invoices.
111+ 'name' : 'Invoices with Department Categorization',
112+ 'version' : '1.0',
113+ 'category' : 'Generic Modules/Sales & Purchases',
114+ 'description':
115+'''
116+ Add the department on Invoices as well as the related filter and button in the search form.
117
118-The views are adapted to use the information in the search form.""",
119- "website": "http://camptocamp.com",
120- "depends" : [
121- "account",
122- "hr"
123- ],
124- "init_xml" : [],
125- "demo_xml" : [],
126- "update_xml" : [
127- "invoice_view.xml",
128- ],
129- "active": False,
130- 'installable': False
131+''',
132+ 'author' : 'Camptocamp',
133+ 'website': 'http://camptocamp.com',
134+ 'depends' : ['account', 'hr'],
135+ 'data' : ['invoice_view.xml',],
136+ 'demo' : [],
137+ 'test': [],
138+ 'installable': True,
139+ 'auto_install': False,
140+ 'application': False
141 }
142+
143+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
144
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 # -*- coding: utf-8 -*-
150 ##############################################################################
151 #
152-# Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
153-# All Right Reserved
154-#
155-# Author : Joel Grand-guillaume (Camptocamp)
156-#
157-# WARNING: This program as such is intended to be used by professional
158-# programmers who take the whole responsability of assessing all potential
159-# consequences resulting from its eventual inadequacies and bugs
160-# End users who are looking for a ready-to-use solution with commercial
161-# garantees and support are strongly adviced to contract a Free Software
162-# Service Company
163-#
164-# This program is Free Software; you can redistribute it and/or
165-# modify it under the terms of the GNU General Public License
166-# as published by the Free Software Foundation; either version 2
167-# of the License, or (at your option) any later version.
168-#
169-# This program is distributed in the hope that it will be useful,
170-# but WITHOUT ANY WARRANTY; without even the implied warranty of
171-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
172-# GNU General Public License for more details.
173-#
174-# You should have received a copy of the GNU General Public License
175-# along with this program; if not, write to the Free Software
176-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
177+# Author: Joël Grand-guillaume (Camptocamp)
178+# Copyright 2010 Camptocamp SA
179+#
180+# This program is free software: you can redistribute it and/or modify
181+# it under the terms of the GNU Affero General Public License as
182+# published by the Free Software Foundation, either version 3 of the
183+# License, or (at your option) any later version.
184+#
185+# This program is distributed in the hope that it will be useful,
186+# but WITHOUT ANY WARRANTY; without even the implied warranty of
187+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
188+# GNU Affero General Public License for more details.
189+#
190+# You should have received a copy of the GNU Affero General Public License
191+# along with this program. If not, see <http://www.gnu.org/licenses/>.
192 #
193 ##############################################################################
194-
195-from osv import osv
196-from osv import fields
197-
198-class account_invoice(osv.osv):
199+from openerp.osv import orm, fields
200+
201+class AccountInvoice(orm.Model):
202 _inherit = "account.invoice"
203-
204 _columns = {
205 'department_id': fields.many2one('hr.department', 'Department'),
206- }
207+ }
208+
209+ def _get_department(self, cr, uid, ids, context=None):
210+ employee_obj = self.pool.get('hr.employee')
211+ department_id = False
212+ employee_ids = employee_obj.search(cr, uid, [('user_id','=', uid)])
213+ if employee_ids:
214+ department_id = employee_obj.browse(cr, uid, employee_ids[0], context=context).department_id.id
215+ return department_id
216+
217 _defaults = {
218- 'department_id': lambda s,cr,uid,c: s.pool.get('res.users').browse(cr,uid,uid).context_department_id.id,
219- }
220+ 'department_id': _get_department,
221+ }
222
223-account_invoice()
224+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
225
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+<?xml version="1.0" encoding="utf-8"?>
231 <openerp>
232- <data>
233- <record id="invoice_tree" model="ir.ui.view">
234- <field name="name">account.invoice.tree</field>
235- <field name="model">account.invoice</field>
236- <field name="inherit_id" ref="account.invoice_tree" />
237- <field name="type">tree</field>
238- <field name="arch" type="xml">
239- <xpath expr="/tree/field[@name='company_id']" position="before">
240- <field name="department_id" />
241- </xpath>
242- </field>
243- </record>
244-
245- <record id="invoice_form" model="ir.ui.view">
246- <field name="name">account.invoice.form</field>
247- <field name="model">account.invoice</field>
248- <field name="inherit_id" ref="account.invoice_form" />
249- <field name="type">form</field>
250- <field name="arch" type="xml">
251- <xpath expr="/form/notebook/page[@string='Other Info']/field[@name='company_id']" position="before">
252- <field name="department_id" widget="selection"/>
253- </xpath>
254- </field>
255- </record>
256-
257- <record id="view_account_invoice_filter" model="ir.ui.view">
258- <field name="name">account.invoice.select</field>
259- <field name="model">account.invoice</field>
260- <field name="inherit_id" ref="account.view_account_invoice_filter" />
261- <field name="type">search</field>
262- <field name="arch" type="xml">
263- <xpath expr="/search/group[2]" position="replace">
264- <group col="10" colspan="4">
265- <field name="journal_id" widget="selection" select='1'/>
266- <field name="department_id" select="1" widget="selection"/>
267- <field name="period_id" select='1' string="Period"/>
268- </group>
269- </xpath>
270- <xpath expr="/search/group/filter[@string='Partner']" position="after">
271- <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/>
272- </xpath>
273- </field>
274- </record>
275-
276- <record id="invoice_supplier_form" model="ir.ui.view">
277- <field name="name">account.invoice.supplier.form</field>
278- <field name="model">account.invoice</field>
279- <field name="inherit_id" ref="account.invoice_supplier_form" />
280- <field name="type">form</field>
281- <field name="priority">2</field>
282- <field name="arch" type="xml">
283- <xpath expr="/form/notebook/page[@string='Other Info']/field[@name='company_id']" position="before">
284- <field name="department_id" widget="selection"/>
285- </xpath>
286- </field>
287- </record>
288-
289- </data>
290-</openerp>
291\ No newline at end of file
292+ <data>
293+
294+ <record id="invoice_tree" model="ir.ui.view">
295+ <field name="name">account.invoice.tree</field>
296+ <field name="model">account.invoice</field>
297+ <field name="inherit_id" ref="account.invoice_tree" />
298+ <field name="arch" type="xml">
299+ <field name="company_id" position="before">
300+ <field name="department_id" />
301+ </field>
302+ </field>
303+ </record>
304+
305+ <record id="invoice_form" model="ir.ui.view">
306+ <field name="name">account.invoice.form</field>
307+ <field name="model">account.invoice</field>
308+ <field name="inherit_id" ref="account.invoice_form" />
309+ <field name="arch" type="xml">
310+ <field name="company_id" position="before">
311+ <field name="department_id" widget="selection"/>
312+ </field>
313+ </field>
314+ </record>
315+
316+ <record id="view_account_invoice_filter" model="ir.ui.view">
317+ <field name="name">account.invoice.select</field>
318+ <field name="model">account.invoice</field>
319+ <field name="inherit_id" ref="account.view_account_invoice_filter" />
320+ <field name="arch" type="xml">
321+ <field name="period_id" position="replace">
322+ <field name="journal_id" widget="selection"/>
323+ <field name="department_id" widget="selection"/>
324+ <field name="period_id" string="Period"/>
325+ </field>
326+ <filter string="Partner" position="after">
327+ <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/>
328+ </filter>
329+ </field>
330+ </record>
331+
332+ <record id="invoice_supplier_form" model="ir.ui.view">
333+ <field name="name">account.invoice.supplier.form</field>
334+ <field name="model">account.invoice</field>
335+ <field name="inherit_id" ref="account.invoice_supplier_form" />
336+ <field name="priority">2</field>
337+ <field name="arch" type="xml">
338+ <field name="company_id" position="before">
339+ <field name="department_id" widget="selection"/>
340+ </field>
341+ </field>
342+ </record>
343+
344+ </data>
345+</openerp>

Subscribers

People subscribed via source and target branches