openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #07107
[Merge] lp:~camptocamp/openerp-product-attributes/7.0-add_product_gtin-afe into lp:openerp-product-attributes
Alexandre Fayolle - camptocamp has proposed merging lp:~camptocamp/openerp-product-attributes/7.0-add_product_gtin-afe into lp:openerp-product-attributes.
Requested reviews:
Product Core Editors (product-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-add_product_gtin-afe/+merge/222760
replace product_gtin with chricar_product_gtin (from c2c-rd-addons), which works (whereas the existing module was not installable).
I ported the history of changes of that addon using bazaar-extractor, and Alexis de Lattre did the actual porting to V7 + OCA coding standards
--
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-add_product_gtin-afe/+merge/222760
Your team Product Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-product-attributes/7.0-add_product_gtin-afe into lp:openerp-product-attributes.
=== added directory 'product_gtin'
=== removed directory 'product_gtin'
=== added file 'product_gtin/__init__.py'
--- product_gtin/__init__.py 1970-01-01 00:00:00 +0000
+++ product_gtin/__init__.py 2014-06-11 08:42:55 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Product GTIN module for OpenERP
+# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# Fabien Pinckaers <fp@xxxxxxx>
+# Copyright (c) 2008 ChriCar Beteilugungs- und Beratungs- GmbH
+# All Rights Reserved.
+# Ferdinand Gassauer <tiny@xxxxxxxxxx>
+#
+# 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_gtin
=== removed file 'product_gtin/__init__.py'
--- product_gtin/__init__.py 2009-04-09 07:06:02 +0000
+++ product_gtin/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,31 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
-# Fabien Pinckaers <fp@xxxxxxx>
-# Copyright (c) 2008 ChriCar Beteilugungs- und Beratungs- GmbH All Rights Reserved.
-# Ferdinand Gassauer <tiny@xxxxxxxxxx>
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-##############################################################################
-
-import product_gtin
\ No newline at end of file
=== added file 'product_gtin/__openerp__.py'
--- product_gtin/__openerp__.py 1970-01-01 00:00:00 +0000
+++ product_gtin/__openerp__.py 2014-06-11 08:42:55 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Product GTIN module for OpenERP
+# Copyright (C) 2004-2011 Tiny SPRL (<http://tiny.be>).
+# Copyright (C) 2010-2011 Camptocamp Austria (<http://www.camptocamp.at>)
+#
+# 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": "Product GTIN EAN8 EAN13 UPC JPC Support",
+ "version": "1.1",
+ "author": "ChriCar Beteiligungs- und Beratungs- GmbH",
+ "website": "http://www.chricar.at/ChriCar",
+ "category": "Sales Management",
+ "depends": ["product"],
+ "description": """
+Product GTIN module
+===================
+
+Replaces the EAN13 field on products, partners and packaging by a field with the same technical name that accepts EAN13, EAN8, JPC, UPC and GTIN.
+ """,
+ "demo": [],
+ "data": [],
+ "installable": True,
+}
=== removed file 'product_gtin/__terp__.py'
--- product_gtin/__terp__.py 2013-01-21 06:49:06 +0000
+++ product_gtin/__terp__.py 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-{
- "name" : "Invalid - Please use chricar_product_gtin instead Product GTIN EAN UPC JPC Support",
- "version" : "1.0",
- "author" : "ChriCar Beteiligungs- und Beratungs- GmbH",
- "website" : "http://www.chricar.at/ChriCar",
- "category" : "Generic Modules/Others",
- "depends" : ["product"],
- "description" : """
-Replaces the EAN13 code completion with a checkroutine for EAN13, EAN8, UPC and GTIN.
-It allows to support different types of barcodes systems.
- """,
- "init_xml" : [],
- "demo_xml" : [],
- "update_xml" : [],
- "active": False,
- 'installable': False
-}
=== added directory 'product_gtin/i18n'
=== removed directory 'product_gtin/i18n'
=== added file 'product_gtin/i18n/de.po'
--- product_gtin/i18n/de.po 1970-01-01 00:00:00 +0000
+++ product_gtin/i18n/de.po 2014-06-11 08:42:55 +0000
@@ -0,0 +1,40 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * chricar_product_gtin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1rc1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-01-23 22:06+0000\n"
+"PO-Revision-Date: 2012-01-24 01:28+0000\n"
+"Last-Translator: Joël Grand-Guillaume @ CampToCamp "
+"<joel.grandguillaume@xxxxxxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Launchpad-Export-Date: 2012-10-23 05:13+0000\n"
+"X-Generator: Launchpad (build 16179)\n"
+
+#. module: chricar_product_gtin
+#: model:ir.model,name:chricar_product_gtin.model_product_packaging
+msgid "Packaging"
+msgstr "Verpackung"
+
+#. module: chricar_product_gtin
+#: model:ir.model,name:chricar_product_gtin.model_res_partner
+msgid "Partner"
+msgstr "Partner"
+
+#. module: chricar_product_gtin
+#: model:ir.model,name:chricar_product_gtin.model_product_product
+msgid "Product"
+msgstr "Produkt"
+
+#. module: chricar_product_gtin
+#: constraint:product.packaging:0
+#: constraint:product.product:0
+#: constraint:res.partner:0
+msgid "Error: Invalid EAN code"
+msgstr "Fehler: ungültiger EAN Code"
=== removed file 'product_gtin/i18n/fr_BE.po'
--- product_gtin/i18n/fr_BE.po 2014-05-17 07:09:00 +0000
+++ product_gtin/i18n/fr_BE.po 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_gtin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 5.0.6\n"
-"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
-"POT-Creation-Date: 2009-11-25 13:29+0000\n"
-"PO-Revision-Date: 2014-03-11 12:21+0000\n"
-"Last-Translator: <>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2014-05-17 07:08+0000\n"
-"X-Generator: Launchpad (build 17007)\n"
-
-#. module: product_gtin
-#: model:ir.module.module,description:product_gtin.module_meta_information
-msgid ""
-"\n"
-"Replaces the EAN13 code completion with a checkroutine for EAN13, EAN8, UPC "
-"and GTIN.\n"
-"It allows to support different types of barcodes systems.\n"
-" "
-msgstr ""
-
-#. module: product_gtin
-#: model:ir.module.module,shortdesc:product_gtin.module_meta_information
-msgid "Product GTIN EAN UPC JPC Support"
-msgstr ""
=== added file 'product_gtin/i18n/product_gtin.pot'
--- product_gtin/i18n/product_gtin.pot 1970-01-01 00:00:00 +0000
+++ product_gtin/i18n/product_gtin.pot 2014-06-11 08:42:55 +0000
@@ -0,0 +1,39 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * product_gtin
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-06-10 22:04+0000\n"
+"PO-Revision-Date: 2014-06-10 22:04+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: product_gtin
+#: constraint:product.packaging:0
+#: constraint:product.product:0
+#: constraint:res.partner:0
+msgid "Error: Invalid EAN code"
+msgstr ""
+
+#. module: product_gtin
+#: model:ir.model,name:product_gtin.model_product_packaging
+msgid "Packaging"
+msgstr ""
+
+#. module: product_gtin
+#: model:ir.model,name:product_gtin.model_res_partner
+msgid "Partner"
+msgstr ""
+
+#. module: product_gtin
+#: model:ir.model,name:product_gtin.model_product_product
+msgid "Product"
+msgstr ""
+
=== removed file 'product_gtin/i18n/product_gtin.pot'
--- product_gtin/i18n/product_gtin.pot 2010-01-04 05:32:54 +0000
+++ product_gtin/i18n/product_gtin.pot 1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_gtin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 5.0.6\n"
-"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
-"POT-Creation-Date: 2009-11-25 13:29:40+0000\n"
-"PO-Revision-Date: 2009-11-25 13:29:40+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: product_gtin
-#: model:ir.module.module,description:product_gtin.module_meta_information
-msgid "\n"
-"Replaces the EAN13 code completion with a checkroutine for EAN13, EAN8, UPC and GTIN.\n"
-"It allows to support different types of barcodes systems.\n"
-" "
-msgstr ""
-
-#. module: product_gtin
-#: model:ir.module.module,shortdesc:product_gtin.module_meta_information
-msgid "Product GTIN EAN UPC JPC Support"
-msgstr ""
-
=== removed file 'product_gtin/i18n/sv.po'
--- product_gtin/i18n/sv.po 2014-05-17 07:09:00 +0000
+++ product_gtin/i18n/sv.po 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-# Translation of OpenERP Server.
-# This file contains the translation of the following modules:
-# * product_gtin
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: OpenERP Server 5.0.14\n"
-"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
-"POT-Creation-Date: 2009-11-25 13:29+0000\n"
-"PO-Revision-Date: 2014-03-11 12:44+0000\n"
-"Last-Translator: Graeme Gellatly <Unknown>\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Launchpad-Export-Date: 2014-05-17 07:08+0000\n"
-"X-Generator: Launchpad (build 17007)\n"
-
-#. module: product_gtin
-#: model:ir.module.module,description:product_gtin.module_meta_information
-msgid ""
-"\n"
-"Replaces the EAN13 code completion with a checkroutine for EAN13, EAN8, UPC "
-"and GTIN.\n"
-"It allows to support different types of barcodes systems.\n"
-" "
-msgstr ""
-"\n"
-"Ersätter EAN13-koden med en kontrollrutin för EAN13, EAN8, UPC och GTIN.\n"
-"den tillåter användning av flera typer av streckkodsystem.\n"
-" "
-
-#. module: product_gtin
-#: model:ir.module.module,shortdesc:product_gtin.module_meta_information
-msgid "Product GTIN EAN UPC JPC Support"
-msgstr "Product GTIN EAN UPC JPC Support"
=== added file 'product_gtin/product_gtin.py'
--- product_gtin/product_gtin.py 1970-01-01 00:00:00 +0000
+++ product_gtin/product_gtin.py 2014-06-11 08:42:55 +0000
@@ -0,0 +1,109 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Product GTIN module for OpenERP
+# Copyright (C) 2004-2011 Tiny SPRL (<http://tiny.be>).
+# Copyright (C) 2010-2011 Camptocamp (<http://www.camptocamp.at>)
+#
+# 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.osv import orm, fields
+import operator
+
+
+def is_pair(x):
+ return not x % 2
+
+
+def check_ean(eancode):
+ if not eancode:
+ return True
+ if not len(eancode) in [8, 12, 13, 14]:
+ return False
+ try:
+ int(eancode)
+ except:
+ return False
+ sum = 0
+ ean13_len = int(len(eancode))
+ for i in range(ean13_len-1):
+ pos = int(ean13_len-2-i)
+ if is_pair(i):
+ sum += 3 * int(eancode[pos])
+ else:
+ sum += int(eancode[pos])
+ check = 10 - operator.mod(sum, 10)
+ if check == 10:
+ check = 0
+ if check != int(eancode[ean13_len-1]): # last digit
+ return False
+ return True
+
+
+class product_product(orm.Model):
+ _inherit = "product.product"
+
+ def _check_ean_key(self, cr, uid, ids):
+ for rec in self.browse(cr, uid, ids):
+ if not check_ean(rec.ean13):
+ return False
+ return True
+
+ _columns = {
+ 'ean13': fields.char(
+ 'EAN', size=14,
+ help="Code for EAN8 EAN13 UPC JPC GTIN "
+ "http://en.wikipedia.org/wiki/Global_Trade_Item_Number"),
+ }
+
+ _constraints = [(_check_ean_key, 'Error: Invalid EAN code', ['ean13'])]
+
+
+class product_packaging(orm.Model):
+ _inherit = "product.packaging"
+
+ def _check_ean_key(self, cr, uid, ids):
+ for rec in self.browse(cr, uid, ids):
+ if not check_ean(rec.ean):
+ return False
+ return True
+
+ _columns = {
+ 'ean': fields.char(
+ 'EAN', size=14,
+ help='Barcode number for EAN8 EAN13 UPC JPC GTIN'),
+ }
+
+ _constraints = [(_check_ean_key, 'Error: Invalid EAN code', ['ean'])]
+
+
+class res_partner(orm.Model):
+ _inherit = "res.partner"
+
+ def _check_ean_key(self, cr, uid, ids):
+ for rec in self.browse(cr, uid, ids):
+ if not check_ean(rec.ean13):
+ return False
+ return True
+
+ _columns = {
+ 'ean13': fields.char(
+ 'EAN', size=14,
+ help="Code for EAN8 EAN13 UPC JPC GTIN "
+ "http://en.wikipedia.org/wiki/Global_Trade_Item_Number"),
+ }
+
+ _constraints = [(_check_ean_key, 'Error: Invalid EAN code', ['ean13'])]
=== removed file 'product_gtin/product_gtin.py'
--- product_gtin/product_gtin.py 2009-04-09 07:06:02 +0000
+++ product_gtin/product_gtin.py 1970-01-01 00:00:00 +0000
@@ -1,105 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
-#
-# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-##############################################################################
-
-
-import netsvc
-from osv import fields, osv
-#import pooler
-#import wizard
-import math
-#from _common import rounding
-
-#import product
-
-# need to replace the check_ean_key function
-class product_product(osv.osv):
- _inherit = "product.product"
- _name = "product.product"
- _columns = {
- 'ean13': fields.char('EAN UPC JPC GTIN', size=14),
- }
- def _check_ean_key(self, cr, uid, ids):
- def is_pair(x):
- return not x%2
- for product in self.browse(cr, uid, ids):
- if not product.ean13:
- continue
- if not len(product.ean13) in [8,12,13,14]:
- return False
- try:
- int(product.ean13)
- except:
- return False
- sum=0
- ean_len=len(product.ean13)
- for i in range(ean_len-1):
- pos=int(ean_len-2-i)
- if is_pair(i):
- sum += 3 * int(product.ean13[pos])
- else:
- sum += int(product.ean13[pos])
- check = int(math.ceil(sum / 10.0) * 10 - sum)
- if check != int(product.ean13[ean_len-1]): # last digit
- return False
- return True
- _constraints = [(_check_ean_key, 'Error: Invalid EAN,UPC,JPC,GTIN code', ['ean13'])]
-product_product()
-
-class res_partner(osv.osv):
- _inherit = "res.partner"
- def _check_ean_key(self, cr, uid, ids):
- def is_pair(x):
- return not x%2
- for partner in self.browse(cr, uid, ids):
- if not partner.ean13:
- continue
- if not len(partner.ean13) in [8,12,13,14]:
- return False
- try:
- int(partner.ean13)
- except:
- return False
- sum=0
- ean_len=len(partner.ean13)
- for i in range(ean_len-1):
- pos=int(ean_len-2-i)
- if is_pair(i):
- sum += 3 * int(partner.ean13[pos])
- else:
- sum += int(partner.ean13[pos])
- check = int(math.ceil(sum / 10.0) * 10 - sum)
- if check != int(partner.ean13[ean_len-1]): # last digit
- return False
- return True
-
- _constraints = [(_check_ean_key, 'Error: Invalid EAN,UPC,JPC,GTIN code', ['ean13'])]
-
-res_partner()
-
Follow ups