[IMP] point_of_sale: convert the scan_product wizard into osv_memory and remove wizard_default_journal
bzr revid: sbh@tinyerp.com-20100329133808-hrslymp4ki3fccff
This commit is contained in:
parent
bee4052cb0
commit
dc0f22435e
|
@ -62,6 +62,7 @@ Main features :
|
|||
'wizard/pos_payment_report_user.xml',
|
||||
'wizard/pos_payment_report.xml',
|
||||
'wizard/pos_payment.xml',
|
||||
'wizard/pos_scan_product_view.xml',
|
||||
'pos_report.xml',
|
||||
'pos_wizard.xml',
|
||||
'pos_view.xml',
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
<button name="%(pos_add_product)d" string="_Add product" type="action" states="draft"/>
|
||||
-->
|
||||
|
||||
<button name="%(action_pos_payment)d" string="Ma_ke Payment" icon="gtk-ok" type="action" states="draft,advance" context="{'record_id':'active_id'}" />
|
||||
<button name="%(action_pos_scan_product)d" string="Ma_ke Payment" icon="gtk-ok" type="action" states="draft,advance" context="{'record_id':'active_id'}" />
|
||||
<button name="%(action_report_pos_receipt)d" string="_Reprint" icon="gtk-print" type="action" states="paid,done,invoiced"/>
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
##############################################################################
|
||||
|
||||
#import wizard_pos_payment
|
||||
import wizard_default_journal
|
||||
|
||||
import wizard_scan_product
|
||||
|
||||
import wizard_return
|
||||
|
@ -50,6 +50,7 @@ import pos_payment_report_user
|
|||
import pos_payment_report_date
|
||||
import pos_payment_report
|
||||
import pos_payment
|
||||
import pos_scan_product
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import netsvc
|
||||
from osv import osv,fields
|
||||
from tools.translate import _
|
||||
from mx import DateTime
|
||||
import time
|
||||
|
||||
|
||||
|
||||
class pos_scan_product(osv.osv_memory):
|
||||
_name = 'pos.scan.product'
|
||||
_description = 'Scan product'
|
||||
_columns = {
|
||||
'gencod': fields.char('Barcode',size=13,required= True)
|
||||
}
|
||||
def scan(self, cr, uid, ids, context):
|
||||
"""
|
||||
To get the gencod and scan product
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param context: A standard dictionary
|
||||
@return : retrun gencod
|
||||
"""
|
||||
|
||||
data=self.read(cr, uid, ids)[0]
|
||||
record_id = context and context.get('active_id',False)
|
||||
result =self. pool.get('pos.order.line')._scan_product(cr, uid, data['gencod'], 1, record_id)
|
||||
return {'gencod': False}
|
||||
|
||||
|
||||
|
||||
pos_scan_product()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_pos_scan_product" model="ir.ui.view">
|
||||
<field name="name">Scan product</field>
|
||||
<field name="model">pos.scan.product</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Scan product">
|
||||
<group col="2" colspan="4">
|
||||
<label string="Scan Barcode" colspan="4"/>
|
||||
<field name="gencod" colspan="4" nolabel="1"/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Close" />
|
||||
<button name="scan" string="Add"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_pos_scan_product" model="ir.actions.act_window">
|
||||
<field name="name">Scan product</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">pos.scan.product</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,128 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# 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 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
|
||||
def _get_default_journal_selection(self, cr, uid, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
obj = pool.get('account.journal')
|
||||
ids = obj.search(cr, uid, [('type', '=', 'cash')])
|
||||
res = obj.read(cr, uid, ids, ['id', 'name'], context)
|
||||
res = [(r['id'], r['name']) for r in res]
|
||||
res.insert(0, ('', ''))
|
||||
return res
|
||||
|
||||
default_journal_form = '''<?xml version="1.0"?>
|
||||
<form string="Select default journals">
|
||||
<field name="default_journal" />
|
||||
<newline />
|
||||
<field name="default_journal_rebate" />
|
||||
<newline />
|
||||
<field name="default_journal_gift" />
|
||||
<newline />
|
||||
</form>'''
|
||||
|
||||
default_journal_fields = {
|
||||
'default_journal': {'string': 'Default journal', 'type': 'selection',
|
||||
'selection': _get_default_journal_selection,
|
||||
},
|
||||
'default_journal_rebate': {'string': 'Default rebate journal', 'type': 'selection',
|
||||
'selection': _get_default_journal_selection,
|
||||
},
|
||||
'default_journal_gift': {'string': 'Default gift journal', 'type': 'selection',
|
||||
'selection': _get_default_journal_selection,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class wizard_default_journal(wizard.interface):
|
||||
|
||||
def _set_default_journal(self, cr, uid, data, context):
|
||||
|
||||
def _update_default_journal_config(journal_type, journal_code, journal_descr, journal_codes, data):
|
||||
default_journal_id = data.get('form', {}).get(journal_type) or None
|
||||
dico = dict(name=journal_descr, code=journal_code, journal_id=default_journal_id)
|
||||
if default_journal_id:
|
||||
if journal_code in journal_codes:
|
||||
ids = [obj.id for obj in objs if obj.code == journal_code]
|
||||
pos_config_journal.write(cr, uid, ids, dico, context)
|
||||
else:
|
||||
pos_config_journal.create(cr, uid, dico, context)
|
||||
else:
|
||||
ids = [obj.id for obj in objs if obj.code == journal_code]
|
||||
pos_config_journal.write(cr, uid, ids, dico, context)
|
||||
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
pos_config_journal = pool.get('pos.config.journal')
|
||||
ids = pos_config_journal.search(cr, uid, [])
|
||||
objs = pos_config_journal.browse(cr, uid, ids)
|
||||
journal_codes = [str(obj.code) for obj in objs]
|
||||
|
||||
_update_default_journal_config('default_journal', 'DEFAULT', 'Default journal', journal_codes, data)
|
||||
_update_default_journal_config('default_journal_rebate', 'REBATE', 'Default rebate journal', journal_codes, data)
|
||||
_update_default_journal_config('default_journal_gift', 'GIFT', 'Default gift journal', journal_codes, data)
|
||||
|
||||
return {}
|
||||
|
||||
def _get_defaults(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
pos_config_journal = pool.get('pos.config.journal')
|
||||
ids = pos_config_journal.search(cr, uid, [])
|
||||
objs = pos_config_journal.browse(cr, uid, ids)
|
||||
journal_codes = {}
|
||||
for obj in objs:
|
||||
journal_codes[obj.code] = int(obj.journal_id.id)
|
||||
|
||||
form = data['form']
|
||||
form['default_journal'] = journal_codes.get('DEFAULT') or False
|
||||
form['default_journal_rebate'] = journal_codes.get('REBATE') or False
|
||||
form['default_journal_gift'] = journal_codes.get('GIFT') or False
|
||||
|
||||
return form
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_get_defaults],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': default_journal_form,
|
||||
'fields': default_journal_fields,
|
||||
'state': [
|
||||
('end', 'Cancel'),
|
||||
('set_default_journal', 'Define default journals')
|
||||
]
|
||||
}
|
||||
},
|
||||
'set_default_journal': {
|
||||
'actions': [_set_default_journal],
|
||||
'result': {
|
||||
'type': 'state',
|
||||
'state': "end",
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
wizard_default_journal('pos.config.journal')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,71 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# Copyright (c) 2008 Sylëam Info Services. (http://www.syleam.fr) All Rights Reserved.
|
||||
#
|
||||
# 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 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import pooler
|
||||
import wizard
|
||||
from osv import osv
|
||||
|
||||
form_gencod = """<?xml version="1.0"?>
|
||||
<form string="Scan product">
|
||||
<label string="Scan Barcode" colspan="4"/>
|
||||
<field name="gencod" colspan="4" nolabel="1"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
fields_gencod = {
|
||||
'gencod': {'string': 'Barcode',
|
||||
'type': 'char',
|
||||
'size': 13,
|
||||
'required': True}
|
||||
}
|
||||
|
||||
|
||||
def _scan(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
result = pool.get('pos.order.line')._scan_product(cr, uid, data['form']['gencod'], 1, data['id'])
|
||||
return {'gencod': False}
|
||||
|
||||
def _pre_init(self, cr, uid, data, context):
|
||||
return {'gencod': False}
|
||||
|
||||
class pos_scan_product(wizard.interface):
|
||||
states = {
|
||||
'init' : {'actions' : [_pre_init],
|
||||
'result' : {
|
||||
'type': 'form',
|
||||
'arch': form_gencod,
|
||||
'fields': fields_gencod,
|
||||
'state': [('end','Cancel','gtk-cancel'),
|
||||
('add', 'Add', 'gtk-ok', True)],
|
||||
}
|
||||
},
|
||||
'add' : {'actions' : [_scan],
|
||||
'result' : {
|
||||
'type': 'state',
|
||||
'state': 'init',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pos_scan_product('pos.scan_product')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -1,69 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# 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 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields
|
||||
from osv import osv
|
||||
import time
|
||||
import ir
|
||||
from mx import DateTime
|
||||
import datetime
|
||||
import pooler
|
||||
from tools import config
|
||||
import wizard
|
||||
import netsvc
|
||||
|
||||
|
||||
sale_forecast_res_form= """<?xml version="1.0"?>
|
||||
<form string="Sale by User">
|
||||
<field name="date_start" />
|
||||
<field name="date_end" />
|
||||
<field name="user_id" />
|
||||
|
||||
</form>
|
||||
"""
|
||||
|
||||
sale_forecast_res_field= {
|
||||
'date_start': {'string':'Start Date','type':'date','required': True,'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
'date_end': {'string':'End Date','type':'date','required': True,'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
'user_id': {'string': 'Salesman', 'type': 'many2many', 'relation': 'res.users', 'required': True},
|
||||
|
||||
}
|
||||
|
||||
|
||||
class wizard_pos_sales_user(wizard.interface):
|
||||
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [],
|
||||
'result' : {'type' : 'form',
|
||||
'arch' : sale_forecast_res_form,
|
||||
'fields' : sale_forecast_res_field,
|
||||
'state' : [('end', 'Cancel','gtk-cancel'),('print_report', 'Print Report','gtk-print') ]}
|
||||
},
|
||||
'print_report' : {
|
||||
'actions' : [],
|
||||
'result' : {'type' : 'print',
|
||||
'report':'pos.sales.user',
|
||||
'state' : 'end'}
|
||||
},
|
||||
}
|
||||
wizard_pos_sales_user('pos.sales.user')
|
Loading…
Reference in New Issue