Merge lp:~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line into lp:~sale-core-editors/sale-wkfl/7.0

Proposed by David BEAL (ak)
Status: Work in progress
Proposed branch: lp:~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line
Merge into: lp:~sale-core-editors/sale-wkfl/7.0
Diff against target: 201 lines (+181/-0)
4 files modified
sale_optional_line/__init__.py (+21/-0)
sale_optional_line/__openerp__.py (+45/-0)
sale_optional_line/sale.py (+79/-0)
sale_optional_line/sale_view.xml (+36/-0)
To merge this branch: bzr merge lp:~akretion-team/sale-wkfl/7.0-add-module-sale_optional_line
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Review via email: mp+212186@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
42. By David BEAL (ak)

[IMP] split order_lines o2m in 2 parts

43. By David BEAL (ak)

[IMP] clean

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

Unmerged revisions

43. By David BEAL (ak)

[IMP] clean

42. By David BEAL (ak)

[IMP] split order_lines o2m in 2 parts

41. By David BEAL (ak)

[ADD] module sale_optional_line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_optional_line'
2=== added file 'sale_optional_line/__init__.py'
3--- sale_optional_line/__init__.py 1970-01-01 00:00:00 +0000
4+++ sale_optional_line/__init__.py 2014-03-25 11:15:43 +0000
5@@ -0,0 +1,21 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright (C) 2014 Akretion - David BEAL <david.beal@akretion.com>
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU Affero General Public License as published
13+# by the Free Software Foundation, either version 3 of the License, or
14+# (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU Affero General Public License for more details.
20+#
21+# You should have received a copy of the GNU Affero General Public License
22+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+#
24+##############################################################################
25+
26+import sale
27
28=== added file 'sale_optional_line/__openerp__.py'
29--- sale_optional_line/__openerp__.py 1970-01-01 00:00:00 +0000
30+++ sale_optional_line/__openerp__.py 2014-03-25 11:15:43 +0000
31@@ -0,0 +1,45 @@
32+# -*- coding: utf-8 -*-
33+##############################################################################
34+#
35+# Copyright (C) 2014 Akretion -
36+# @author Sébastien BEAU <sebastien.beau@akretion.com>
37+# David BEAL <david.beal@akretion.com>
38+# This program is free software: you can redistribute it and/or modify
39+# it under the terms of the GNU Affero General Public License as published
40+# by the Free Software Foundation, either version 3 of the License, or
41+# (at your option) any later version.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU Affero General Public License for more details.
47+#
48+# You should have received a copy of the GNU Affero General Public License
49+# along with this program. If not, see <http://www.gnu.org/licenses/>.
50+#
51+##############################################################################
52+
53+{
54+ 'name': "Sale Optional Line",
55+ 'version': '0.2',
56+ 'category': 'Sales Management',
57+ 'summary': "Manage optional lines in Quotation / Sale Order",
58+ 'description': """
59+Allows to do a quotation with optional lines.
60+
61+On quotation validation to sale order, you have to select choosen options by customer
62+
63+Non choosen lines are set to inactive but are visible in the user interface in a different style.
64+
65+""",
66+ 'author': 'Akretion',
67+ 'website': 'http://www.akretion.com',
68+ 'license': 'AGPL-3',
69+ "depends": ['sale'],
70+ "data": [
71+ 'sale_view.xml',
72+ ],
73+ "demo": [],
74+ "active": False,
75+ "installable": True
76+}
77
78=== added file 'sale_optional_line/sale.py'
79--- sale_optional_line/sale.py 1970-01-01 00:00:00 +0000
80+++ sale_optional_line/sale.py 2014-03-25 11:15:43 +0000
81@@ -0,0 +1,79 @@
82+# -*- coding: utf-8 -*-
83+##############################################################################
84+#
85+# Copyright (C) 2014 Akretion -
86+# @author Sébastien BEAU <sebastien.beau@akretion.com>
87+# David BEAL <david.beal@akretion.com>
88+# This program is free software: you can redistribute it and/or modify
89+# it under the terms of the GNU Affero General Public License as published
90+# by the Free Software Foundation, either version 3 of the License, or
91+# (at your option) any later version.
92+#
93+# This program is distributed in the hope that it will be useful,
94+# but WITHOUT ANY WARRANTY; without even the implied warranty of
95+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+# GNU Affero General Public License for more details.
97+#
98+# You should have received a copy of the GNU Affero General Public License
99+# along with this program. If not, see <http://www.gnu.org/licenses/>.
100+#
101+##############################################################################
102+
103+from openerp.osv import orm, fields
104+from openerp.tools.translate import _
105+
106+
107+class SaleOrder(orm.Model):
108+ _inherit = "sale.order"
109+
110+ _columns = {
111+ 'unconfirm_offer_ids': fields.one2many(
112+ 'sale.order.line',
113+ 'order_id',
114+ 'Unconfirmed offer',
115+ domain=[('active', '=', False)],
116+ help="Options offered to the customers but refused"),
117+ }
118+
119+ def action_button_confirm(self, cr, uid, ids, context=None):
120+ line_opt_ids = []
121+ line_without_opt_ids = []
122+ for line in self.browse(cr, uid, ids, context=context)[0].order_line:
123+ if line.option is True:
124+ line_opt_ids.append(line.id)
125+ else:
126+ line_without_opt_ids.append(line.id)
127+ if not line_without_opt_ids:
128+ raise orm.except_orm(
129+ _("Optional lines in Quotation"),
130+ _("All the order lines are optional.\n"
131+ "At least one line must not be optional "
132+ "for that the quotation can be confirmed in sale"))
133+ if line_opt_ids:
134+ self.pool['sale.order.line'].write(
135+ cr, uid, line_opt_ids, {'active': False}, context=context)
136+ vals = super(SaleOrder, self).action_button_confirm(
137+ cr, uid, ids, context=context)
138+ return vals
139+
140+
141+class SaleOrderLine(orm.Model):
142+ _inherit = "sale.order.line"
143+
144+ _columns = {
145+ 'active': fields.boolean(
146+ 'Active'),
147+ 'option': fields.boolean(
148+ 'Opt',
149+ help="Optional line : Optional lines in Quotation are "
150+ "set to inactive \nwhen Sale Order is confirmed."),
151+ }
152+
153+ _defaults = {
154+ 'option': False,
155+ 'active': True,
156+ }
157+
158+ def copy(self, cr, uid, vals, context=None):
159+ vals.update({'active': True})
160+ super(SaleOrderLine, self).copy(cr, uid, vals, context=context)
161
162=== added file 'sale_optional_line/sale_view.xml'
163--- sale_optional_line/sale_view.xml 1970-01-01 00:00:00 +0000
164+++ sale_optional_line/sale_view.xml 2014-03-25 11:15:43 +0000
165@@ -0,0 +1,36 @@
166+<?xml version="1.0" encoding="utf-8"?>
167+<openerp>
168+<data>
169+
170+ <record id="view_order_form" model="ir.ui.view">
171+ <field name="model">sale.order</field>
172+ <field name="inherit_id" ref="sale.view_order_form"></field>
173+ <field name="arch" type="xml">
174+ <xpath expr="//page[@string='Other Information']" position="inside">
175+ <separator string="Unconfirm options"/>
176+ <field name="unconfirm_offer_ids">
177+ <tree>
178+ <field name="name"/>
179+ <field name="product_uom_qty"/>
180+ <field name="price_unit"/>
181+ <field name="price_subtotal"/>
182+ <field name="state" invisible="1"/>
183+ </tree>
184+ </field>
185+ </xpath>
186+ <xpath expr="//field[@name='order_line']/tree/field[@name='price_subtotal']"
187+ position="after">
188+ <field name="active" invisible="1"/>
189+ <field name="option"
190+ attrs="{'readonly': [('state', 'not in', ['draft', 'sent'])]}"/>
191+ </xpath>
192+
193+ </field>
194+ </record>
195+
196+</data>
197+</openerp>
198+
199+
200+
201+

Subscribers

People subscribed via source and target branches