[WIP] point_of_sale: barcode validation wizard (wip)
bzr revid: fva@openerp.com-20120720170012-eqp81clbpbfsr3hl
This commit is contained in:
parent
7a1cee1401
commit
f1fbf44b5c
|
@ -22,6 +22,7 @@ import pdb
|
|||
import io
|
||||
import openerp
|
||||
import addons
|
||||
import openerp.addons.product.product
|
||||
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
@ -143,8 +144,6 @@ class pos_config(osv.osv):
|
|||
obj.sequence_id.unlink()
|
||||
return super(pos_config, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
pos_config()
|
||||
|
||||
class pos_session(osv.osv):
|
||||
_name = 'pos.session'
|
||||
_order = 'id desc'
|
||||
|
@ -425,8 +424,6 @@ class pos_session(osv.osv):
|
|||
'context' : context,
|
||||
}
|
||||
|
||||
pos_session()
|
||||
|
||||
class pos_order(osv.osv):
|
||||
_name = "pos.order"
|
||||
_description = "Point of Sale"
|
||||
|
@ -1038,8 +1035,6 @@ class pos_order(osv.osv):
|
|||
self.create_account_move(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
pos_order()
|
||||
|
||||
class account_bank_statement(osv.osv):
|
||||
_inherit = 'account.bank.statement'
|
||||
_columns= {
|
||||
|
@ -1138,8 +1133,6 @@ class pos_order_line(osv.osv):
|
|||
})
|
||||
return super(pos_order_line, self).copy_data(cr, uid, id, default, context=context)
|
||||
|
||||
pos_order_line()
|
||||
|
||||
class pos_category(osv.osv):
|
||||
_name = 'pos.category'
|
||||
_description = "Point of Sale Category"
|
||||
|
@ -1211,12 +1204,24 @@ class pos_category(osv.osv):
|
|||
# 'category_image': _get_default_image,
|
||||
#}
|
||||
|
||||
pos_category()
|
||||
|
||||
import io, StringIO
|
||||
|
||||
class ean_wizard(osv.osv_memory):
|
||||
_name = 'pos.ean_wizard'
|
||||
_columns = {
|
||||
'ean13_pattern': fields.char('Ean13 Pattern', size=32, 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.get(m).write(cr,uid,[m_id],{'ean13':ean13})
|
||||
|
||||
class product_product(osv.osv):
|
||||
_inherit = 'product.product'
|
||||
|
||||
|
||||
def _get_small_image(self, cr, uid, ids, prop, unknow_none, context=None):
|
||||
result = {}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -1247,7 +1252,16 @@ class product_product(osv.osv):
|
|||
'to_weight' : False,
|
||||
}
|
||||
|
||||
product_product()
|
||||
|
||||
def add_ean13(self, cr, uid, ids, context):
|
||||
return {
|
||||
'name': _('Return Products'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'pos.ean_wizard',
|
||||
'target' : 'new',
|
||||
'view_id': False,
|
||||
'context':context,
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -618,12 +618,22 @@
|
|||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="product.product_normal_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="status" position="after">
|
||||
<group name="pos" string="Point of Sale">
|
||||
<field name="pos_categ_id"/>
|
||||
<field name="to_weight" />
|
||||
</group>
|
||||
</group>
|
||||
<group name="status" position="after">
|
||||
<group name="pos" string="Point of Sale">
|
||||
<field name="pos_categ_id"/>
|
||||
<field name="to_weight" />
|
||||
</group>
|
||||
</group>
|
||||
<group name="misc" position="after">
|
||||
<group name="pos" colspan="2" col="2">
|
||||
<separator string="Point of Sale" colspan="2"/>
|
||||
<field name="income_pdt"/>
|
||||
<field name="expense_pdt"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="ean13" position="after">
|
||||
<button name="add_ean13" type="object" string="Edit">
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
@ -634,13 +644,6 @@
|
|||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="product.product_normal_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="misc" position="after">
|
||||
<group name="pos" colspan="2" col="2">
|
||||
<separator string="Point of Sale" colspan="2"/>
|
||||
<field name="income_pdt"/>
|
||||
<field name="expense_pdt"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
@ -1054,5 +1057,20 @@
|
|||
|
||||
<menuitem action="action_pos_session_opening" parent="menu_point_of_sale" id="menu_pos_session_opening" sequence="0" />
|
||||
|
||||
<record model="ir.ui.view" id="view_pos_session_form">
|
||||
<field name="name">pos.ean_wizard</field>
|
||||
<field name="model">pos.ean_wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="ASDFDASF of Sale Session" version="7.0">
|
||||
<field name="ean13_pattern"/>
|
||||
<footer>
|
||||
<button name="sanitize_ean13" type="object" string="Apply"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -63,6 +63,18 @@ def check_ean(eancode):
|
|||
return False
|
||||
return ean_checksum(eancode) == int(eancode[-1])
|
||||
|
||||
def sanitize_ean13(ean13):
|
||||
"""Creates and returns a valid ean13 from an invalid one"""
|
||||
if not ean13:
|
||||
return "0000000000000"
|
||||
ean13 = re.subs("[A-Za-z]","0",ean13);
|
||||
ean13 = re.subs("[^0-9]","",ean13);
|
||||
ean13 = ean13[:13]
|
||||
if len(ean13) < 13:
|
||||
ean13 = ean13 + '0' * (13-len(ean13))
|
||||
ean13[-1] = openerp.addons.product.product.ean_checksum(ean13)
|
||||
return ean13
|
||||
|
||||
#----------------------------------------------------------
|
||||
# UOM
|
||||
#----------------------------------------------------------
|
||||
|
@ -568,6 +580,7 @@ class product_product(osv.osv):
|
|||
res = check_ean(product['ean13'])
|
||||
return res
|
||||
|
||||
|
||||
_constraints = [(_check_ean_key, 'Error: Invalid ean code', ['ean13'])]
|
||||
|
||||
def on_order(self, cr, uid, ids, orderline, quantity):
|
||||
|
|
Loading…
Reference in New Issue