← Back to team overview

openerp-community-reviewer team mailing list archive

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

 

Raphaël Valyi - http://www.akretion.com has proposed merging lp:~akretion-team/sale-wkfl/7.0-add-sale_import_lines into lp:sale-wkfl with lp:~akretion-team/sale-wkfl/7.0-add-sale_group as a prerequisite.

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

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

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.
-- 
https://code.launchpad.net/~akretion-team/sale-wkfl/7.0-add-sale_import_lines/+merge/201021
Your team Sale Core Editors is requested to review the proposed merge of lp:~akretion-team/sale-wkfl/7.0-add-sale_import_lines into lp:sale-wkfl.
=== added directory 'sale_import_lines'
=== added file 'sale_import_lines/__init__.py'
--- sale_import_lines/__init__.py	1970-01-01 00:00:00 +0000
+++ sale_import_lines/__init__.py	2014-01-09 15:02:28 +0000
@@ -0,0 +1,1 @@
+import sale

=== added file 'sale_import_lines/__openerp__.py'
--- sale_import_lines/__openerp__.py	1970-01-01 00:00:00 +0000
+++ sale_import_lines/__openerp__.py	2014-01-09 15:02:28 +0000
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2013 Akretion LDTA (<http://www.akretion.com>).
+#    @author Raphaël Valyi
+#
+#    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 Order Line importation utilities",
+    "version": "1.0",
+    "author" : "Akretion",
+    "website" : "http://www.akretion.com";,
+    "category" : "Others",
+    "depends" : ["sale", "sale_group"],
+    "description": """
+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.
+    """,
+    "init_xml" : [],
+    "demo_xml" : [],
+    "test" : [],
+    "update_xml": ["sale_view.xml"],
+    'installable': True,
+    'active': False,
+    'certificate': None,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'sale_import_lines/i18n'
=== added file 'sale_import_lines/i18n/pt_BR.po'
--- sale_import_lines/i18n/pt_BR.po	1970-01-01 00:00:00 +0000
+++ sale_import_lines/i18n/pt_BR.po	2014-01-09 15:02:28 +0000
@@ -0,0 +1,63 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* sale_import_lines
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-06-10 18:17+0000\n"
+"PO-Revision-Date: 2013-06-10 18:17+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: sale_import_lines
+#: sql_constraint:sale.order:0
+msgid "Order Reference must be unique per Company!"
+msgstr "A Referência do Pedido deve ser única por empresa!"
+
+#. module: sale_import_lines
+#: field:sale_import_lines.wizard,group_id:0
+msgid "Sale Group"
+msgstr "Grupo de Venda"
+
+#. module: sale_import_lines
+#: field:sale_import_lines.wizard,order_line_ids:0
+msgid "Sale Order Lines"
+msgstr "Linhas de pedido de venda"
+
+#. module: sale_import_lines
+#: view:sale_import_lines.wizard:0
+msgid "Cancel"
+msgstr "Cancelar"
+
+#. module: sale_import_lines
+#: view:sale.order:0
+msgid "Import"
+msgstr "Importar"
+
+#. module: sale_import_lines
+#: view:sale_import_lines.wizard:0
+msgid "Validate"
+msgstr "Validar"
+
+#. module: sale_import_lines
+#: model:ir.model,name:sale_import_lines.model_sale_order
+msgid "Sales Order"
+msgstr "Pedido de Venda"
+
+#. module: sale_import_lines
+#: code:addons/sale_import_lines/sale.py:14
+#, python-format
+msgid "Sale Order Lines Importation Wizard"
+msgstr "Linhas de pedido de venda Importação Wizard"
+
+#. module: sale_import_lines
+#: model:ir.model,name:sale_import_lines.model_sale_import_lines_wizard
+msgid "sale_import_lines.wizard"
+msgstr "sale_import_lines.wizard"
+

=== added file 'sale_import_lines/sale.py'
--- sale_import_lines/sale.py	1970-01-01 00:00:00 +0000
+++ sale_import_lines/sale.py	2014-01-09 15:02:28 +0000
@@ -0,0 +1,96 @@
+# -*- encoding: utf-8 -*-
+###############################################################################
+#                                                                             #
+# Copyright (C) 2013  Raphaël Valyi - Akretion                                #
+#                                                                             #
+#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 osv import orm, fields
+from tools.translate import _
+
+
+class sale_order(orm.Model):
+    _inherit = "sale.order"
+
+    def button_lines_wizard_edit(self, cr, uid, ids, context=None):
+        analytic_account_id = self.read(cr, uid, ids, ['project_id'],
+                               context)[0].get('project_id')
+        context['analytic_account_id'] = analytic_account_id and\
+                                         analytic_account_id[0]
+        return {
+            'context': context,
+            'name': _('Sale Order Lines Importation Wizard'),
+            'view_type': 'form',
+            'view_mode': 'form',
+            'res_model': 'sale_import_lines.wizard',
+            'type': 'ir.actions.act_window',
+            'target': 'new',
+        }
+
+
+class sale_order_line(orm.Model):
+    _inherit = 'sale.order.line'
+
+    _columns = {
+        'product_categ_id': fields.related('product_id', 'categ_id',
+                                           type='many2one', readonly=True,
+                                           relation='product.category',
+                                           store=True,
+                                           string='Product Category'),
+    }
+
+
+class sale_import_lines_wizard(orm.TransientModel):
+    _name = "sale_import_lines.wizard"
+    _rec_name = "group_id"
+
+    _columns = {
+        'group_id': fields.many2one('sale.order.line.group', 'Sale Group'),
+        'order_line_ids': fields.many2many('sale.order.line',
+                                           'sale_lines_wizard_order_line_rel',
+                                           'wizard_id', 'line_id',
+                                           'Sale Order Lines'),
+    }
+
+    def validate(self, cr, uid, ids, context=None):
+        order_obj = self.pool["sale.order"]
+        line_obj = self.pool["sale.order.line"]
+        order_id = context.get("active_id")
+        order = order_obj.browse(cr, uid, order_id, context)
+        for wizard in self.browse(cr, uid, ids):
+            so_lines = []
+            for line in wizard.order_line_ids:
+                new_line_id = line_obj.copy(cr, uid, line.id,
+                                            {"order_id": order_id}, context)
+                # NOTE, use web_context_tunnel module if you need to override
+                on_change_vals = line_obj.product_id_change(cr, uid, [],
+                          order.pricelist_id.id, line.product_id.id,
+                          line.product_uom_qty, line.product_id.uom_id.id,
+                          line.product_uos_qty, line.product_uos, line.name,
+                          order.partner_id.id, context.get('lang'), True,
+                          order.date_order, False,
+                          order.fiscal_position and order.fiscal_position.id,
+                          False, context)
+
+                vals = {}
+                vals.update(on_change_vals['value'])
+                vals['tax_id'] = [(6, 0, on_change_vals['value']['tax_id'])]
+                vals['group_id'] = wizard.group_id and wizard.group_id.id
+                so_lines.append((1, new_line_id, vals))
+
+            order_obj.write(cr, uid, [order_id], {'order_line': so_lines},
+                            context)
+
+        return {'type': 'ir.actions.act_window_close'}

=== added file 'sale_import_lines/sale_view.xml'
--- sale_import_lines/sale_view.xml	1970-01-01 00:00:00 +0000
+++ sale_import_lines/sale_view.xml	2014-01-09 15:02:28 +0000
@@ -0,0 +1,47 @@
+<openerp>
+    <data>
+
+        <record id="view_sale_order_import_form" model="ir.ui.view">
+            <field name="name">view_sale_order_import_form</field>
+            <field name="model">sale.order</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="sale.view_order_form"/>
+            <field name="arch" type="xml">
+                <field name="order_line" position="before">
+                    <button name="button_lines_wizard_edit" string="Import" type="object"/>
+                </field>
+            </field>
+        </record>
+
+        <record id="view_sale_import_lines_form" model="ir.ui.view">
+            <field name="name">view_sale_import_lines_form</field>
+            <field name="model">sale_import_lines.wizard</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form>
+                    <group colspan="4" col="4">
+                        <field name="order_line_ids" colspan="4"/>
+                        <field name="group_id" colspan="2" context="{'analytic_account_id': context.get('analytic_account_id')}" domain="[('analytic_account_id', '=', context.get('analytic_account_id'))]"/>
+                    </group>
+                    <group>
+                    <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+                    <button name="validate" string="Validate" type="object" icon="gtk-convert"/>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record id="sales_import_sale_view_order_line_tree" model="ir.ui.view">
+            <field name="name">sales_import_sale_view_order_line_tree</field>
+            <field name="model">sale.order.line</field>
+            <field name="inherit_id" ref="sale.view_order_line_tree"/>
+            <field name="arch" type="xml">
+                <field name="product_id" position="after">
+                    <field name="product_categ_id"/>
+                        <field name="group_id"/>
+                    </field>
+            </field>
+        </record>
+
+    </data>
+</openerp>


Follow ups