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

Proposed by Raphaël Valyi - http://www.akretion.com
Status: Needs review
Proposed branch: lp:~akretion-team/sale-wkfl/7.0-add-sale_import_lines
Merge into: lp:~sale-core-editors/sale-wkfl/7.0
Prerequisite: lp:~akretion-team/sale-wkfl/7.0-add-sale_group
Diff against target: 277 lines (+251/-0)
5 files modified
sale_import_lines/__init__.py (+1/-0)
sale_import_lines/__openerp__.py (+44/-0)
sale_import_lines/i18n/pt_BR.po (+63/-0)
sale_import_lines/sale.py (+96/-0)
sale_import_lines/sale_view.xml (+47/-0)
To merge this branch: bzr merge lp:~akretion-team/sale-wkfl/7.0-add-sale_import_lines
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Needs Resubmitting
Review via email: mp+201021@code.launchpad.net

Description of the change

Adds sale_import_lines module:

Allows to import sale order lines (by customer, order, sale.group...)
into your new current quotation.

This is useful if you have quotations with many lines with similarities
from one quotation to another.

To post a comment you must log in.
42. By Raphaël Valyi - http://www.akretion.com

[REF] udate_xml -> data in __openerp__.py

43. By Raphaël Valyi - http://www.akretion.com

[FIX] string in form node

44. By Raphaël Valyi - http://www.akretion.com

[REF] relative import style

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :
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

44. By Raphaël Valyi - http://www.akretion.com

[REF] relative import style

43. By Raphaël Valyi - http://www.akretion.com

[FIX] string in form node

42. By Raphaël Valyi - http://www.akretion.com

[REF] udate_xml -> data in __openerp__.py

41. By Raphaël Valyi - http://www.akretion.com

[PEP8] line breaks in module description

40. By Raphaël Valyi - http://www.akretion.com

[REF] sale.pool.get -> self.pool[]

39. By Raphaël Valyi - http://www.akretion.com

[REF] further updates for v7 migration and dependence on sale instead of base_project_costing, so project_id -> analytic_account_id

38. By Raphaël Valyi - http://www.akretion.com

[REF] removed unused imports + copyrights

37. By Florian da Costa

[ADD] Brazilian Portuguese translation

36. By Akretion Bot <email address hidden>

[IMP] improved group creation

35. By Akretion Bot <email address hidden>

