Merge lp:~camptocamp/sale-reports/add-html-note-flow into lp:~sale-core-editors/sale-reports/7.0

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 17
Merged at revision: 16
Proposed branch: lp:~camptocamp/sale-reports/add-html-note-flow
Merge into: lp:~sale-core-editors/sale-reports/7.0
Diff against target: 326 lines (+257/-7)
8 files modified
html_sale_product_note/__init__.py (+22/-0)
html_sale_product_note/__openerp__.py (+39/-0)
html_sale_product_note/product.py (+28/-0)
html_sale_product_note/sale_order.py (+51/-0)
sale_note_flow/__init__.py (+21/-0)
sale_note_flow/__openerp__.py (+43/-0)
sale_note_flow/sale.py (+44/-0)
sale_order_webkit/sale.py (+9/-7)
To merge this branch: bzr merge lp:~camptocamp/sale-reports/add-html-note-flow
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+153371@code.launchpad.net

Description of the change

Add sale_note_flow + html_sale_product_note
Some pep8

To post a comment you must log in.
17. By Alexandre Fayolle - camptocamp

[IMP] updated __openerp__.py of both new modules

* improved description
* merged init_xml/update_xml in data, removed demo_xml

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

I updated __openerp__.py of both new modules.

LGTM

review: Approve (code review, no test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'html_sale_product_note'
2=== added file 'html_sale_product_note/__init__.py'
3--- html_sale_product_note/__init__.py 1970-01-01 00:00:00 +0000
4+++ html_sale_product_note/__init__.py 2013-03-18 09:03:21 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
10+# @author Nicolas Bessi
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+from . import product
27+from . import sale_order
28
29=== added file 'html_sale_product_note/__openerp__.py'
30--- html_sale_product_note/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ html_sale_product_note/__openerp__.py 2013-03-18 09:03:21 +0000
32@@ -0,0 +1,39 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
37+# @author Nicolas Bessi
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU Affero General Public License as
41+# published by the Free Software Foundation, either version 3 of the
42+# License, or (at your option) any later version.
43+#
44+# This program is distributed in the hope that it will be useful,
45+# but WITHOUT ANY WARRANTY; without even the implied warranty of
46+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47+# GNU Affero General Public License for more details.
48+#
49+# You should have received a copy of the GNU Affero General Public License
50+# along with this program. If not, see <http://www.gnu.org/licenses/>.
51+#
52+##############################################################################
53+
54+{'name': 'HTML note in product reported in sale order report',
55+ 'version': '1.0.1',
56+ 'category': 'other',
57+ 'description': """
58+Sale product note
59+=================
60+
61+This module replaces sale description in product with a HTML field.
62+It also adds this description into the HTML note
63+of the sale order line when the product is set.""",
64+ 'author': 'Camptocamp',
65+ 'website': 'http://www.camptocamp.com',
66+ 'depends': ['product', 'sale', 'sale_order_webkit'],
67+ 'data': [],
68+ 'test': [],
69+ 'installable': True,
70+ 'active': False,
71+ }
72
73=== added file 'html_sale_product_note/product.py'
74--- html_sale_product_note/product.py 1970-01-01 00:00:00 +0000
75+++ html_sale_product_note/product.py 2013-03-18 09:03:21 +0000
76@@ -0,0 +1,28 @@
77+# -*- coding: utf-8 -*-
78+##############################################################################
79+#
80+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
81+# @author Nicolas Bessi
82+#
83+# This program is free software: you can redistribute it and/or modify
84+# it under the terms of the GNU Affero General Public License as
85+# published by the Free Software Foundation, either version 3 of the
86+# License, or (at your option) any later version.
87+#
88+# This program is distributed in the hope that it will be useful,
89+# but WITHOUT ANY WARRANTY; without even the implied warranty of
90+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91+# GNU Affero General Public License for more details.
92+#
93+# You should have received a copy of the GNU Affero General Public License
94+# along with this program. If not, see <http://www.gnu.org/licenses/>.
95+#
96+##############################################################################
97+from openerp.osv import orm, fields
98+
99+
100+class ProductTemplate(orm.Model):
101+
102+ _inherit = 'product.template'
103+
104+ _columns = {'description_sale': fields.html('Sale Description')}
105
106=== added file 'html_sale_product_note/sale_order.py'
107--- html_sale_product_note/sale_order.py 1970-01-01 00:00:00 +0000
108+++ html_sale_product_note/sale_order.py 2013-03-18 09:03:21 +0000
109@@ -0,0 +1,51 @@
110+# -*- coding: utf-8 -*-
111+##############################################################################
112+#
113+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
114+# @author Nicolas Bessi
115+#
116+# This program is free software: you can redistribute it and/or modify
117+# it under the terms of the GNU Affero General Public License as
118+# published by the Free Software Foundation, either version 3 of the
119+# License, or (at your option) any later version.
120+#
121+# This program is distributed in the hope that it will be useful,
122+# but WITHOUT ANY WARRANTY; without even the implied warranty of
123+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124+# GNU Affero General Public License for more details.
125+#
126+# You should have received a copy of the GNU Affero General Public License
127+# along with this program. If not, see <http://www.gnu.org/licenses/>.
128+#
129+##############################################################################
130+from openerp.osv import orm
131+
132+
133+class SaleOrderLine(orm.Model):
134+
135+ _inherit = 'sale.order.line'
136+
137+ def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
138+ uom=False, qty_uos=0, uos=False, name='', partner_id=False,
139+ lang=False, update_tax=True, date_order=False, packaging=False,
140+ fiscal_position=False, flag=False, context=None):
141+
142+ # Can you feel the pain?
143+ res = super(SaleOrderLine, self).product_id_change(cr, uid, ids, pricelist,
144+ product, qty=qty,
145+ uom=uom, qty_uos=0,
146+ uos=uos, name=name,
147+ partner_id=partner_id,
148+ lang=lang, update_tax=update_tax,
149+ date_order=date_order,
150+ packaging=packaging,
151+ fiscal_position=fiscal_position,
152+ flag=flag, context=context)
153+ if not product:
154+ return res
155+ pobj = self.pool['product.product']
156+ product_name = pobj.name_get(cr, uid, [product], context=context)[0][1]
157+ product_note = pobj.read(cr, uid, product, ['description_sale'], context=context)
158+ res['value']['name'] = product_name
159+ res['value']['formatted_note'] = product_note['description_sale']
160+ return res
161
162=== added directory 'sale_note_flow'
163=== added file 'sale_note_flow/__init__.py'
164--- sale_note_flow/__init__.py 1970-01-01 00:00:00 +0000
165+++ sale_note_flow/__init__.py 2013-03-18 09:03:21 +0000
166@@ -0,0 +1,21 @@
167+# -*- coding: utf-8 -*-
168+##############################################################################
169+#
170+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
171+# @author Nicolas Bessi
172+#
173+# This program is free software: you can redistribute it and/or modify
174+# it under the terms of the GNU Affero General Public License as
175+# published by the Free Software Foundation, either version 3 of the
176+# License, or (at your option) any later version.
177+#
178+# This program is distributed in the hope that it will be useful,
179+# but WITHOUT ANY WARRANTY; without even the implied warranty of
180+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181+# GNU Affero General Public License for more details.
182+#
183+# You should have received a copy of the GNU Affero General Public License
184+# along with this program. If not, see <http://www.gnu.org/licenses/>.
185+#
186+##############################################################################
187+from . import sale
188
189=== added file 'sale_note_flow/__openerp__.py'
190--- sale_note_flow/__openerp__.py 1970-01-01 00:00:00 +0000
191+++ sale_note_flow/__openerp__.py 2013-03-18 09:03:21 +0000
192@@ -0,0 +1,43 @@
193+# -*- coding: utf-8 -*-
194+##############################################################################
195+#
196+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
197+# @author Nicolas Bessi
198+#
199+# This program is free software: you can redistribute it and/or modify
200+# it under the terms of the GNU Affero General Public License as
201+# published by the Free Software Foundation, either version 3 of the
202+# License, or (at your option) any later version.
203+#
204+# This program is distributed in the hope that it will be useful,
205+# but WITHOUT ANY WARRANTY; without even the implied warranty of
206+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
207+# GNU Affero General Public License for more details.
208+#
209+# You should have received a copy of the GNU Affero General Public License
210+# along with this program. If not, see <http://www.gnu.org/licenses/>.
211+#
212+##############################################################################
213+
214+{'name': 'HTML note from sale order in invoice',
215+ 'version': '1.0.0',
216+ 'category': 'other',
217+ 'description': """
218+Sale order to invoice notes
219+===========================
220+
221+This module forwards the `note` field of sale order lines to the
222+`note` field of invoice line when an invoice in generated from a sale
223+order.
224+""",
225+ 'author': 'Camptocamp',
226+ 'website': 'http://www.camptocamp.com',
227+ 'depends': ['html_invoice_product_note',
228+ 'html_sale_product_note',
229+ 'invoice_webkit',
230+ 'sale_order_webkit'],
231+ 'data': [],
232+ 'test': [],
233+ 'installable': True,
234+ 'active': False,
235+ }
236
237=== added file 'sale_note_flow/sale.py'
238--- sale_note_flow/sale.py 1970-01-01 00:00:00 +0000
239+++ sale_note_flow/sale.py 2013-03-18 09:03:21 +0000
240@@ -0,0 +1,44 @@
241+# -*- coding: utf-8 -*-
242+##############################################################################
243+#
244+# Copyright (c) 2013 Camptocamp SA (http://www.camptocamp.com)
245+# @author Nicolas Bessi
246+#
247+# This program is free software: you can redistribute it and/or modify
248+# it under the terms of the GNU Affero General Public License as
249+# published by the Free Software Foundation, either version 3 of the
250+# License, or (at your option) any later version.
251+#
252+# This program is distributed in the hope that it will be useful,
253+# but WITHOUT ANY WARRANTY; without even the implied warranty of
254+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255+# GNU Affero General Public License for more details.
256+#
257+# You should have received a copy of the GNU Affero General Public License
258+# along with this program. If not, see <http://www.gnu.org/licenses/>.
259+#
260+##############################################################################
261+from openerp.osv import orm
262+
263+
264+class SaleOrder(orm.Model):
265+
266+ _inherit = "sale.order"
267+
268+ def _prepare_invoice(self, cr, uid, order, lines, context=None):
269+ res = super(SaleOrder, self)._prepare_invoice(cr, uid, order,
270+ lines, context=context)
271+ res.update({'note1': order.note1, 'note2': order.note2})
272+ return res
273+
274+
275+class SaleOrderline(orm.Model):
276+
277+ _inherit = "sale.order.line"
278+
279+ def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
280+ res = super(SaleOrderline, self)._prepare_order_line_invoice_line(cr, uid, line,
281+ account_id=False,
282+ context=context)
283+ res.update({'formatted_note': line.formatted_note})
284+ return res
285
286=== modified file 'sale_order_webkit/sale.py'
287--- sale_order_webkit/sale.py 2013-02-14 10:12:45 +0000
288+++ sale_order_webkit/sale.py 2013-03-18 09:03:21 +0000
289@@ -54,7 +54,7 @@
290 return {}
291 try:
292 lang = self.browse(cursor, uid, inv_id)[0].partner_id.lang
293- except Exception, exc:
294+ except Exception as exc:
295 lang = 'en_US'
296 cond = self.pool.get('sale.condition_text').browse(cursor, uid,
297 commentid, {'lang': lang})
298@@ -65,20 +65,22 @@
299
300 def set_footer(self, cursor, uid, inv_id, commentid):
301 return self._set_condition(cursor, uid, inv_id, commentid, 'note2')
302-
303+
304 def print_quotation(self, cursor, uid, ids, context=None):
305 '''
306- This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow
307+ This function prints the sales order and mark it as sent,
308+ so that we can see more easily the next step of the workflow
309 '''
310 assert len(ids) == 1, 'This option should only be used for a single id at a time'
311 wf_service = netsvc.LocalService("workflow")
312 wf_service.trg_validate(uid, 'sale.order', ids[0], 'quotation_sent', cursor)
313- datas = {
314- 'model': 'sale.order',
315+ datas = {'model': 'sale.order',
316 'ids': ids,
317 'form': self.read(cursor, uid, ids[0], context=context),
318- }
319- return {'type': 'ir.actions.report.xml', 'report_name': 'sale.order.webkit', 'datas': datas, 'nodestroy': True}
320+ }
321+ return {'type': 'ir.actions.report.xml',
322+ 'report_name': 'sale.order.webkit',
323+ 'datas': datas, 'nodestroy': True}
324
325
326 class SaleOrderLine(orm.Model):

Subscribers

People subscribed via source and target branches