[REM] remove ean13 only barcode code
Barcode fields now allows all formats. EAN13 doesnt need to be used unless you have an official GS1 prefix.
This commit is contained in:
@@ -1356,19 +1356,6 @@ class pos_order_line(osv.osv):
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||
}
|
||||
|
||||
class ean_wizard(osv.osv_memory):
|
||||
_name = 'pos.ean_wizard'
|
||||
_columns = {
|
||||
'ean13_pattern': fields.char('Reference', size=13, required=True, translate=True),
|
||||
}
|
||||
def sanitize_ean13(self, cr, uid, ids, context):
|
||||
for r in self.browse(cr,uid,ids):
|
||||
ean13 = openerp.addons.product.product.sanitize_ean13(r.ean13_pattern)
|
||||
m = context.get('active_model')
|
||||
m_id = context.get('active_id')
|
||||
self.pool[m].write(cr,uid,[m_id],{'barcode':ean13})
|
||||
return { 'type' : 'ir.actions.act_window_close' }
|
||||
|
||||
class pos_category(osv.osv):
|
||||
_name = "pos.category"
|
||||
_description = "Public Category"
|
||||
|
||||
@@ -528,14 +528,6 @@
|
||||
<menuitem action="product_pos_category_action" id="menu_product_pos_category" parent="menu_point_config_product" sequence="20" />
|
||||
<!-- END -->
|
||||
|
||||
<record id="action_edit_ean" model="ir.actions.act_window">
|
||||
<field name="name">Edit Ean</field>
|
||||
<field name="res_model">pos.ean_wizard</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
</record>
|
||||
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">product.template.form.inherit</field>
|
||||
<field name="model">product.template</field>
|
||||
@@ -550,28 +542,6 @@
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
<record id="product_template_form_view_inherit_ean" model="ir.ui.view">
|
||||
<field name="name">product.template.only.form.inherit.ean</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="barcode" position="after">
|
||||
<button colspan="2" name="%(action_edit_ean)d" type="action" string="Set a Custom EAN"
|
||||
attrs="{'invisible': [('product_variant_count', '>', 1)]}" class="oe_link oe_edit_only"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="product_normal_form_view_inherit_ean" model="ir.ui.view">
|
||||
<field name="name">product.form.inherit.ean</field>
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="product.product_normal_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="barcode" position="after">
|
||||
<button colspan="2" name="%(action_edit_ean)d" type="action" string="Set a Custom EAN" class="oe_link oe_edit_only"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_template_tree_view" model="ir.ui.view">
|
||||
<field name="name">product.template.tree.inherit</field>
|
||||
<field name="model">product.template</field>
|
||||
@@ -977,27 +947,6 @@
|
||||
parent="menu_point_root" name="Dashboard"
|
||||
id="menu_pos_dashboard" sequence="1"/>
|
||||
|
||||
<record model="ir.ui.view" id="pos_ean13_generator">
|
||||
<field name="name">pos.ean_wizard</field>
|
||||
<field name="model">pos.ean_wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Ean13 Generator">
|
||||
<p class="oe_grey">
|
||||
Enter a reference, it will be converted
|
||||
automatically to a valid EAN number.
|
||||
</p>
|
||||
<group>
|
||||
<field name="ean13_pattern" class="oe_inline"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="sanitize_ean13" type="object" string="Apply" class="oe_highlight"/> or
|
||||
<button icon="gtk-stop" special="cancel"
|
||||
string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Barcode Nomenclatures -->
|
||||
<menuitem parent="menu_point_config_product" action="barcodes.action_barcode_nomenclature_form" id="menu_pos_barcode_nomenclature_all"
|
||||
sequence="30"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="view_partner_property_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.pos.form.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
@@ -9,11 +9,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='warehouse']" position="before">
|
||||
<group string="Point of Sale" name="point_of_sale">
|
||||
<label for="barcode"/>
|
||||
<div class="o_row">
|
||||
<field name="barcode" nolabel="1"/>
|
||||
<button name="%(action_edit_ean)d" type="action" string="Set a Custom EAN" class="oe_link"/>
|
||||
</div>
|
||||
<field name="barcode" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
<field name="pos_config" />
|
||||
<field name="barcode" />
|
||||
<field name="pos_security_pin" />
|
||||
<button name="%(action_edit_ean)d" type="action" string="Set a Custom EAN" class="oe_edit_only" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
@@ -18,38 +18,6 @@ from openerp.tools.float_utils import float_round, float_compare
|
||||
from openerp.exceptions import UserError
|
||||
from openerp.exceptions import except_orm
|
||||
|
||||
def ean_checksum(eancode):
|
||||
"""returns the checksum of an ean string of length 13, returns -1 if the string has the wrong length"""
|
||||
if len(eancode) != 13:
|
||||
return -1
|
||||
oddsum=0
|
||||
evensum=0
|
||||
total=0
|
||||
eanvalue=eancode
|
||||
reversevalue = eanvalue[::-1]
|
||||
finalean=reversevalue[1:]
|
||||
|
||||
for i in range(len(finalean)):
|
||||
if i % 2 == 0:
|
||||
oddsum += int(finalean[i])
|
||||
else:
|
||||
evensum += int(finalean[i])
|
||||
total=(oddsum * 3) + evensum
|
||||
|
||||
check = int(10 - math.ceil(total % 10.0)) %10
|
||||
return check
|
||||
|
||||
def sanitize_ean13(ean13):
|
||||
"""Creates and returns a valid ean13 from an invalid one"""
|
||||
if not ean13:
|
||||
return "0000000000000"
|
||||
ean13 = re.sub("[A-Za-z]","0",ean13);
|
||||
ean13 = re.sub("[^0-9]","",ean13);
|
||||
ean13 = ean13[:13]
|
||||
if len(ean13) < 13:
|
||||
ean13 = ean13 + '0' * (13-len(ean13))
|
||||
return ean13[:-1] + str(ean_checksum(ean13))
|
||||
|
||||
#----------------------------------------------------------
|
||||
# UOM
|
||||
#----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user