Add module second_ean13
This commit is contained in:
3
pos_second_ean13/__init__.py
Normal file
3
pos_second_ean13/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import product
|
||||||
43
pos_second_ean13/__openerp__.py
Normal file
43
pos_second_ean13/__openerp__.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# POS Second EAN13 module for Odoo
|
||||||
|
# Copyright (C) 2016 Akretion (http://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.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': 'POS Second EAN13',
|
||||||
|
'version': '0.1',
|
||||||
|
'category': 'Point Of Sale',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'summary': "Add a second EAN13 on products",
|
||||||
|
'description': """
|
||||||
|
POS Second EAN13
|
||||||
|
================
|
||||||
|
|
||||||
|
This module adds a second EAN13 field on products. This feature has been asked by librairies that often have the same book available from 2 different sources with different EAN13 (to keep things simple, I didn't want to handle N EAN13 ; a second EAN13 was enough for most cases). This module also provides a patch to apply on the javascript of the official *point_of_sale* module.
|
||||||
|
|
||||||
|
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
|
||||||
|
""",
|
||||||
|
'author': 'Akretion',
|
||||||
|
'website': 'http://www.akretion.com',
|
||||||
|
'depends': ['product'],
|
||||||
|
'data': ['product_view.xml'],
|
||||||
|
'installable': True,
|
||||||
|
}
|
||||||
47
pos_second_ean13/product.py
Normal file
47
pos_second_ean13/product.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# POS Second EAN13 module for Odoo
|
||||||
|
# Copyright (C) 2016 Akretion (http://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.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, _
|
||||||
|
from openerp.exceptions import ValidationError
|
||||||
|
from openerp.addons.product.product import check_ean
|
||||||
|
|
||||||
|
|
||||||
|
class ProductProduct(models.Model):
|
||||||
|
_inherit = 'product.product'
|
||||||
|
|
||||||
|
second_ean13 = fields.Char(
|
||||||
|
string='Second EAN13 Barcode', size=13,
|
||||||
|
help='If the same product is available with two EAN13, you can enter '
|
||||||
|
'a second EAN13 in this field')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.constrains('second_ean13')
|
||||||
|
def _check_second_ean13(self):
|
||||||
|
for product in self:
|
||||||
|
if product.second_ean13:
|
||||||
|
if not product.ean13:
|
||||||
|
raise ValidationError(_(
|
||||||
|
"You should use the second EAN13 field only when "
|
||||||
|
"there is already a value in the main EAN13 field"))
|
||||||
|
if not check_ean(product.second_ean13):
|
||||||
|
raise ValidationError(_(
|
||||||
|
"The second EAN13 barcode is invalid."))
|
||||||
26
pos_second_ean13/product_view.xml
Normal file
26
pos_second_ean13/product_view.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2016 Akretion (http://www.akretion.com/)
|
||||||
|
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
The licence is in the file __openerp__.py
|
||||||
|
-->
|
||||||
|
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="product_normal_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">usability.product.template.form</field>
|
||||||
|
<field name="model">product.product</field>
|
||||||
|
<field name="inherit_id" ref="product.product_normal_form_view" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="ean13" position="after">
|
||||||
|
<field name="second_ean13"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
Reference in New Issue
Block a user