← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line into lp:sale-wkfl

 

David BEAL has proposed merging lp:~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line into lp:sale-wkfl.

Requested reviews:
  Sale Core Editors (sale-core-editors)

For more details, see:
https://code.launchpad.net/~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line/+merge/212186

add-module-sale_optional_line :

Allows to do a quotation with optional lines.

On quotation validation on sale order, you have to select choosen options by customer

Non choosen lines are set to inactive but are visible in the user interface in a different style.
-- 
https://code.launchpad.net/~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line/+merge/212186
Your team Sale Core Editors is requested to review the proposed merge of lp:~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line into lp:sale-wkfl.
=== added directory 'sale_optional_line'
=== added file 'sale_optional_line/__init__.py'
--- sale_optional_line/__init__.py	1970-01-01 00:00:00 +0000
+++ sale_optional_line/__init__.py	2014-03-21 16:04:42 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2014 Akretion - David BEAL <david.beal@xxxxxxxxxxxx>
+#
+#    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 sale

=== added file 'sale_optional_line/__openerp__.py'
--- sale_optional_line/__openerp__.py	1970-01-01 00:00:00 +0000
+++ sale_optional_line/__openerp__.py	2014-03-21 16:04:42 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2014 Akretion -
+#                  @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+#                          David BEAL <david.beal@xxxxxxxxxxxx>
+#    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 Optional Line",
+    'version': '0.2',
+    'category': 'Sales Management',
+    'summary': "Manage optional lines in Quotation / Sale Order",
+    'description': """
+Allows to do a quotation with optionnal lines.
+
+On quotation validation on sale order, you have to select choosen options by customer
+
+Non choosen lines are set to inactive but are visible in the user interface in a different style.
+
+""",
+    'author': 'Akretion',
+    'website': 'http://www.akretion.com',
+    'license': 'AGPL-3',
+    "depends": ['sale'],
+    "data": [
+        'sale_view.xml',
+    ],
+    "demo": [],
+    "active": False,
+    "installable": True
+}

=== added file 'sale_optional_line/sale.py'
--- sale_optional_line/sale.py	1970-01-01 00:00:00 +0000
+++ sale_optional_line/sale.py	2014-03-21 16:04:42 +0000
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Akretion -
+#                  @author Sébastien BEAU <sebastien.beau@xxxxxxxxxxxx>
+#                          David BEAL <david.beal@xxxxxxxxxxxx>
+#    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 orm, fields
+
+
+class SaleOrder(orm.Model):
+    _inherit = "sale.order"
+
+    def action_button_confirm(self, cr, uid, ids, context=None):
+        vals = super(SaleOrder, self).action_button_confirm(
+            cr, uid, ids, context=context)
+        line_opt_ids = []
+        line_without_opt_ids = []
+        for line in self.browse(cr, uid, ids, context=context)[0].order_line:
+            if line.option is True:
+                line_opt_ids.append(line.id)
+            else:
+                line_without_opt_ids.append(line.id)
+        if not line_without_opt_ids:
+            raise orm.except_orm(
+                "Optional lines in Quotation",
+                "All the order lines are optional.\n"
+                "At least one line must not be optional "
+                "for that the quotation can be confirmed in sale")
+        if line_opt_ids:
+            self.pool['sale.order.line'].write(
+                cr, uid, line_opt_ids, {'active': False}, context=context)
+        return vals
+
+
+class SaleOrderLine(orm.Model):
+    _inherit = "sale.order.line"
+
+    _columns = {
+        'active': fields.boolean(
+            'Active'),
+        'option': fields.boolean(
+            'Opt',
+            help="Optional line : Optional lines in Quotation are  "
+            "set to inactive \nwhen Sale Order is confirmed."),
+    }
+
+    _defaults = {
+        'option': False,
+        'active': True,
+    }
+
+    def copy(self, cr, uid, vals, context=None):
+        vals.update({'active': True})
+        super(SaleOrderLine, self).copy(cr, uid, vals, context=context)
+
+    #def create(self, cr, uid, vals, context=None):
+    #    vals.update({'active': True})
+    #    return super(SaleOrderLine, self).create(cr, uid, vals, context=context)

=== added file 'sale_optional_line/sale_view.xml'
--- sale_optional_line/sale_view.xml	1970-01-01 00:00:00 +0000
+++ sale_optional_line/sale_view.xml	2014-03-21 16:04:42 +0000
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+
+        <record id="view_order_form" model="ir.ui.view">
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_order_form"></field>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='order_line']/tree/field[@name='price_subtotal']"
+                       position="after">
+                    <field name="active" invisible="1"/>
+                    <field name="option"
+                           attrs="{'readonly': [('state', 'not in', ['draft', 'sent'])]}"/>
+                </xpath>
+                <xpath expr="//field[@name='order_line']/tree"
+                       position="attributes">
+                    <attribute name="colors">grey:active==False</attribute>
+                </xpath>
+            </field>
+        </record>
+
+        <record id="sale.action_orders" model="ir.actions.act_window">
+            <field name="context">{'active_test': False}</field>
+        </record>
+
+</data>
+</openerp>
+
+
+
+


References