← Back to team overview

clearcorp team mailing list archive

lp:~miguel-gutierrez-j/openerp-ccorp-addons/6.1-product_search_improver into lp:openerp-ccorp-addons

 

Miguel Gutierrez has proposed merging lp:~miguel-gutierrez-j/openerp-ccorp-addons/6.1-product_search_improver into lp:openerp-ccorp-addons.

Requested reviews:
  CLEARCORP drivers (clearcorp-drivers)

For more details, see:
https://code.launchpad.net/~miguel-gutierrez-j/openerp-ccorp-addons/6.1-product_search_improver/+merge/143125
-- 
https://code.launchpad.net/~miguel-gutierrez-j/openerp-ccorp-addons/6.1-product_search_improver/+merge/143125
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== added directory 'product_search_improver'
=== added file 'product_search_improver/__init__.py'
--- product_search_improver/__init__.py	1970-01-01 00:00:00 +0000
+++ product_search_improver/__init__.py	2013-01-14 15:24:32 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by SIESA
+#    Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+#    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 product

=== added file 'product_search_improver/__openerp__.py'
--- product_search_improver/__openerp__.py	1970-01-01 00:00:00 +0000
+++ product_search_improver/__openerp__.py	2013-01-14 15:24:32 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by SIESA
+#    Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+#    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" : "Products Search Extends",
+    "version" : "1.0",
+    "author" : "SIESA",
+    "category" : "Generic Modules/Inventory Control",
+    "depends" : ["base", "process","product","sale", "decimal_precision","stock"],
+    'complexity': "easy",
+    "website" : "http://www.siesacr.com";,
+    "description": """
+    This module add to product
+    currency_id,
+    part_number,
+    fob_currency_id,
+    cost_fob,
+    and improve the search logic.
+
+    """,
+    'update_xml': [
+        'product_view.xml',
+    ],
+    'installable': True,
+    'active': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'product_search_improver/product.py'
--- product_search_improver/product.py	1970-01-01 00:00:00 +0000
+++ product_search_improver/product.py	2013-01-14 15:24:32 +0000
@@ -0,0 +1,166 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by SIESA
+#    Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+#    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 osv, fields
+import decimal_precision as dp
+
+import math
+import logging
+import re
+from tools.translate import _
+
+
+class product_product(osv.osv):
+    _inherit = "product.product"
+    def _get_currency(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+        res = {}
+        for order in self.browse(cr, uid, ids):
+            res[order.id] = 0
+            for oline in order.order_line:
+                res[order.id] += oline.price_unit * oline.product_qty
+        return res
+
+    def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
+        res = {}
+        new_args = []
+        cont=0
+
+        if not args:
+            args = []
+        number_params = len(args)
+
+        while cont<number_params:
+            param=args[cont]
+            if ('part_number' in param) or ('default_code' in param) or ('name' in param):
+                search_vals = param[2].split()
+                for val in search_vals:
+                    new_args = new_args + [[param[0],'ilike', val]]
+
+            cont = cont +1
+        if len(new_args) > 0:
+            args = new_args
+
+        res = super(product_product, self).search(cr, uid, args, offset, limit, order, context, count)
+
+        return res
+
+
+
+    def _product_price(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+        if context is None:
+            context = {}
+        quantity = context.get('quantity') or 1.0
+        pricelist = context.get('pricelist', False)
+        if pricelist:
+            for id in ids:
+                try:
+                    price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, context=context)[pricelist]
+                except:
+                    price = 0.0
+                res[id] = price
+        for id in ids:
+            res.setdefault(id, 0.0)
+        return res
+
+    def _product_partner_ref(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+        if context is None:
+            context = {}
+        for p in self.browse(cr, uid, ids, context=context):
+            data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context=context)
+            if not data['code']:
+                data['code'] = p.code
+            if not data['name']:
+                data['name'] = p.name
+            res[p.id] = (data['code'] and ('['+data['code']+'] ') or '') + \
+                    (data['name'] or '')
+        return res
+
+    _columns = {
+        'currency_id': fields.many2one('res.currency','Currency'),
+        'part_number': fields.char('Part Number', size=90),
+        'default_code' : fields.char('Reference', size=64, select=True),
+        'import_ok': fields.boolean('Could be imported'),
+        'cost_fob': fields.float('Cost FOB o Ex Works'),
+        'fob_currency_id': fields.many2one('res.currency','FoB Currency'),
+    }
+    _sql_constraints = [
+        ('default_code_uniq', 'unique (default_code)', 'El code must be unique!')
+    ]
+    _defaults = {
+        'import_ok': lambda *a: 1,
+    }
+
+
+    def price_get(self, cr, uid, ids, ptype='list_price', context=None):
+        if context is None:
+            context = {}
+
+        if 'currency_id' in context:
+            pricetype_obj = self.pool.get('product.price.type')
+            price_type_id = pricetype_obj.search(cr, uid, [('field','=',ptype)])[0]
+            price_type_currency_id = pricetype_obj.browse(cr,uid,price_type_id).currency_id.id
+
+        res = {}
+        product_uom_obj = self.pool.get('product.uom')
+        for product in self.browse(cr, uid, ids, context=context):
+            res[product.id] = product[ptype] or 0.0
+            if ptype == 'list_price':
+                res[product.id] = (res[product.id] * (product.price_margin or 1.0)) + \
+                        product.price_extra
+            if 'uom' in context:
+                uom = product.uos_id or product.uom_id
+                res[product.id] = product_uom_obj._compute_price(cr, uid,
+                        uom.id, res[product.id], context['uom'])
+            if 'currency_id' in context:
+                res[product.id] = self.pool.get('res.currency').compute(cr, uid, price_type_currency_id,
+                    context['currency_id'], res[product.id],context=context)
+
+        return res
+
+    def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
+        if not args:
+            args = []
+        if name:
+            ids = self.search(cr, user, [['default_code','ilike',name]]+ args, limit=limit, context=context)
+            if not ids:
+                ids = self.search(cr, user, [['part_number','ilike',name]]+ args, limit=limit, context=context)
+            if not ids:
+                ids = set()
+                ids.update(self.search(cr, user, args + [['default_code',operator,name]], limit=limit, context=context))
+                if len(ids) < limit:
+                    ids.update(self.search(cr, user, args + [['name',operator,name]], limit=(limit-len(ids)), context=context))
+                ids = list(ids)
+            if not ids:
+                ptrn = re.compile('(\[(.*?)\])')
+                res = ptrn.search(name)
+                if res:
+                    ids = self.search(cr, user, [('default_code','=', res.group(2))] + args, limit=limit, context=context)
+        else:
+            ids = self.search(cr, user, args, limit=limit, context=context)
+        result = self.name_get(cr, user, ids, context=context)
+        return result
+
+product_product()
+
+

=== added file 'product_search_improver/product_view.xml'
--- product_search_improver/product_view.xml	1970-01-01 00:00:00 +0000
+++ product_search_improver/product_view.xml	2013-01-14 15:24:32 +0000
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="siesa_product_search_form_view" model="ir.ui.view">
+            <field name="name">product.search.form</field>
+            <field name="model">product.product</field>
+            <field name="type">search</field>
+            <field name="inherit_id" ref="product.product_search_form_view"/>
+            <field name="arch" type="xml">
+                   <field name="name" position="replace">
+                       <field name="name"/>
+                       <field name="part_number"/>
+                       <field name="default_code" string="Código"/>
+                   </field>
+            </field>
+        </record>
+        <record id="siesa_product_product_tree_view" model="ir.ui.view">
+            <field name="name">product.product.tree</field>
+            <field name="model">product.product</field>
+            <field name="type">tree</field>
+            <field name="inherit_id" ref="product.product_product_tree_view"/>
+            <field eval="7" name="priority"/>
+            <field name="arch" type="xml">
+                    <field name="default_code" position="after">
+                        <field name="part_number" />
+                    </field>
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="siesa_view_product_form">
+            <field name="name">product.normal.form</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_normal_form_view" />
+            <field name="type">form</field>
+            <field eval="2" name="priority"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form/group/group/field[@name='name']" position="after">
+                    <field name="part_number" />
+                </xpath>
+                <xpath expr="/form/group/group/field[@name='purchase_ok']" position="after">
+                    <field name="import_ok"/>
+                </xpath>
+                <xpath expr="/form/notebook/page[@string='Information']/group/field[@name='standard_price']" position="replace">
+                    <field  groups="base.group_sale_manager" name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"  sequence="3"/>
+                </xpath>
+                <xpath expr="/form/notebook/page[@string='Information']/group/field[@name='uom_po_id']" position="after">
+                     <separator string="Import Product" colspan="2" attrs="{'invisible':[('import_ok','!=','1')]}"/>
+                    <field name="fob_currency_id" string="Import Currency" attrs="{'invisible':[('import_ok','!=','1')]}"/>
+                    <field name="cost_fob" string="Import Cost" attrs="{'invisible':[('import_ok','!=','1')]}"/>
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>

=== removed directory 'sale_order_extended'
=== removed file 'sale_order_extended/__init__.py'
--- sale_order_extended/__init__.py	2012-10-30 15:17:40 +0000
+++ sale_order_extended/__init__.py	1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Addons modules by CLEARCORP S.A.
-#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
-#
-#    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_order_extended

=== removed file 'sale_order_extended/__openerp__.py'
--- sale_order_extended/__openerp__.py	2012-10-30 15:17:40 +0000
+++ sale_order_extended/__openerp__.py	1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Addons modules by CLEARCORP S.A.
-#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
-#
-#    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" : 'CLEARCORP Sale Order Extended',
-    "version" : '2.0',
-    "author" : 'CLEARCORP S.A.',
-    #easy, normal, expert
-    'complexity': 'normal',
-    "description": """
-Customization from sale.order to apply due dates in views and reports, and custom footer for report
-    """,
-    "category": 'Sales',
-    "sequence": 4,
-    "website" : "http://clearcorp.co.cr";,
-    "images" : [],
-    "icon" : False,
-    "depends" : [
-        'sale'],
-    "init_xml" : [],
-    "demo_xml" : [],
-    "update_xml" : ['sale_order_extended_view.xml'],
-    "test" : [],
-    "auto_install": False,
-    "application": False,
-    "installable": True,
-    'license': 'AGPL-3',
-}

