openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #01021
[Merge] lp:~agilebg/purchase-wkfl/adding_purchase_order_revision_7 into lp:purchase-wkfl
Lorenzo Battistini - Agile BG has proposed merging lp:~agilebg/purchase-wkfl/adding_purchase_order_revision_7 into lp:purchase-wkfl.
Requested reviews:
Purchase Core Editors (purchase-core-editors)
For more details, see:
https://code.launchpad.net/~agilebg/purchase-wkfl/adding_purchase_order_revision_7/+merge/193778
Revisions for purchase 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
purchase orders
--
https://code.launchpad.net/~agilebg/purchase-wkfl/adding_purchase_order_revision_7/+merge/193778
Your team Purchase Core Editors is requested to review the proposed merge of lp:~agilebg/purchase-wkfl/adding_purchase_order_revision_7 into lp:purchase-wkfl.
=== added directory 'purchase_order_revision'
=== added file 'purchase_order_revision/__init__.py'
--- purchase_order_revision/__init__.py 1970-01-01 00:00:00 +0000
+++ purchase_order_revision/__init__.py 2013-11-04 13:42:12 +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/>.
+#
+##############################################################################
+
+import purchase
=== added file 'purchase_order_revision/__openerp__.py'
--- purchase_order_revision/__openerp__.py 1970-01-01 00:00:00 +0000
+++ purchase_order_revision/__openerp__.py 2013-11-04 13:42:12 +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': "Purchase order revisions",
+ 'version': '0.1',
+ 'category': 'Purchase Management',
+ 'description': """
+Revisions for purchase 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
+purchase orders.
+""",
+ 'author': 'Agile Business Group',
+ 'website': 'http://www.agilebg.com',
+ 'license': 'AGPL-3',
+ "depends": ['purchase'],
+ "data": [
+ 'purchase_view.xml',
+ ],
+ "demo": [],
+ "test": [
+ 'test/purchase_order.yml',
+ ],
+ "active": False,
+ "installable": True
+}
=== added file 'purchase_order_revision/purchase.py'
--- purchase_order_revision/purchase.py 1970-01-01 00:00:00 +0000
+++ purchase_order_revision/purchase.py 2013-11-04 13:42:12 +0000
@@ -0,0 +1,72 @@
+# -*- 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 openerp.osv import fields, orm
+from openerp.tools.translate import _
+
+
+class purchase_order(orm.Model):
+
+ _inherit = "purchase.order"
+
+ _columns = {
+ 'current_revision_id': fields.many2one(
+ 'purchase.order', 'Current revision', readonly=True),
+ 'old_revision_ids': fields.one2many(
+ 'purchase.order', 'current_revision_id',
+ 'Old revisions', readonly=True),
+ }
+
+ def new_revision(self, cr, uid, ids, context=None):
+ if len(ids) > 1:
+ raise orm.except_orm(
+ _('Error'), _('This only works for 1 PO at a time'))
+ po = self.browse(cr, uid, ids[0], context)
+ new_seq = self.pool.get('ir.sequence').get(
+ cr, uid, 'purchase.order') or '/'
+ old_seq = po.name
+ po.write({'name': new_seq}, context=context)
+ orm.Model.copy(self, cr, uid, po.id, default={
+ 'name': old_seq,
+ 'state': 'cancel',
+ 'shipped': False,
+ 'invoiced': False,
+ 'invoice_ids': [],
+ 'picking_ids': [],
+ 'old_revision_ids': [],
+ 'current_revision_id': po.id,
+ }, context=None)
+ self.action_cancel_draft(cr, uid, [po.id], context=context)
+ return True
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ if not default:
+ default = {}
+ default.update({
+ 'state': 'draft',
+ 'shipped': False,
+ 'invoiced': False,
+ 'invoice_ids': [],
+ 'picking_ids': [],
+ 'name': self.pool.get('ir.sequence').get(
+ cr, uid, 'purchase.order'),
+ })
+ return super(purchase_order, self).copy(cr, uid, id, default, context)
=== added file 'purchase_order_revision/purchase_view.xml'
--- purchase_order_revision/purchase_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_order_revision/purchase_view.xml 2013-11-04 13:42:12 +0000
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="purchase_order_form" model="ir.ui.view">
+ <field name="name">purchase.order.form</field>
+ <field name="model">purchase.order</field>
+ <field name="inherit_id" ref="purchase.purchase_order_form"></field>
+ <field name="arch" type="xml">
+ <button name="action_cancel_draft" position="replace" >
+ <button name="new_revision" string="New revision" type="object" attrs="{'invisible': ['|',('state', '!=', 'cancel'),('current_revision_id','!=', False)]}"/>
+ </button>
+ <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 'purchase_order_revision/test'
=== added file 'purchase_order_revision/test/purchase_order.yml'
--- purchase_order_revision/test/purchase_order.yml 1970-01-01 00:00:00 +0000
+++ purchase_order_revision/test/purchase_order.yml 2013-11-04 13:42:12 +0000
@@ -0,0 +1,28 @@
+-
+ I create a PO
+-
+ !record {model: purchase.order, id: purchase_order_1}:
+ partner_id: base.res_partner_1
+ invoice_method: order
+ order_line:
+ - product_id: product.product_product_15
+ price_unit: 79.80
+ product_qty: 15.0
+ - product_id: product.product_product_25
+ price_unit: 2868.70
+ product_qty: 5.0
+ - product_id: product.product_product_27
+ price_unit: 3297.20
+ product_qty: 4.0
+-
+ I cancel the PO
+-
+ !python {model: purchase.order}: |
+ self.action_cancel(cr, uid, [ref('purchase_order_1')])
+-
+ I create a new revision
+-
+ !python {model: purchase.order}: |
+ action = self.new_revision(cr, uid, [ref('purchase_order_1')])
+ new_po = self.browse(cr, uid, ref('purchase_order_1'))
+ assert new_po.old_revision_ids, "Old revisions not set"
Follow ups