Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions __unported__/product_customer_code/__init__.py

This file was deleted.

73 changes: 0 additions & 73 deletions __unported__/product_customer_code/product.py

This file was deleted.

67 changes: 0 additions & 67 deletions __unported__/product_customer_code/product_customer_code.py

This file was deleted.

12 changes: 12 additions & 0 deletions product_customer_code/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Customer' codes in product
==========================

This module does just like the product.supplierinfo but for customers instead. For instance it
allows to have different references for the same product according to the customer.

.. image:: product_customer_code/static/src/img/screenshot1.png

.. tip::

You will need install some of the Apps which enable the product menu to see this module in
action, like Sales, Purchase or Warehouse Management
27 changes: 27 additions & 0 deletions product_customer_code/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
#
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/
# All Rights Reserved.
# info Vauxoo (info@vauxoo.com)
############################################################################
# Coded by: el_rodo_1 (rodo@vauxoo.com)
############################################################################
# Migrated to Odoo 8.0 by Acysos S.L. - http://www.acysos.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 . import models
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
############################################################################
# Coded by: el_rodo_1 (rodo@vauxoo.com)
############################################################################
# Migrated to Odoo 8.0 by Acysos S.L. - http://www.acysos.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
Expand All @@ -24,37 +25,24 @@
#
##############################################################################
{
"name": "Products Customer Code",
"version": "1.0",
"author": "Vauxoo",
"website": "http://www.vauxoo.com/",
"license": "AGPL-3",
"category": "Generic Modules/Product",
"summary": "Add many Customers' Codes in product",
"depends": [
"base",
"product",
'name': 'Products Customer Code',
'version': '1.0',
'author': 'Vauxoo',
'website': 'http://www.vauxoo.com/',
'contributors': ['Acysos S.L.'],
'license': 'AGPL-3',
'category': 'Generic Modules/Product',
'summary': 'Add many Customers Codes in product',
'depends': [
'base',
'product',
],
"description": """
Customer' codes in product
==========================

This module does just like the product.supplierinfo but for customers instead. For instance it
allows to have different references for the same product according to the customer.

.. image:: product_customer_code/static/src/img/screenshot1.png

.. tip::

You will need install some of the Apps which enable the product menu to see this module in
action, like Sales, Purchase or Warehouse Management
""",
"data": [
"security/product_customer_code_security.xml",
"security/ir.model.access.csv",
"product_customer_code_view.xml",
"product_product_view.xml",
'data': [
'security/product_customer_code_security.xml',
'security/ir.model.access.csv',
'views/product_customer_code_view.xml',
'views/product_product_view.xml',
],
"active": False,
'installable': False,
'active': False,
'installable': True,
}
28 changes: 28 additions & 0 deletions product_customer_code/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
#
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com/
# All Rights Reserved.
# info Vauxoo (info@vauxoo.com)
############################################################################
# Coded by: el_rodo_1 (rodo@vauxoo.com)
############################################################################
# Migrated to Odoo 8.0 by Acysos S.L. - http://www.acysos.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 . import product_customer_code
from . import product
116 changes: 116 additions & 0 deletions product_customer_code/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# -*- coding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
#
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
# All Rights Reserved.
# info@vauxoo.com
############################################################################
# Coded by: Rodo (rodo@vauxoo.com),Moy (moylop260@vauxoo.com)
############################################################################
# Migrated to Odoo 8.0 by Acysos S.L. - http://www.acysos.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 openerp import models, fields, api


class ProductTemplate(models.Model):
_inherit = "product.template"

product_customer_code_ids = fields.One2many(
comodel_name='product.customer.code', inverse_name='product_id',
string='Customer Codes')

@api.model
def copy(self, default):
if not default:
default = {}
default['product_customer_code_ids'] = False
res = super(ProductTemplate, self).copy(default)
return res

def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
res = super(ProductTemplate, self).search(cr, uid, args, offset=offset,
limit=limit, order=order,
count=count)
operator = False
term = False
for arg in args:
if arg[0] == 'name':
operator = arg[1]
term = arg[2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break

if not res and operator is not False and term is not False:
product_customer_code_obj = self.pool.get('product.customer.code')
product_ids = set(product_customer_code_obj.search(
cr, uid, [('product_code', operator, term)], limit=limit,
context=context))
if not limit or len(product_ids) < limit:
limit2 = (limit - len(product_ids)) if limit else False
product_ids.update(product_customer_code_obj.search(
cr, uid, [('product_name', operator, term)], limit=limit2,
context=context))
product_ids = list(product_ids)

product_datas = product_customer_code_obj.browse(cr, uid,
product_ids,
context)

prod_ids = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do: res = [x.product_id.id for x in product_datas]

for product_data in product_datas:
prod_ids.append(product_data.product_id.id)
res = prod_ids

return res


class ProductProduct(models.Model):
_inherit = "product.product"

def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
res = super(ProductProduct, self).search(cr, uid, args, offset=offset,
limit=limit, order=order,
context=context, count=count)
operator = False
term = False
for arg in args:
if arg[0] == 'name':
operator = arg[1]
term = arg[2]

if not res and operator is not False and term is not False:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you call it here template search?

cust_data_obj = self.pool.get('product.customer.code')
cust_ids = set(cust_data_obj.search(
cr, uid, [('product_code', operator, term)], limit=limit,
context=context))
if not limit or len(cust_ids) < limit:
limit2 = (limit - len(cust_ids)) if limit else False
cust_ids.update(cust_data_obj.search(
cr, uid, [('product_name', operator, term)], limit=limit2,
context=context))
cust_ids = list(cust_ids)

products_template = cust_data_obj.read(cr, uid, cust_ids,
['product_id'], context)
product_obj = self.pool.get('product.product')
for template in products_template:
prod_ids = product_obj.search(
cr, uid, [('product_tmpl_id', '=',
template['product_id'][0])], context=context)
for prod_id in prod_ids:
res.append(prod_id)
return res
Loading