[REF] point_of_sale: Code cleaning

bzr revid: psi@tinyerp.co.in-20101026053743-kdti4mq98m1iriod
This commit is contained in:
psi (Open ERP) 2010-10-26 11:07:43 +05:30
parent 1197af2134
commit dfea5584e7
5 changed files with 278 additions and 345 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 PC Solutions (<http://pcsol.be>). All Rights Reserved
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
@ -16,21 +16,19 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import osv
from osv import fields
from osv import fields, osv
class account_journal(osv.osv):
_inherit = 'account.journal'
_columns = {
'auto_cash': fields.boolean('Automatic Opening', help="This field authorize the automatic creation of the cashbox"),
'special_journal': fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
'check_dtls': fields.boolean('Check Details', help="This field authorize Validation of Cashbox without checking ending details"),
'journal_users': fields.many2many('res.users','pos_journal_users','journal_id','user_id','Users'),
'journal_users': fields.many2many('res.users', 'pos_journal_users', 'journal_id', 'user_id', 'Users'),
}
_defaults = {
'check_dtls': False,
@ -39,7 +37,7 @@ class account_journal(osv.osv):
account_journal()
class account_cash_statement(osv.osv):
_inherit = 'account.bank.statement'
def _equal_balance(self, cr, uid, cash_id, context=None):
@ -48,12 +46,11 @@ class account_cash_statement(osv.osv):
statement = self.browse(cr, uid, cash_id, context=context)
if not statement.journal_id.check_dtls:
return True
if statement.journal_id.check_dtls and (statement.balance_end != statement.balance_end_cash):
return False
else:
return True
return True
def _user_allow(self, cr, uid, statement_id, context=None):
if context is None:
context = {}
@ -62,12 +59,10 @@ class account_cash_statement(osv.osv):
statement = self.browse(cr, uid, statement_id, context=context)
for user in statement.journal_id.journal_users:
uids.append(user.id)
if uid in uids:
res = True
return res
def _get_cash_open_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
@ -81,7 +76,7 @@ class account_cash_statement(osv.osv):
res.append(dct)
res.sort()
return res
def _get_default_cash_close_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
@ -95,7 +90,7 @@ class account_cash_statement(osv.osv):
res.append(dct)
res.sort()
return res
account_cash_statement()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

File diff suppressed because it is too large Load Diff

View File

@ -19,38 +19,32 @@
#
##############################################################################
import netsvc
from osv import osv,fields
from tools.translate import _
import time
import netsvc
from osv import osv, fields
from tools.translate import _
class all_closed_cashbox_of_the_day(osv.osv_memory):
_name = 'all.closed.cashbox.of.the.day'
_description = 'All closed cashbox of the day'
_columns = {
}
def print_report(self, cr, uid, ids, context=None):
"""
To get the date and print the report
@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 report
"""
datas = {'ids' : context.get('active_ids',[])}
datas = {'ids': context.get('active_ids', [])}
res = {}
datas['form'] = res
return {
'type' : 'ir.actions.report.xml',
'report_name':'all.closed.cashbox.of.the.day',
'datas' : datas,
'type': 'ir.actions.report.xml',
'report_name': 'all.closed.cashbox.of.the.day',
'datas': datas,
}
all_closed_cashbox_of_the_day()

View File

@ -32,10 +32,10 @@ class add_product(osv.osv_memory):
'quantity': fields.float('Quantity', required=True),
}
_defaults = {
'quantity': lambda *a: 1,
'quantity': 1,
}
def select_product(self, cr, uid, ids, context):
def select_product(self, cr, uid, ids, context=None):
"""
To get the product and quantity and add in order .
@param self: The object pointer.
@ -44,13 +44,14 @@ class add_product(osv.osv_memory):
@param context: A standard dictionary
@return : Return the add product form again for adding more product
"""
if context is None:
context = {}
this = self.browse(cr, uid, ids[0], context=context)
record_id = context and context.get('active_id', False)
assert record_id, _('Active ID is not found')
if record_id:
order_obj = self.pool.get('pos.order')
order_obj.add_product(cr, uid, record_id, this.product_id.id, this.quantity, context=context)
return {
'name': _('Add Product'),
'view_type': 'form',
@ -61,34 +62,36 @@ class add_product(osv.osv_memory):
'views': False,
'type': 'ir.actions.act_window',
}
def close_action(self, cr, uid, ids, context):
def close_action(self, cr, uid, ids, context=None):
"""
To get the product and Make the payment .
@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 : Return the Make Payment
@return : Return the Make Payment
"""
if context is None:
context = {}
record_id = context and context.get('active_id', False)
order_obj= self.pool.get('pos.order')
obj=order_obj.browse(cr, uid, record_id)
order_obj.write(cr, uid, [record_id], {'state':'done'})
obj = order_obj.browse(cr, uid, record_id, context=context)
order_obj.write(cr, uid, [record_id], {'state': 'done'}, context=context)
if obj.amount_total != obj.amount_paid:
return {
'name': _('Make Payment'),
'context ':context and context.get('active_id', False),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'pos.make.payment',
'view_id': False,
'target': 'new',
'views': False,
'type': 'ir.actions.act_window',
'name': _('Make Payment'),
'context': context and context.get('active_id', False),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'pos.make.payment',
'view_id': False,
'target': 'new',
'views': False,
'type': 'ir.actions.act_window',
}
return {}
return {}
add_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,30 +19,31 @@
#
##############################################################################
from osv import osv, fields
import time
from osv import osv, fields
from tools.translate import _
def get_journal(self, cr, uid, context):
def get_journal(self, cr, uid, context=None):
"""
Make the selection list of Cash Journal .
@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 :Return the list of journal
Make the selection list of Cash Journal .
@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 :Return the list of journal
"""
obj = self.pool.get('account.journal')
journal_obj = self.pool.get('account.journal')
statement_obj = self.pool.get('account.bank.statement')
cr.execute("SELECT DISTINCT journal_id from pos_journal_users where user_id=%s order by journal_id", (uid,))
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users WHERE user_id = %s ORDER BY journal_id", (uid, ))
j_ids = map(lambda x1: x1[0], cr.fetchall())
ids = obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
obj_ids= statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)])
res_obj = obj.read(cr, uid, ids, ['journal_id'], context)
res_obj = [(r1['id'])for r1 in res_obj]
res = statement_obj.read(cr, uid, obj_ids, ['journal_id'], context)
ids = journal_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
obj_ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)], context=context)
res_obj = journal_obj.read(cr, uid, ids, ['journal_id'], context=context)
res_obj = [(r1['id']) for r1 in res_obj]
res = statement_obj.read(cr, uid, obj_ids, ['journal_id'], context=context)
res = [(r['journal_id']) for r in res]
res.insert(0, ('', ''))
return res
@ -51,10 +52,7 @@ class pos_box_entries(osv.osv_memory):
_name = 'pos.box.entries'
_description = 'Pos Box Entries'
def _get_income_product(self, cr, uid, context):
"""
Make the selection list of purchasing products.
@param self: The object pointer.