Merge lp:~akretion-team/sale-wkfl/70-add-sale_order_revision into lp:~sale-core-editors/sale-wkfl/7.0

Proposed by Raphaël Valyi - http://www.akretion.com
Status: Needs review
Proposed branch: lp:~akretion-team/sale-wkfl/70-add-sale_order_revision
Merge into: lp:~sale-core-editors/sale-wkfl/7.0
Diff against target: 272 lines (+240/-0)
6 files modified
sale_order_revision/__init__.py (+22/-0)
sale_order_revision/__openerp__.py (+49/-0)
sale_order_revision/i18n/sale_order_revision.pot (+54/-0)
sale_order_revision/sale.py (+74/-0)
sale_order_revision/sale_view.xml (+21/-0)
sale_order_revision/test/sale_order.yml (+20/-0)
To merge this branch: bzr merge lp:~akretion-team/sale-wkfl/70-add-sale_order_revision
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Lorenzo Battistini (community) code review Approve
Review via email: mp+202735@code.launchpad.net

Description of the change

adds sale_order_revision, modeled after purchase_order_revision OCA module by Agile Business Group

To post a comment you must log in.
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Please just wait for me fixing the test case. Doing it soon.

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Hello Raphaël, thanks for the module!

purchase_order_revision.pot file should be renamed to sale_order_revision.pot

review: Needs Fixing
29. By Raphaël Valyi - http://www.akretion.com

[REF] as requested 'sale_order_revision/i18n/purchase_order_revision.pot' => 'sale_order_revision/i18n/sale_order_revision.pot'

30. By Raphaël Valyi - http://www.akretion.com

[TEST] fixed and enable test for sale_order_revision

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello,

I did the 'sale_order_revision/i18n/purchase_order_revision.pot' => 'sale_order_revision/i18n/sale_order_revision.pot' rename as requested by Lorenzo.

I also fixed and enabled the tests. Is it ok for you now?

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Thanks

review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Raphaël, thanks for the contribution. It works like intended, and it's very useful. I think it can be even more useful if cancelled orders with a revision are hidden by default from quotations screens, don't you think?

Regards.

review: Needs Information (code review and test)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/sale-workflow. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

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

Unmerged revisions

30. By Raphaël Valyi - http://www.akretion.com

[TEST] fixed and enable test for sale_order_revision

29. By Raphaël Valyi - http://www.akretion.com

[REF] as requested 'sale_order_revision/i18n/purchase_order_revision.pot' => 'sale_order_revision/i18n/sale_order_revision.pot'

28. By Raphaël Valyi - http://www.akretion.com