=== removed directory 'sale_order_extended/i18n'
=== removed symlink 'sale_order_extended/i18n/es.po'
=== target was u'es_CR.po'
=== removed file 'sale_order_extended/i18n/es_CR.po'
--- sale_order_extended/i18n/es_CR.po	2012-10-30 15:17:40 +0000
+++ sale_order_extended/i18n/es_CR.po	1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-#	* sale_order_extended
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 6.1\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-29 16:03+0000\n"
-"PO-Revision-Date: 2012-10-29 16:03+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_order_extended
-#: sql_constraint:sale.order:0
-msgid "Order Reference must be unique per Company!"
-msgstr "¡La referencia de la compra debe ser única por compañía!"
-
-#. module: sale_order_extended
-#: view:res.company:0
-msgid "Configuration"
-msgstr "Configuración"
-
-#. module: sale_order_extended
-#: sql_constraint:res.company:0
-msgid "The company name must be unique !"
-msgstr "¡El nombre de la compañía debe ser único!"
-
-#. module: sale_order_extended
-#: model:ir.model,name:sale_order_extended.model_sale_order
-msgid "Sales Order"
-msgstr "Pedido de venta"
-
-#. module: sale_order_extended
-#: model:ir.model,name:sale_order_extended.model_res_company
-msgid "Companies"
-msgstr "Compañías"
-
-#. module: sale_order_extended
-#: constraint:res.company:0
-msgid "Error! You can not create recursive companies."
-msgstr "¡Error! No puede crear compañías recursivas."
-
-#. module: sale_order_extended
-#: view:res.company:0
-msgid "Sales"
-msgstr "Ventas"
-
-#. module: sale_order_extended
-#: field:res.company,show_sale_order_footer:0
-msgid "Show Sale Order Footer"
-msgstr "Mostrar pie de pagina de Orden de Venta"
-
-#. module: sale_order_extended
-#: field:res.company,sale_order_footer:0
-msgid "Sale Order Footer"
-msgstr "Pie de pagina de Orden de Venta"
-
-#. module: sale_order_extended
-#: field:sale.order,expiration_date:0
-msgid "Expiration date"
-msgstr "Fecha vencimiento"
-

