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
=== 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-25 11:15:43 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2014 Akretion - David BEAL <david.beal@akretion.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published
8# by the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21import sale
022
=== 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-25 11:15:43 +0000
@@ -0,0 +1,45 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2014 Akretion -
5# @author Sébastien BEAU <sebastien.beau@akretion.com>
6# David BEAL <david.beal@akretion.com>
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{
23 'name': "Sale Optional Line",
24 'version': '0.2',
25 'category': 'Sales Management',
26 'summary': "Manage optional lines in Quotation / Sale Order",
27 'description': """
28Allows to do a quotation with optional lines.
29
30On quotation validation to sale order, you have to select choosen options by customer
31
32Non choosen lines are set to inactive but are visible in the user interface in a different style.
33
34""",
35 'author': 'Akretion',
36 'website': 'http://www.akretion.com',
37 'license': 'AGPL-3',
38 "depends": ['sale'],
39 "data": [
40 'sale_view.xml',
41 ],
42 "demo": [],
43 "active": False,
44 "installable": True
45}
046
=== 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-25 11:15:43 +0000
@@ -0,0 +1,79 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2014 Akretion -
5# @author Sébastien BEAU <sebastien.beau@akretion.com>
6# David BEAL <david.beal@akretion.com>
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import orm, fields
23from openerp.tools.translate import _
24
25
26class SaleOrder(orm.Model):
27 _inherit = "sale.order"
28
29 _columns = {
30 'unconfirm_offer_ids': fields.one2many(
31 'sale.order.line',
32 'order_id',
33 'Unconfirmed offer',
34 domain=[('active', '=', False)],
35 help="Options offered to the customers but refused"),
36 }
37
38 def action_button_confirm(self, cr, uid, ids, context=None):
39 line_opt_ids = []
40 line_without_opt_ids = []
41 for line in self.browse(cr, uid, ids, context=context)[0].order_line:
42 if line.option is True:
43 line_opt_ids.append(line.id)
44 else:
45 line_without_opt_ids.append(line.id)
46 if not line_without_opt_ids:
47 raise orm.except_orm(
48 _("Optional lines in Quotation"),
49 _("All the order lines are optional.\n"
50 "At least one line must not be optional "
51 "for that the quotation can be confirmed in sale"))
52 if line_opt_ids:
53 self.pool['sale.order.line'].write(
54 cr, uid, line_opt_ids, {'active': False}, context=context)
55 vals = super(SaleOrder, self).action_button_confirm(
56 cr, uid, ids, context=context)
57 return vals
58
59
60class SaleOrderLine(orm.Model):
61 _inherit = "sale.order.line"
62
63 _columns = {
64 'active': fields.boolean(
65 'Active'),
66 'option': fields.boolean(
67 'Opt',
68 help="Optional line : Optional lines in Quotation are "
69 "set to inactive \nwhen Sale Order is confirmed."),
70 }
71
72 _defaults = {
73 'option': False,
74 'active': True,
75 }
76
77 def copy(self, cr, uid, vals, context=None):
78 vals.update({'active': True})
79 super(SaleOrderLine, self).copy(cr, uid, vals, context=context)
080
=== 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-25 11:15:43 +0000
@@ -0,0 +1,36 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data>
4
5 <record id="view_order_form" model="ir.ui.view">
6 <field name="model">sale.order</field>
7 <field name="inherit_id" ref="sale.view_order_form"></field>
8 <field name="arch" type="xml">
9 <xpath expr="//page[@string='Other Information']" position="inside">
10 <separator string="Unconfirm options"/>
11 <field name="unconfirm_offer_ids">
12 <tree>
13 <field name="name"/>
14 <field name="product_uom_qty"/>
15 <field name="price_unit"/>
16 <field name="price_subtotal"/>
17 <field name="state" invisible="1"/>
18 </tree>
19 </field>
20 </xpath>
21 <xpath expr="//field[@name='order_line']/tree/field[@name='price_subtotal']"
22 position="after">
23 <field name="active" invisible="1"/>
24 <field name="option"
25 attrs="{'readonly': [('state', 'not in', ['draft', 'sent'])]}"/>
26 </xpath>
27
28 </field>
29 </record>
30
31</data>
32</openerp>
33
34
35
36

Subscribers

People subscribed via source and target branches