Selaa lähdekoodia

commit inicial

Rodney Enciso Arias 8 vuotta sitten
commit
6337a1147a
9 muutettua tiedostoa jossa 254 lisäystä ja 0 poistoa
  1. 13 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 50 0
      __openerp__.py
  4. 39 0
      i18n/en.po
  5. 39 0
      i18n/es.po
  6. 40 0
      i18n/lt.po
  7. 39 0
      i18n/product_unique.pot
  8. 34 0
      product.py
  9. BIN
      product.pyc

+ 13 - 0
__init__.py

@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+
+
+#
+# Insert all includes necesary for this module
+#
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+from . import product

BIN
__init__.pyc


+ 50 - 0
__openerp__.py

@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2015  ADHOC SA  (http://www.adhoc.com.ar)
+#    All Rights Reserved.
+#
+#    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 Unique',
+    'version': '8.0.1.0.0',
+    'category': 'Product',
+    'sequence': 14,
+    'summary': '',
+    'description': """
+Product Unique
+==============
+Module to made "ean13" and "default_code" fields to be unique for products on the same company.
+    """,
+    'author':  'ADHOC SA/Rodney Enciso Arias',
+    'website': 'www.adhoc.com.ar',
+    'license': 'AGPL-3',
+    'images': [
+    ],
+    'depends': [
+        'product','product_barcode_athletic',
+    ],
+    'data': [
+    ],
+    'demo': [
+    ],
+    'test': [
+    ],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 39 - 0
i18n/en.po

@@ -0,0 +1,39 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_unique
+# 
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: odoo-addons (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-09-09 23:58+0000\n"
+"PO-Revision-Date: 2015-09-01 17:59+0000\n"
+"Last-Translator: Juan Jose Scarafia <scarafia.juanjose@gmail.com>\n"
+"Language-Team: English (http://www.transifex.com/adhoc/ingadhoc-odoo-addons-8-0/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: product_unique
+#: model:ir.model,name:product_unique.model_product_product
+msgid "Product"
+msgstr "Product"
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:34
+#, python-format
+msgid ""
+"There can not be two active products with the same EAN code in the same "
+"company"
+msgstr "There can not be two active products with the same EAN code in the same company"
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:23
+#, python-format
+msgid ""
+"There can not be two active products with the same Reference ode in the same"
+" company."
+msgstr "There can not be two active products with the same Reference ode in the same company."

+ 39 - 0
i18n/es.po

@@ -0,0 +1,39 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_unique
+# 
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: odoo-addons (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-09-09 23:58+0000\n"
+"PO-Revision-Date: 2015-09-01 17:59+0000\n"
+"Last-Translator: Juan Jose Scarafia <scarafia.juanjose@gmail.com>\n"
+"Language-Team: Spanish (http://www.transifex.com/adhoc/ingadhoc-odoo-addons-8-0/language/es/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: es\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: product_unique
+#: model:ir.model,name:product_unique.model_product_product
+msgid "Product"
+msgstr "Producto"
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:34
+#, python-format
+msgid ""
+"There can not be two active products with the same EAN code in the same "
+"company"
+msgstr "No puede haber dos productos activos con el mismo código EAN en la misma empresa"
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:23
+#, python-format
+msgid ""
+"There can not be two active products with the same Reference ode in the same"
+" company."
+msgstr "No puede haber dos productos activos con la misma ode de referencia en la misma empresa ."

+ 40 - 0
i18n/lt.po

@@ -0,0 +1,40 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * product_unique
+# 
+# Translators:
+# UAB "Draugiški sprendimai" <transifex@draugiskisprendimai.lt>, 2015
+msgid ""
+msgstr ""
+"Project-Id-Version: odoo-addons (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-01-05 15:03+0000\n"
+"PO-Revision-Date: 2015-09-18 23:14+0000\n"
+"Last-Translator: UAB \"Draugiški sprendimai\" <transifex@draugiskisprendimai.lt>\n"
+"Language-Team: Lithuanian (http://www.transifex.com/adhoc/ingadhoc-odoo-addons-8-0/language/lt/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: lt\n"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+
+#. module: product_unique
+#: model:ir.model,name:product_unique.model_product_product
+msgid "Product"
+msgstr "Produktas"
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:34
+#, python-format
+msgid ""
+"There can not be two active products with the same EAN code in the same "
+"company"
+msgstr "Čia negali būti du aktyvūs produktai, turintys tokį pat EAN kodą vienoje įmonėje"
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:23
+#, python-format
+msgid ""
+"There can not be two active products with the same Reference ode in the same"
+" company."
+msgstr "Čia negali būti du aktyvūs produktai, turintys tokia pačia nuorodą vienoje įmonėje."

+ 39 - 0
i18n/product_unique.pot

@@ -0,0 +1,39 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+#	* product_unique
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Odoo Server 8.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-02-23 12:11+0000\n"
+"PO-Revision-Date: 2015-02-23 12:11+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_unique
+#: field:product.product,company_id:0
+msgid "Company"
+msgstr ""
+
+#. module: product_unique
+#: model:ir.model,name:product_unique.model_product_product
+msgid "Product"
+msgstr ""
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:37
+#, python-format
+msgid "There can not be two active products with the same EAN code in the same company"
+msgstr ""
+
+#. module: product_unique
+#: code:addons/product_unique/product.py:26
+#, python-format
+msgid "There can not be two active products with the same Reference ode in the same company."
+msgstr ""
+

+ 34 - 0
product.py

@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+from openerp import models, api, _
+from openerp.exceptions import Warning
+
+
+class product_template(models.Model):
+    _inherit = "product.template"
+
+    @api.one
+    @api.constrains('company_id', 'factory_reference', 'active')
+    def check_unique_company_and_factory_reference(self):
+        if self.active and self.factory_reference and self.company_id:
+            filters = [('company_id', '=', self.company_id.id),
+                       ('factory_reference', '=', self.factory_reference),
+                       ('active', '=', True)]
+            prod_ids = self.search(filters)
+            if len(prod_ids) > 1:
+                raise Warning(
+                    _('There can not be two active products with the same Reference in the same company.'))
+
+    @api.one
+    @api.constrains('company_id', 'ean13', 'active')
+    def check_unique_company_and_ean13(self):
+        if self.active and self.ean13 and self.company_id:
+            filters = [('company_id', '=', self.company_id.id),
+                       ('ean13', '=', self.ean13), ('active', '=', True)]
+            prod_ids = self.search(filters)
+            if len(prod_ids) > 1:
+                raise Warning(
+                    _('There can not be two active products with the same EAN code in the same company'))

BIN
product.pyc