=== removed file 'sale_order_extended/sale_order_extended.py'
--- sale_order_extended/sale_order_extended.py	2012-10-30 15:35:46 +0000
+++ sale_order_extended/sale_order_extended.py	1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Addons modules by CLEARCORP S.A.
-#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
-#
-#    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 osv
-from osv import fields
-import os
-import tools
-from tools.translate import _
-from tools.safe_eval import safe_eval as eval
-
-class res_company(osv.osv):
-      _inherit = 'res.company'
-      _columns =  {
-        'sale_order_footer': fields.text('Sale Order Footer'),
-        'show_sale_order_footer': fields.boolean('Show Sale Order Footer'),       
-            } 
-      _defaults = {
-        'show_sale_order_footer': False        
-            }
-      
-
-class sale_order(osv.osv):
-      _inherit = 'sale.order'
-      _columns =  {
-        'expiration_date': fields.date('Expiration date'),       
-            } 

=== removed file 'sale_order_extended/sale_order_extended_view.xml'
--- sale_order_extended/sale_order_extended_view.xml	2012-10-30 15:17:40 +0000
+++ sale_order_extended/sale_order_extended_view.xml	1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<openerp>
-	<data>
-		<record id="view_company_form_inherit" model="ir.ui.view">
-			<field name="name">res.company.form.inherit</field>
-			<field name="model">res.company</field>
-			<field name="inherit_id" ref="base.view_company_form"/>
-			<field name="priority">33</field>
-			<field name="type">form</field>
-			<field name="arch" type="xml">
-				<page string="Configuration" position="inside">
-					<separator string="Sales" colspan="4"/>
-						<field name="sale_order_footer" colspan="2"/>
-						<field name="show_sale_order_footer" colspan="2"/>
-				</page>
-			</field>
-		</record>
-		
-		<record id="view_order_form_inherit" model="ir.ui.view">
-			<field name="name">sale.order.form.inherit</field>
-			<field name="model">sale.order</field>
-			<field name="inherit_id" ref="sale.view_order_form"/>
-			<field name="type">form</field>
-			<field name="arch" type="xml">
-				<field name="client_order_ref" position="after">
-					<field name="expiration_date"/> 
-				</field>
-			</field>
-		</record>
-	</data>
-</openerp>
\ No newline at end of file