changed name: plural

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_import_lines'
2=== added file 'sale_import_lines/__init__.py'
3--- sale_import_lines/__init__.py 1970-01-01 00:00:00 +0000
4+++ sale_import_lines/__init__.py 2014-01-10 17:37:52 +0000
5@@ -0,0 +1,1 @@
6+from . import sale
7
8=== added file 'sale_import_lines/__openerp__.py'
9--- sale_import_lines/__openerp__.py 1970-01-01 00:00:00 +0000
10+++ sale_import_lines/__openerp__.py 2014-01-10 17:37:52 +0000
11@@ -0,0 +1,44 @@
12+# -*- coding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# Copyright (C) 2013 Akretion LDTA (<http://www.akretion.com>).
17+# @author Raphaël Valyi
18+#
19+# This program is free software: you can redistribute it and/or modify
20+# it under the terms of the GNU Affero General Public License as
21+# published by the Free Software Foundation, either version 3 of the
22+# License, or (at your option) any later version.
23+#
24+# This program is distributed in the hope that it will be useful,
25+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+# GNU Affero General Public License for more details.
28+#
29+# You should have received a copy of the GNU Affero General Public License
30+# along with this program. If not, see <http://www.gnu.org/licenses/>.
31+#
32+##############################################################################
33+{
34+ "name" : "Sale Order Line importation utilities",
35+ "version": "1.0",
36+ "author" : "Akretion",
37+ "website" : "http://www.akretion.com",
38+ "category" : "Others",
39+ "depends" : ["sale", "sale_group"],
40+ "description": """
41+Allows to import sale order lines (by customer, order, sale.group...)
42+into your new current quotation.
43+
44+This is useful if you have quotations with many lines with similarities
45+from one quotation to another.
46+ """,
47+ "init_xml" : [],
48+ "demo_xml" : [],
49+ "test" : [],
50+ "data": ["sale_view.xml"],
51+ 'installable': True,
52+ 'active': False,
53+ 'certificate': None,
54+}
55+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
56
57=== added directory 'sale_import_lines/i18n'
58=== added file 'sale_import_lines/i18n/pt_BR.po'
59--- sale_import_lines/i18n/pt_BR.po 1970-01-01 00:00:00 +0000
60+++ sale_import_lines/i18n/pt_BR.po 2014-01-10 17:37:52 +0000
61@@ -0,0 +1,63 @@
62+# Translation of OpenERP Server.
63+# This file contains the translation of the following modules:
64+# * sale_import_lines
65+#
66+msgid ""
67+msgstr ""
68+"Project-Id-Version: OpenERP Server 6.1\n"
69+"Report-Msgid-Bugs-To: \n"
70+"POT-Creation-Date: 2013-06-10 18:17+0000\n"
71+"PO-Revision-Date: 2013-06-10 18:17+0000\n"
72+"Last-Translator: <>\n"
73+"Language-Team: \n"
74+"MIME-Version: 1.0\n"
75+"Content-Type: text/plain; charset=UTF-8\n"
76+"Content-Transfer-Encoding: \n"
77+"Plural-Forms: \n"
78+
79+#. module: sale_import_lines
80+#: sql_constraint:sale.order:0
81+msgid "Order Reference must be unique per Company!"
82+msgstr "A Referência do Pedido deve ser única por empresa!"
83+
84+#. module: sale_import_lines
85+#: field:sale_import_lines.wizard,group_id:0
86+msgid "Sale Group"
87+msgstr "Grupo de Venda"
88+
89+#. module: sale_import_lines
90+#: field:sale_import_lines.wizard,order_line_ids:0
91+msgid "Sale Order Lines"
92+msgstr "Linhas de pedido de venda"
93+
94+#. module: sale_import_lines
95+#: view:sale_import_lines.wizard:0
96+msgid "Cancel"
97+msgstr "Cancelar"
98+
99+#. module: sale_import_lines
100+#: view:sale.order:0
101+msgid "Import"
102+msgstr "Importar"
103+
104+#. module: sale_import_lines
105+#: view:sale_import_lines.wizard:0
106+msgid "Validate"
107+msgstr "Validar"
108+
109+#. module: sale_import_lines
110+#: model:ir.model,name:sale_import_lines.model_sale_order
111+msgid "Sales Order"
112+msgstr "Pedido de Venda"
113+
114+#. module: sale_import_lines
115+#: code:addons/sale_import_lines/sale.py:14
116+#, python-format
117+msgid "Sale Order Lines Importation Wizard"
118+msgstr "Linhas de pedido de venda Importação Wizard"
119+
120+#. module: sale_import_lines
121+#: model:ir.model,name:sale_import_lines.model_sale_import_lines_wizard
122+msgid "sale_import_lines.wizard"
123+msgstr "sale_import_lines.wizard"
124+
125
126=== added file 'sale_import_lines/sale.py'
127--- sale_import_lines/sale.py 1970-01-01 00:00:00 +0000
128+++ sale_import_lines/sale.py 2014-01-10 17:37:52 +0000
129@@ -0,0 +1,96 @@
130+# -*- encoding: utf-8 -*-
131+###############################################################################
132+# #
133+# Copyright (C) 2013 Raphaël Valyi - Akretion #
134+# #
135+#This program is free software: you can redistribute it and/or modify #
136+#it under the terms of the GNU Affero General Public License as published by #
137+#the Free Software Foundation, either version 3 of the License, or #
138+#(at your option) any later version. #
139+# #
140+#This program is distributed in the hope that it will be useful, #
141+#but WITHOUT ANY WARRANTY; without even the implied warranty of #
142+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
143+#GNU Affero General Public License for more details. #
144+# #
145+#You should have received a copy of the GNU Affero General Public License #
146+#along with this program. If not, see <http://www.gnu.org/licenses/>. #
147+###############################################################################
148+
149+from osv import orm, fields
150+from tools.translate import _
151+
152+
153+class sale_order(orm.Model):
154+ _inherit = "sale.order"
155+
156+ def button_lines_wizard_edit(self, cr, uid, ids, context=None):
157+ analytic_account_id = self.read(cr, uid, ids, ['project_id'],
158+ context)[0].get('project_id')
159+ context['analytic_account_id'] = analytic_account_id and\
160+ analytic_account_id[0]
161+ return {
162+ 'context': context,
163+ 'name': _('Sale Order Lines Importation Wizard'),
164+ 'view_type': 'form',
165+ 'view_mode': 'form',
166+ 'res_model': 'sale_import_lines.wizard',
167+ 'type': 'ir.actions.act_window',
168+ 'target': 'new',
169+ }
170+
171+
172+class sale_order_line(orm.Model):
173+ _inherit = 'sale.order.line'
174+
175+ _columns = {
176+ 'product_categ_id': fields.related('product_id', 'categ_id',
177+ type='many2one', readonly=True,
178+ relation='product.category',
179+ store=True,
180+ string='Product Category'),
181+ }
182+
183+
184+class sale_import_lines_wizard(orm.TransientModel):
185+ _name = "sale_import_lines.wizard"
186+ _rec_name = "group_id"
187+
188+ _columns = {
189+ 'group_id': fields.many2one('sale.order.line.group', 'Sale Group'),
190+ 'order_line_ids': fields.many2many('sale.order.line',
191+ 'sale_lines_wizard_order_line_rel',
192+ 'wizard_id', 'line_id',
193+ 'Sale Order Lines'),
194+ }
195+
196+ def validate(self, cr, uid, ids, context=None):
197+ order_obj = self.pool["sale.order"]
198+ line_obj = self.pool["sale.order.line"]
199+ order_id = context.get("active_id")
200+ order = order_obj.browse(cr, uid, order_id, context)
201+ for wizard in self.browse(cr, uid, ids):
202+ so_lines = []
203+ for line in wizard.order_line_ids:
204+ new_line_id = line_obj.copy(cr, uid, line.id,
205+ {"order_id": order_id}, context)
206+ # NOTE, use web_context_tunnel module if you need to override
207+ on_change_vals = line_obj.product_id_change(cr, uid, [],
208+ order.pricelist_id.id, line.product_id.id,
209+ line.product_uom_qty, line.product_id.uom_id.id,
210+ line.product_uos_qty, line.product_uos, line.name,
211+ order.partner_id.id, context.get('lang'), True,
212+ order.date_order, False,
213+ order.fiscal_position and order.fiscal_position.id,
214+ False, context)
215+
216+ vals = {}
217+ vals.update(on_change_vals['value'])
218+ vals['tax_id'] = [(6, 0, on_change_vals['value']['tax_id'])]
219+ vals['group_id'] = wizard.group_id and wizard.group_id.id
220+ so_lines.append((1, new_line_id, vals))
221+
222+ order_obj.write(cr, uid, [order_id], {'order_line': so_lines},
223+ context)
224+
225+ return {'type': 'ir.actions.act_window_close'}
226
227=== added file 'sale_import_lines/sale_view.xml'
228--- sale_import_lines/sale_view.xml 1970-01-01 00:00:00 +0000
229+++ sale_import_lines/sale_view.xml 2014-01-10 17:37:52 +0000
230@@ -0,0 +1,47 @@
231+<openerp>
232+ <data>
233+
234+ <record id="view_sale_order_import_form" model="ir.ui.view">
235+ <field name="name">view_sale_order_import_form</field>
236+ <field name="model">sale.order</field>
237+ <field name="type">form</field>
238+ <field name="inherit_id" ref="sale.view_order_form"/>
239+ <field name="arch" type="xml">
240+ <field name="order_line" position="before">
241+ <button name="button_lines_wizard_edit" string="Import" type="object"/>
242+ </field>
243+ </field>
244+ </record>
245+
246+ <record id="view_sale_import_lines_form" model="ir.ui.view">
247+ <field name="name">view_sale_import_lines_form</field>
248+ <field name="model">sale_import_lines.wizard</field>
249+ <field name="type">form</field>
250+ <field name="arch" type="xml">
251+ <form string="Line Importer">
252+ <group colspan="4" col="4">
253+ <field name="order_line_ids" colspan="4"/>
254+ <field name="group_id" colspan="2" context="{'analytic_account_id': context.get('analytic_account_id')}" domain="[('analytic_account_id', '=', context.get('analytic_account_id'))]"/>
255+ </group>
256+ <group>
257+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
258+ <button name="validate" string="Validate" type="object" icon="gtk-convert"/>
259+ </group>
260+ </form>
261+ </field>
262+ </record>
263+
264+ <record id="sales_import_sale_view_order_line_tree" model="ir.ui.view">
265+ <field name="name">sales_import_sale_view_order_line_tree</field>
266+ <field name="model">sale.order.line</field>
267+ <field name="inherit_id" ref="sale.view_order_line_tree"/>
268+ <field name="arch" type="xml">
269+ <field name="product_id" position="after">
270+ <field name="product_categ_id"/>
271+ <field name="group_id"/>
272+ </field>
273+ </field>
274+ </record>
275+
276+ </data>
277+</openerp>

Subscribers

People subscribed via source and target branches