openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #03126
[Merge] lp:~akretion-team/sale-wkfl/70-add-sale_order_revision into lp:sale-wkfl
Raphaël Valyi - http://www.akretion.com has proposed merging lp:~akretion-team/sale-wkfl/70-add-sale_order_revision into lp:sale-wkfl.
Requested reviews:
Sale Core Editors (sale-core-editors)
For more details, see:
https://code.launchpad.net/~akretion-team/sale-wkfl/70-add-sale_order_revision/+merge/202735
adds sale_order_revision, modeled after purchase_order_revision OCA module by Agile Business Group
--
https://code.launchpad.net/~akretion-team/sale-wkfl/70-add-sale_order_revision/+merge/202735
Your team Sale Core Editors is requested to review the proposed merge of lp:~akretion-team/sale-wkfl/70-add-sale_order_revision into lp:sale-wkfl.
=== added directory 'sale_order_revision'
=== added file 'sale_order_revision/__init__.py'
--- sale_order_revision/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_order_revision/__init__.py 2014-01-22 19:24:32 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+# @author Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import sale
=== added file 'sale_order_revision/__openerp__.py'
--- sale_order_revision/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_order_revision/__openerp__.py 2014-01-22 19:24:32 +0000
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+# @author Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': "Sale order revisions",
+ 'version': '0.1',
+ 'category': 'Sale Management',
+ 'description': """
+Revisions for sale orders (and requests for quotation)
+==========================================================
+
+On canceled orders, you can click on 'new revision' and the 'old revisions'
+tab of the just created request for quotation will contain all the old
+(canceled orders) revisions.
+So that you can track every change you made to your requests for quotation and
+sale orders.
+""",
+ 'author': 'Agile Business Group',
+ 'website': 'http://www.agilebg.com',
+ 'license': 'AGPL-3',
+ "depends": ['sale'],
+ "data": [
+ 'sale_view.xml',
+ ],
+ "demo": [],
+ "test": [
+# 'test/sale_order.yml',
+ ],
+ "active": False,
+ "installable": True
+}
=== added directory 'sale_order_revision/i18n'
=== added file 'sale_order_revision/i18n/purchase_order_revision.pot'
--- sale_order_revision/i18n/purchase_order_revision.pot 1970-01-01 00:00:00 +0000
+++ sale_order_revision/i18n/purchase_order_revision.pot 2014-01-22 19:24:32 +0000
@@ -0,0 +1,54 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * sale_order_revision
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-11-18 18:17+0000\n"
+"PO-Revision-Date: 2013-11-18 18:17+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: sale_order_revision
+#: field:sale.order,old_revision_ids:0
+msgid "Old revisions"
+msgstr ""
+
+#. module: sale_order_revision
+#: code:addons/sale_order_revision/sale.py:41
+#, python-format
+msgid "This only works for 1 PO at a time"
+msgstr ""
+
+#. module: sale_order_revision
+#: field:sale.order,current_revision_id:0
+msgid "Current revision"
+msgstr ""
+
+#. module: sale_order_revision
+#: model:ir.model,name:sale_order_revision.model_sale_order
+msgid "Sale Order"
+msgstr ""
+
+#. module: sale_order_revision
+#: code:addons/sale_order_revision/sale.py:41
+#, python-format
+msgid "Error"
+msgstr ""
+
+#. module: sale_order_revision
+#: view:sale.order:0
+msgid "New revision"
+msgstr ""
+
+#. module: sale_order_revision
+#: view:sale.order:0
+msgid "Revisions"
+msgstr ""
+
=== added file 'sale_order_revision/sale.py'
--- sale_order_revision/sale.py 1970-01-01 00:00:00 +0000
+++ sale_order_revision/sale.py 2014-01-22 19:24:32 +0000
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
+# @author Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
+# @author Raphaël Valyi <raphael.valyi@xxxxxxxxxxxx> (ported to sale from
+# original purchase_order_revision by Lorenzo Battistini)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp import netsvc
+from openerp.osv import fields, orm
+from openerp.tools.translate import _
+
+
+class sale_order(orm.Model):
+
+ _inherit = "sale.order"
+
+ _columns = {
+ 'current_revision_id': fields.many2one(
+ 'sale.order', 'Current revision', readonly=True),
+ 'old_revision_ids': fields.one2many(
+ 'sale.order', 'current_revision_id',
+ 'Old revisions', readonly=True),
+ }
+
+ def copy_quotation(self, cr, uid, ids, context=None):
+ if len(ids) > 1:
+ raise orm.except_orm(
+ _('Error'), _('This only works for 1 SO at a time'))
+ so = self.browse(cr, uid, ids[0], context)
+ new_seq = self.pool.get('ir.sequence').get(
+ cr, uid, 'sale.order') or '/'
+ old_seq = so.name
+ so.write({'name': new_seq}, context=context)
+ # 'orm.Model.copy' is called instead of 'self.copy' in order to avoid
+ # 'sale.order' method to overwrite our values, like name and state
+ orm.Model.copy(self, cr, uid, so.id, default={
+ 'name': old_seq,
+ 'state': 'cancel',
+ 'shipped': False,
+ 'invoiced': False,
+ 'invoice_ids': [],
+ 'picking_ids': [],
+ 'old_revision_ids': [],
+ 'current_revision_id': so.id,
+ }, context=None)
+ self.write(cr, uid, ids, {'state':'draft','shipped':0})
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_delete(uid, 'sale.order', ids[0], cr)
+ wf_service.trg_create(uid, 'sale.order', ids[0], cr)
+ return True
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ if not default:
+ default = {}
+ default.update({
+ 'old_revision_ids': [],
+ })
+ return super(sale_order, self).copy(cr, uid, id, default, context)
=== added file 'sale_order_revision/sale_view.xml'
--- sale_order_revision/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_order_revision/sale_view.xml 2014-01-22 19:24:32 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="sale_order_form" model="ir.ui.view">
+ <field name="name">sale.order.form</field>
+ <field name="model">sale.order</field>
+ <field name="inherit_id" ref="sale.view_order_form"></field>
+ <field name="arch" type="xml">
+ <notebook position="inside">
+ <page string="Revisions">
+ <field name="old_revision_ids"></field>
+ <group>
+ <field name="current_revision_id"></field>
+ </group>
+ </page>
+ </notebook>
+ </field>
+ </record>
+ </data>
+</openerp>
=== added directory 'sale_order_revision/test'
=== added file 'sale_order_revision/test/sale_order.yml'
--- sale_order_revision/test/sale_order.yml 1970-01-01 00:00:00 +0000
+++ sale_order_revision/test/sale_order.yml 2014-01-22 19:24:32 +0000
@@ -0,0 +1,20 @@
+-
+ I create a SO
+-
+ !record {model: sale.order, id: sale_order_1}:
+ partner_id: base.res_partner_2
+ order_line:
+ - product_id: product.product_product_15
+ product_uom_qty: 15.0
+-
+ I cancel the SO
+-
+ !python {model: sale.order}: |
+ self.action_cancel(cr, uid, [ref('sale_order_1')])
+-
+ I create a new revision
+-
+ !python {model: sale.order}: |
+ action = self.new_revision(cr, uid, [ref('sale_order_1')])
+ new_so = self.browse(cr, uid, ref('sale_order_1'))
+ assert new_so.old_revision_ids, "Old revisions not set"
References