Merge lp:~camptocamp/department-mgmt/7.0-port-sale_department into lp:~department-core-editors/department-mgmt/7.0
- 7.0-port-sale_department
- Merge into 7.0
Status: | Merged |
---|---|
Approved by: | Daniel Reis |
Approved revision: | 18 |
Merged at revision: | 15 |
Proposed branch: | lp:~camptocamp/department-mgmt/7.0-port-sale_department |
Merge into: | lp:~department-core-editors/department-mgmt/7.0 |
Diff against target: |
318 lines (+134/-131) 4 files modified
sale_department/__init__.py (+3/-1) sale_department/__openerp__.py (+33/-46) sale_department/sale.py (+46/-40) sale_department/sale_view.xml (+52/-44) |
To merge this branch: | bzr merge lp:~camptocamp/department-mgmt/7.0-port-sale_department |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Reis | tested install, no errors. | Approve | |
Nhomar - Vauxoo | Approve | ||
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel Reis (dreis-pt) wrote : | # |
Hmmm ... my tests return an error message when installing.
Maybe this happens because I don't have multicompany installed?
2013-07-15 16:57:25,471 26929 ERROR dept7-dev openerp.
<record id="invoice_form" model="ir.ui.view">
<field name="name"
<field name="model"
<field name="inherit_id" ref="account.
<field name="arch" type="xml">
<field name="company_id" position="before">
<field name="departmen
</field>
</field>
</record>
(...)
2013-07-15 16:57:25,475 26929 ERROR dept7-dev openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
This issue doesn't seems to come from sale_department but from its dependency invoice_department which conflicts with portal_sale (auto installed with portal and sale thus with sale_department).
To complete install of sale_department from scratch I had to do those steps:
- comment invoice_form and invoice_
- comment invoice_
- launch OpenERP with --update=all
- uncomment view in portal_sale
- launch OpenERP with --update=
- uncomment view in invoice_department
- launch OpenERP with --update=
I guess this is due to some OpenERP bug in view inheritance...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Somehow, on update of portal_sale, it uses some cached view trying to read department_id before it has been defined by invoice_department.
We cannot make invoice_department depending on portal_sale as it doesn't make sense. Let's see if a new bug report on view inheritance bring us some solution to this.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Finally it seems it is simply in invoice_department that we try to add the field department_id before company_id of invoice line instead of doing it before the company_id of invoice. Funny I could install invoice_department anyway...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel Reis (dreis-pt) wrote : | # |
As a suggestion for future improvement:
From a usability PoV, the widget "selection" is only appropriate for small lists of items (less than a handfull).
In this case, when the Department list grows significantly (in my case, many dozens of records) it gets harder to use.
So, the default v7 search-as-you-type list widget will probably be more adequate here.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Thanks for the review.
You are right using completion instead of selection makes sense with dozens of departments.
I kept it like this as we haven't such case with that many departments but to be more generic it would be a good improvement.
Actually we have half of department-mgmt using selection and half using default completion.
So we will have to change it in the following modules:
crm_department
invoice_department
sale_department
Preview Diff
1 | === modified file 'sale_department/__init__.py' | |||
2 | --- sale_department/__init__.py 2011-08-12 12:53:16 +0000 | |||
3 | +++ sale_department/__init__.py 2013-06-19 06:55:30 +0000 | |||
4 | @@ -1,7 +1,7 @@ | |||
5 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
6 | 2 | ############################################################################## | 2 | ############################################################################## |
7 | 3 | # | 3 | # |
9 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) |
10 | 5 | # All Right Reserved | 5 | # All Right Reserved |
11 | 6 | # | 6 | # |
12 | 7 | # Author : Joel Grand-guillaume (Camptocamp) | 7 | # Author : Joel Grand-guillaume (Camptocamp) |
13 | @@ -30,3 +30,5 @@ | |||
14 | 30 | ############################################################################## | 30 | ############################################################################## |
15 | 31 | 31 | ||
16 | 32 | import sale | 32 | import sale |
17 | 33 | |||
18 | 34 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
19 | 33 | \ No newline at end of file | 35 | \ No newline at end of file |
20 | 34 | 36 | ||
21 | === modified file 'sale_department/__openerp__.py' | |||
22 | --- sale_department/__openerp__.py 2013-01-04 10:32:58 +0000 | |||
23 | +++ sale_department/__openerp__.py 2013-06-19 06:55:30 +0000 | |||
24 | @@ -1,55 +1,42 @@ | |||
25 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
26 | 2 | ############################################################################## | 2 | ############################################################################## |
27 | 3 | # | 3 | # |
53 | 4 | # Copyright (c) 2011 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Joël Grand-guillaume (Camptocamp) |
54 | 5 | # All Right Reserved | 5 | # Copyright 2011 Camptocamp SA |
55 | 6 | # | 6 | # |
56 | 7 | # Author : Joel Grand-guillaume (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
57 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
58 | 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 |
59 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
60 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
61 | 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, |
62 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
63 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
64 | 15 | # | 15 | # GNU Affero General Public License for more details. |
65 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
66 | 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 |
67 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
43 | 19 | # of the License, or (at your option) any later version. | ||
44 | 20 | # | ||
45 | 21 | # This program is distributed in the hope that it will be useful, | ||
46 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
47 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
48 | 24 | # GNU General Public License for more details. | ||
49 | 25 | # | ||
50 | 26 | # You should have received a copy of the GNU General Public License | ||
51 | 27 | # along with this program; if not, write to the Free Software | ||
52 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
68 | 29 | # | 19 | # |
69 | 30 | ############################################################################## | 20 | ############################################################################## |
70 | 31 | |||
71 | 32 | { | 21 | { |
78 | 33 | "name" : "Sales Order with Department Categorization", | 22 | 'name' : 'Sales Order with Department Categorization', |
79 | 34 | "version" : "1.0", | 23 | 'version' : '1.0', |
80 | 35 | "author" : "Camptocamp", | 24 | 'category' : 'Generic Modules/Sales & Purchases', |
81 | 36 | "category" : "Generic Modules/Sales & Purchases", | 25 | 'description': |
82 | 37 | "description": | 26 | ''' |
77 | 38 | """ | ||
83 | 39 | Add the department on Sales Order and Customer Invoices as well as the related filter and button in the search form. | 27 | Add the department on Sales Order and Customer Invoices as well as the related filter and button in the search form. |
96 | 40 | 28 | ||
97 | 41 | """, | 29 | ''', |
98 | 42 | "website": "http://camptocamp.com", | 30 | 'author' : 'Camptocamp', |
99 | 43 | "depends" : [ | 31 | 'website': 'http://camptocamp.com', |
100 | 44 | "sale", | 32 | 'depends' : ['sale', 'invoice_department', 'hr'], |
101 | 45 | "invoice_department", | 33 | 'data' : [ |
102 | 46 | "hr" | 34 | 'sale_view.xml', |
91 | 47 | ], | ||
92 | 48 | "init_xml" : [], | ||
93 | 49 | "demo_xml" : [], | ||
94 | 50 | "update_xml" : [ | ||
95 | 51 | "sale_view.xml", | ||
103 | 52 | ], | 35 | ], |
106 | 53 | "active": False, | 36 | 'demo' : [], |
107 | 54 | 'installable': False | 37 | 'installable': True, |
108 | 38 | 'auto_install': False, | ||
109 | 39 | 'application': False, | ||
110 | 55 | } | 40 | } |
111 | 41 | |||
112 | 42 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
113 | 56 | 43 | ||
114 | === modified file 'sale_department/sale.py' | |||
115 | --- sale_department/sale.py 2011-08-12 12:53:16 +0000 | |||
116 | +++ sale_department/sale.py 2013-06-19 06:55:30 +0000 | |||
117 | @@ -1,51 +1,57 @@ | |||
118 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
119 | 2 | ############################################################################## | 2 | ############################################################################## |
120 | 3 | # | 3 | # |
146 | 4 | # Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com) | 4 | # Author: Joël Grand-guillaume (Camptocamp) |
147 | 5 | # All Right Reserved | 5 | # Copyright 2010 Camptocamp SA |
148 | 6 | # | 6 | # |
149 | 7 | # Author : Joel Grand-guillaume (Camptocamp) | 7 | # This program is free software: you can redistribute it and/or modify |
150 | 8 | # | 8 | # it under the terms of the GNU Affero General Public License as |
151 | 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 |
152 | 10 | # programmers who take the whole responsability of assessing all potential | 10 | # License, or (at your option) any later version. |
153 | 11 | # consequences resulting from its eventual inadequacies and bugs | 11 | # |
154 | 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, |
155 | 13 | # garantees and support are strongly adviced to contract a Free Software | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
156 | 14 | # Service Company | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
157 | 15 | # | 15 | # GNU Affero General Public License for more details. |
158 | 16 | # This program is Free Software; you can redistribute it and/or | 16 | # |
159 | 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 |
160 | 18 | # as published by the Free Software Foundation; either version 2 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
136 | 19 | # of the License, or (at your option) any later version. | ||
137 | 20 | # | ||
138 | 21 | # This program is distributed in the hope that it will be useful, | ||
139 | 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
140 | 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
141 | 24 | # GNU General Public License for more details. | ||
142 | 25 | # | ||
143 | 26 | # You should have received a copy of the GNU General Public License | ||
144 | 27 | # along with this program; if not, write to the Free Software | ||
145 | 28 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
161 | 29 | # | 19 | # |
162 | 30 | ############################################################################## | 20 | ############################################################################## |
170 | 31 | 21 | from openerp.osv import orm, fields | |
171 | 32 | from osv import osv | 22 | |
172 | 33 | from osv import fields | 23 | class SaleOrder(orm.Model): |
173 | 34 | 24 | _inherit = 'sale.order' | |
167 | 35 | class sale_order(osv.osv): | ||
168 | 36 | _inherit = "sale.order" | ||
169 | 37 | |||
174 | 38 | _columns = { | 25 | _columns = { |
175 | 39 | 'department_id': fields.many2one('hr.department', 'Department'), | 26 | 'department_id': fields.many2one('hr.department', 'Department'), |
177 | 40 | } | 27 | } |
178 | 28 | |||
179 | 29 | def _get_department(self, cr, uid, ids, context=None): | ||
180 | 30 | employee_obj = self.pool.get('hr.employee') | ||
181 | 31 | department_id = False | ||
182 | 32 | employee_ids = employee_obj.search( | ||
183 | 33 | cr, uid, | ||
184 | 34 | [('user_id','=', uid)], | ||
185 | 35 | context=context) | ||
186 | 36 | if employee_ids: | ||
187 | 37 | department_id = employee_obj.browse( | ||
188 | 38 | cr, uid, employee_ids[0], | ||
189 | 39 | context=context).department_id.id | ||
190 | 40 | return department_id | ||
191 | 41 | |||
192 | 41 | _defaults = { | 42 | _defaults = { |
196 | 42 | 'department_id': lambda s,cr,uid,c: s.pool.get('res.users').browse(cr,uid,uid).context_department_id.id, | 43 | 'department_id': _get_department, |
197 | 43 | } | 44 | } |
198 | 44 | 45 | ||
199 | 45 | def _make_invoice(self, cr, uid, order, lines, context=None): | 46 | def _make_invoice(self, cr, uid, order, lines, context=None): |
202 | 46 | res = super(sale_order,self)._make_invoice(cr,uid,order,lines,context) | 47 | invoice_obj = self.pool.get('account.invoice') |
203 | 47 | self.pool.get('account.invoice').write(cr,uid,res,{'department_id':order.department_id.id},context) | 48 | res = super(SaleOrder, self)._make_invoice( |
204 | 49 | cr, uid, order, | ||
205 | 50 | lines, context=context) | ||
206 | 51 | invoice_obj.write( | ||
207 | 52 | cr, uid, res, | ||
208 | 53 | {'department_id': order.department_id.id}, | ||
209 | 54 | context=context) | ||
210 | 48 | return res | 55 | return res |
211 | 49 | |||
212 | 50 | 56 | ||
213 | 51 | sale_order() | ||
214 | 52 | \ No newline at end of file | 57 | \ No newline at end of file |
215 | 58 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
216 | 53 | 59 | ||
217 | === modified file 'sale_department/sale_view.xml' (properties changed: +x to -x) | |||
218 | --- sale_department/sale_view.xml 2011-08-12 12:53:16 +0000 | |||
219 | +++ sale_department/sale_view.xml 2013-06-19 06:55:30 +0000 | |||
220 | @@ -1,45 +1,53 @@ | |||
221 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
222 | 1 | <openerp> | 2 | <openerp> |
223 | 2 | <data> | ||
224 | 3 | |||
225 | 4 | <record id="view_order_tree" model="ir.ui.view"> | ||
226 | 5 | <field name="name">sale.order.tree</field> | ||
227 | 6 | <field name="model">sale.order</field> | ||
228 | 7 | <field name="type">tree</field> | ||
229 | 8 | <field name="inherit_id" ref="sale.view_order_tree" /> | ||
230 | 9 | <field name="arch" type="xml"> | ||
231 | 10 | <xpath expr="/tree/field[@name='user_id']" position="after"> | ||
232 | 11 | <field name="department_id" /> | ||
233 | 12 | </xpath> | ||
234 | 13 | </field> | ||
235 | 14 | </record> | ||
236 | 15 | |||
237 | 16 | <record id="view_order_form" model="ir.ui.view"> | ||
238 | 17 | <field name="name">sale.order.form</field> | ||
239 | 18 | <field name="model">sale.order</field> | ||
240 | 19 | <field name="type">form</field> | ||
241 | 20 | <field name="inherit_id" ref="sale.view_order_form" /> | ||
242 | 21 | <field name="arch" type="xml"> | ||
243 | 22 | <xpath expr="/form/notebook/page[@string='Other Information']/group/field[@name='user_id']" position="after"> | ||
244 | 23 | <field name="department_id" widget="selection"/> | ||
245 | 24 | </xpath> | ||
246 | 25 | </field> | ||
247 | 26 | </record> | ||
248 | 27 | |||
249 | 28 | <record id="view_sales_order_filter" model="ir.ui.view"> | ||
250 | 29 | <field name="name">sale.order.list.select</field> | ||
251 | 30 | <field name="model">sale.order</field> | ||
252 | 31 | <field name="type">search</field> | ||
253 | 32 | <field name="inherit_id" ref="sale.view_sales_order_filter" /> | ||
254 | 33 | <field name="arch" type="xml"> | ||
255 | 34 | <xpath expr="/search/group/filter[@string='Salesman']" position="after"> | ||
256 | 35 | <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/> | ||
257 | 36 | </xpath> | ||
258 | 37 | <xpath expr="/search/field[@name='partner_id']" position="after"> | ||
259 | 38 | <field name="department_id" select="1" widget="selection"/> | ||
260 | 39 | </xpath> | ||
261 | 40 | </field> | ||
262 | 41 | </record> | ||
263 | 42 | |||
264 | 43 | |||
265 | 44 | </data> | ||
266 | 45 | </openerp> | ||
267 | 46 | \ No newline at end of file | 3 | \ No newline at end of file |
268 | 4 | <data> | ||
269 | 5 | |||
270 | 6 | <record id="view_quotation_tree" model="ir.ui.view"> | ||
271 | 7 | <field name="name">sale.order.tree</field> | ||
272 | 8 | <field name="model">sale.order</field> | ||
273 | 9 | <field name="inherit_id" ref="sale.view_quotation_tree" /> | ||
274 | 10 | <field name="arch" type="xml"> | ||
275 | 11 | <field name="user_id" position="after"> | ||
276 | 12 | <field name="department_id" /> | ||
277 | 13 | </field> | ||
278 | 14 | </field> | ||
279 | 15 | </record> | ||
280 | 16 | |||
281 | 17 | <record id="view_order_tree" model="ir.ui.view"> | ||
282 | 18 | <field name="name">sale.order.tree</field> | ||
283 | 19 | <field name="model">sale.order</field> | ||
284 | 20 | <field name="inherit_id" ref="sale.view_order_tree" /> | ||
285 | 21 | <field name="arch" type="xml"> | ||
286 | 22 | <field name="user_id" position="after"> | ||
287 | 23 | <field name="department_id" /> | ||
288 | 24 | </field> | ||
289 | 25 | </field> | ||
290 | 26 | </record> | ||
291 | 27 | |||
292 | 28 | <record id="view_order_form" model="ir.ui.view"> | ||
293 | 29 | <field name="name">sale.order.form</field> | ||
294 | 30 | <field name="model">sale.order</field> | ||
295 | 31 | <field name="inherit_id" ref="sale.view_order_form" /> | ||
296 | 32 | <field name="arch" type="xml"> | ||
297 | 33 | <field name="user_id" position="after"> | ||
298 | 34 | <field name="department_id" widget="selection"/> | ||
299 | 35 | </field> | ||
300 | 36 | </field> | ||
301 | 37 | </record> | ||
302 | 38 | |||
303 | 39 | <record id="view_sales_order_filter" model="ir.ui.view"> | ||
304 | 40 | <field name="name">sale.order.list.select</field> | ||
305 | 41 | <field name="model">sale.order</field> | ||
306 | 42 | <field name="inherit_id" ref="sale.view_sales_order_filter" /> | ||
307 | 43 | <field name="arch" type="xml"> | ||
308 | 44 | <xpath expr="//filter[@string='Salesperson']" position="after"> | ||
309 | 45 | <filter string="Department" icon="terp-folder-orange" domain="[]" context="{'group_by':'department_id'}"/> | ||
310 | 46 | </xpath> | ||
311 | 47 | <field name="partner_id" position="after"> | ||
312 | 48 | <field name="department_id" widget="selection"/> | ||
313 | 49 | </field> | ||
314 | 50 | </field> | ||
315 | 51 | </record> | ||
316 | 52 | |||
317 | 53 | </data> | ||
318 | 54 | </openerp> |
Approve.
Just Code Review. No test.