[ADD] sale_order_revision, modeled after purchase_order_revision OCA module by Agile Business Group

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_order_revision'
2=== added file 'sale_order_revision/__init__.py'
3--- sale_order_revision/__init__.py 1970-01-01 00:00:00 +0000
4+++ sale_order_revision/__init__.py 2014-05-02 17:24:10 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
10+# @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
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 published
14+# by the Free Software Foundation, either version 3 of the License, or
15+# (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+
27+from . import sale
28
29=== added file 'sale_order_revision/__openerp__.py'
30--- sale_order_revision/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ sale_order_revision/__openerp__.py 2014-05-02 17:24:10 +0000
32@@ -0,0 +1,49 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
37+# @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
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 published
41+# by the Free Software Foundation, either version 3 of the License, or
42+# (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+{
55+ 'name': "Sale order revisions",
56+ 'version': '0.1',
57+ 'category': 'Sale Management',
58+ 'description': """
59+Revisions for sale orders (and requests for quotation)
60+==========================================================
61+
62+On canceled orders, you can click on 'new revision' and the 'old revisions'
63+tab of the just created request for quotation will contain all the old
64+(canceled orders) revisions.
65+So that you can track every change you made to your requests for quotation and
66+sale orders.
67+""",
68+ 'author': 'Agile Business Group',
69+ 'website': 'http://www.agilebg.com',
70+ 'license': 'AGPL-3',
71+ "depends": ['sale'],
72+ "data": [
73+ 'sale_view.xml',
74+ ],
75+ "demo": [],
76+ "test": [
77+ 'test/sale_order.yml',
78+ ],
79+ "active": False,
80+ "installable": True
81+}
82
83=== added directory 'sale_order_revision/i18n'
84=== added file 'sale_order_revision/i18n/sale_order_revision.pot'
85--- sale_order_revision/i18n/sale_order_revision.pot 1970-01-01 00:00:00 +0000
86+++ sale_order_revision/i18n/sale_order_revision.pot 2014-05-02 17:24:10 +0000
87@@ -0,0 +1,54 @@
88+# Translation of OpenERP Server.
89+# This file contains the translation of the following modules:
90+# * sale_order_revision
91+#
92+msgid ""
93+msgstr ""
94+"Project-Id-Version: OpenERP Server 7.0\n"
95+"Report-Msgid-Bugs-To: \n"
96+"POT-Creation-Date: 2013-11-18 18:17+0000\n"
97+"PO-Revision-Date: 2013-11-18 18:17+0000\n"
98+"Last-Translator: <>\n"
99+"Language-Team: \n"
100+"MIME-Version: 1.0\n"
101+"Content-Type: text/plain; charset=UTF-8\n"
102+"Content-Transfer-Encoding: \n"
103+"Plural-Forms: \n"
104+
105+#. module: sale_order_revision
106+#: field:sale.order,old_revision_ids:0
107+msgid "Old revisions"
108+msgstr ""
109+
110+#. module: sale_order_revision
111+#: code:addons/sale_order_revision/sale.py:41
112+#, python-format
113+msgid "This only works for 1 PO at a time"
114+msgstr ""
115+
116+#. module: sale_order_revision
117+#: field:sale.order,current_revision_id:0
118+msgid "Current revision"
119+msgstr ""
120+
121+#. module: sale_order_revision
122+#: model:ir.model,name:sale_order_revision.model_sale_order
123+msgid "Sale Order"
124+msgstr ""
125+
126+#. module: sale_order_revision
127+#: code:addons/sale_order_revision/sale.py:41
128+#, python-format
129+msgid "Error"
130+msgstr ""
131+
132+#. module: sale_order_revision
133+#: view:sale.order:0
134+msgid "New revision"
135+msgstr ""
136+
137+#. module: sale_order_revision
138+#: view:sale.order:0
139+msgid "Revisions"
140+msgstr ""
141+
142
143=== added file 'sale_order_revision/sale.py'
144--- sale_order_revision/sale.py 1970-01-01 00:00:00 +0000
145+++ sale_order_revision/sale.py 2014-05-02 17:24:10 +0000
146@@ -0,0 +1,74 @@
147+# -*- coding: utf-8 -*-
148+##############################################################################
149+#
150+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
151+# @author Lorenzo Battistini <lorenzo.battistini@agilebg.com>
152+# @author Raphaël Valyi <raphael.valyi@akretion.com> (ported to sale from
153+# original purchase_order_revision by Lorenzo Battistini)
154+#
155+# This program is free software: you can redistribute it and/or modify
156+# it under the terms of the GNU Affero General Public License as published
157+# by the Free Software Foundation, either version 3 of the License, or
158+# (at your option) any later version.
159+#
160+# This program is distributed in the hope that it will be useful,
161+# but WITHOUT ANY WARRANTY; without even the implied warranty of
162+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
163+# GNU Affero General Public License for more details.
164+#
165+# You should have received a copy of the GNU Affero General Public License
166+# along with this program. If not, see <http://www.gnu.org/licenses/>.
167+#
168+##############################################################################
169+
170+from openerp import netsvc
171+from openerp.osv import fields, orm
172+from openerp.tools.translate import _
173+
174+
175+class sale_order(orm.Model):
176+
177+ _inherit = "sale.order"
178+
179+ _columns = {
180+ 'current_revision_id': fields.many2one(
181+ 'sale.order', 'Current revision', readonly=True),
182+ 'old_revision_ids': fields.one2many(
183+ 'sale.order', 'current_revision_id',
184+ 'Old revisions', readonly=True),
185+ }
186+
187+ def copy_quotation(self, cr, uid, ids, context=None):
188+ if len(ids) > 1:
189+ raise orm.except_orm(
190+ _('Error'), _('This only works for 1 SO at a time'))
191+ so = self.browse(cr, uid, ids[0], context)
192+ new_seq = self.pool.get('ir.sequence').get(
193+ cr, uid, 'sale.order') or '/'
194+ old_seq = so.name
195+ so.write({'name': new_seq}, context=context)
196+ # 'orm.Model.copy' is called instead of 'self.copy' in order to avoid
197+ # 'sale.order' method to overwrite our values, like name and state
198+ orm.Model.copy(self, cr, uid, so.id, default={
199+ 'name': old_seq,
200+ 'state': 'cancel',
201+ 'shipped': False,
202+ 'invoiced': False,
203+ 'invoice_ids': [],
204+ 'picking_ids': [],
205+ 'old_revision_ids': [],
206+ 'current_revision_id': so.id,
207+ }, context=None)
208+ self.write(cr, uid, ids, {'state':'draft','shipped':0})
209+ wf_service = netsvc.LocalService("workflow")
210+ wf_service.trg_delete(uid, 'sale.order', ids[0], cr)
211+ wf_service.trg_create(uid, 'sale.order', ids[0], cr)
212+ return True
213+
214+ def copy(self, cr, uid, id, default=None, context=None):
215+ if not default:
216+ default = {}
217+ default.update({
218+ 'old_revision_ids': [],
219+ })
220+ return super(sale_order, self).copy(cr, uid, id, default, context)
221
222=== added file 'sale_order_revision/sale_view.xml'
223--- sale_order_revision/sale_view.xml 1970-01-01 00:00:00 +0000
224+++ sale_order_revision/sale_view.xml 2014-05-02 17:24:10 +0000
225@@ -0,0 +1,21 @@
226+<?xml version="1.0" encoding="utf-8"?>
227+<openerp>
228+ <data>
229+
230+ <record id="sale_order_form" model="ir.ui.view">
231+ <field name="name">sale.order.form</field>
232+ <field name="model">sale.order</field>
233+ <field name="inherit_id" ref="sale.view_order_form"></field>
234+ <field name="arch" type="xml">
235+ <notebook position="inside">
236+ <page string="Revisions">
237+ <field name="old_revision_ids"></field>
238+ <group>
239+ <field name="current_revision_id"></field>
240+ </group>
241+ </page>
242+ </notebook>
243+ </field>
244+ </record>
245+ </data>
246+</openerp>
247
248=== added directory 'sale_order_revision/test'
249=== added file 'sale_order_revision/test/sale_order.yml'
250--- sale_order_revision/test/sale_order.yml 1970-01-01 00:00:00 +0000
251+++ sale_order_revision/test/sale_order.yml 2014-05-02 17:24:10 +0000
252@@ -0,0 +1,20 @@
253+-
254+ I create a SO
255+-
256+ !record {model: sale.order, id: sale_order_1}:
257+ partner_id: base.res_partner_2
258+ order_line:
259+ - product_id: product.product_product_15
260+ product_uom_qty: 15.0
261+-
262+ I cancel the SO
263+-
264+ !python {model: sale.order}: |
265+ self.action_cancel(cr, uid, [ref('sale_order_1')])
266+-
267+ I create a new revision
268+-
269+ !python {model: sale.order}: |
270+ action = self.copy_quotation(cr, uid, [ref('sale_order_1')])
271+ new_so = self.browse(cr, uid, ref('sale_order_1'))
272+ assert new_so.old_revision_ids, "Old revisions not set"

Subscribers

People subscribed via source and target branches