From 369e7ccc52971c35d0109c7b7f468cf98a006062 Mon Sep 17 00:00:00 2001 From: "olt@tinyerp.com" <> Date: Mon, 29 Mar 2010 14:38:53 +0200 Subject: [PATCH] [FIX] pep8 bzr revid: olt@tinyerp.com-20100329123853-60zh0xb9p1vt4h0u --- addons/point_of_sale/wizard/pos_add_product.py | 57 +++--- addons/point_of_sale/wizard/pos_box_entries.py | 116 ++++++------ addons/point_of_sale/wizard/pos_box_out.py | 124 +++++++------ addons/point_of_sale/wizard/pos_close_statement.py | 38 ++-- addons/point_of_sale/wizard/pos_confirm.py | 35 ++-- addons/point_of_sale/wizard/pos_details.py | 46 ++--- addons/point_of_sale/wizard/pos_discount.py | 56 +++--- addons/point_of_sale/wizard/pos_get_sale.py | 49 +++--- addons/point_of_sale/wizard/pos_open_statement.py | 73 ++++---- addons/point_of_sale/wizard/pos_payment.py | 186 ++++++++++---------- addons/point_of_sale/wizard/pos_payment_report.py | 50 ++---- .../wizard/pos_payment_report_date.py | 67 +++---- .../wizard/pos_payment_report_user.py | 61 ++++--- addons/point_of_sale/wizard/pos_receipt.py | 41 ++--- 14 files changed, 494 insertions(+), 505 deletions(-) diff --git a/addons/point_of_sale/wizard/pos_add_product.py b/addons/point_of_sale/wizard/pos_add_product.py index f02d8bd..34769be 100644 --- a/addons/point_of_sale/wizard/pos_add_product.py +++ b/addons/point_of_sale/wizard/pos_add_product.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,52 +15,53 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv, fields from tools.translate import _ + class add_product(osv.osv_memory): _name = 'pos.add.product' _description = 'Add Product' _columns = { - 'product_id': fields.many2one('product.product', 'Product',required=True), - 'quantity': fields.float('Quantity ', required=True), + 'product_id': fields.many2one('product.product', 'Product', required=True), + 'quantity': fields.float('Quantity ', required=True), } _defaults = { - 'quantity': lambda *a: 1, - } - + 'quantity': lambda *a: 1, + } + def select_product(self, cr, uid, ids, context): - """ - To get the product and quantity and add in order . + """ + To get the product and quantity and add in order . @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 the add product form again for adding more product - """ + @param context: A standard dictionary + @return : Return the add product form again for adding more product + """ this = self.browse(cr, uid, ids[0], context=context) - record_id = context and context.get('active_id',False) + 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', - 'view_mode': 'form', - 'res_model': 'pos.add.product', - 'view_id': False, - 'target':'new', - 'views': False, - 'type': 'ir.actions.act_window', - } + 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', + 'view_mode': 'form', + 'res_model': 'pos.add.product', + 'view_id': False, + 'target': 'new', + 'views': False, + 'type': 'ir.actions.act_window', + } + add_product() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/wizard/pos_box_entries.py b/addons/point_of_sale/wizard/pos_box_entries.py index fd7b3a5..fe57e66 100644 --- a/addons/point_of_sale/wizard/pos_box_entries.py +++ b/addons/point_of_sale/wizard/pos_box_entries.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,28 +15,25 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields -from tools.translate import _ -from tools.misc import UpdateableStr -from mx import DateTime -from tools.translate import _ +from osv import osv, fields import time +from tools.translate import _ + -def get_journal(self,cr,uid,context): - """ - Make the selection list of Cash Journal . +def get_journal(self, cr, uid, context): + """ + 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 - """ - + @param context: A standard dictionary + @return :Return the list of journal + """ + obj = self.pool.get('account.journal') user = self.pool.get('res.users').browse(cr, uid, uid) ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', user.company_id.id)]) @@ -45,90 +42,91 @@ def get_journal(self,cr,uid,context): res.insert(0, ('', '')) return res + 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. + + def _get_income_product(self, cr, uid, context): + + """ + Make the selection list of purchasing products. @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 of operation of product - """ + @param context: A standard dictionary + @return :Return of operation of product + """ obj = self.pool.get('product.product') ids = obj.search(cr, uid, [('income_pdt', '=', True)]) res = obj.read(cr, uid, ids, ['id', 'name'], context) res = [(r['id'], r['name']) for r in res] res.insert(0, ('', '')) - + return res - - + + _columns = { - 'name': fields.char('Name', size=32,required=True), - 'journal_id': fields.selection(get_journal, "Journal",required=True), - 'product_id': fields.selection(_get_income_product, "Operation",required=True), - 'amount' :fields.float('Amount', digits=(16,2)), - 'ref':fields.char('Ref', size=32), + 'name': fields.char('Name', size=32, required=True), + 'journal_id': fields.selection(get_journal, "Journal", required=True), + 'product_id': fields.selection(_get_income_product, "Operation", required=True), + 'amount': fields.float('Amount', digits=(16, 2)), + 'ref': fields.char('Ref', size=32), } _defaults = { 'journal_id': lambda *a: 1, 'product_id': lambda *a: 1, } - def get_in(self, cr, uid, ids, context): - - """ - Create the entry of statement in journal . + def get_in(self, cr, uid, ids, context): + """ + Create the entry of statement in 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 of operation of product - """ + @param context: A standard dictionary + @return :Return of operation of product + """ statement_obj = self.pool.get('account.bank.statement') product_obj = self.pool.get('product.template') res_obj = self.pool.get('res.users') - product_obj=self.pool.get('product.product') - bank_statement=self.pool.get('account.bank.statement.line') + product_obj = self.pool.get('product.product') + bank_statement = self.pool.get('account.bank.statement.line') for data in self.read(cr, uid, ids): args = {} - curr_company = res_obj.browse(cr,uid,uid).company_id.id - statement_id = statement_obj.search(cr,uid, [('journal_id','=',data['journal_id']),('company_id','=',curr_company),('user_id','=',uid),('state','=','open')]) + curr_company = res_obj.browse(cr, uid, uid).company_id.id + statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')]) if not statement_id: raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox')) - - product = product_obj.browse(cr, uid, data['product_id']) - acc_id = product_obj.browse(cr,uid,data['product_id']).property_account_income + + acc_id = product_obj.browse(cr, uid, data['product_id']).property_account_income if not acc_id: - raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr,uid,data['product_id']).name)) + raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr, uid, data['product_id']).name)) if statement_id: statement_id = statement_id[0] if not statement_id: - statement_id = statement_obj.create(cr,uid,{'date':time.strftime('%Y-%m-%d 00:00:00'), - 'journal_id':data['journal_id'], - 'company_id':curr_company, - 'user_id':uid, + statement_id = statement_obj.create(cr, uid, {'date': time.strftime('%Y-%m-%d 00:00:00'), + 'journal_id': data['journal_id'], + 'company_id': curr_company, + 'user_id': uid, }) - + args['statement_id'] = statement_id - args['journal_id'] = data['journal_id'] + args['journal_id'] = data['journal_id'] if acc_id: - args['account_id'] = acc_id.id + args['account_id'] = acc_id.id args['amount'] = data['amount'] or 0.0 - args['ref'] = "%s" %(data['ref'] or '') - args['name'] = "%s: %s "% (product_obj.browse(cr,uid,data['product_id']).name, data['name'].decode('utf8')) - address_u = res_obj.browse(cr,uid,uid).address_id + args['ref'] = "%s" % (data['ref'] or '') + args['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id']).name, data['name'].decode('utf8')) + address_u = res_obj.browse(cr, uid, uid).address_id if address_u: partner_id = address_u.partner_id and address_u.partner_id.id or None args['partner_id'] = partner_id - statement_line_id =bank_statement.create(cr, uid, args) - + statement_line_id = bank_statement.create(cr, uid, args) + return {} -pos_box_entries() + +pos_box_entries() + diff --git a/addons/point_of_sale/wizard/pos_box_out.py b/addons/point_of_sale/wizard/pos_box_out.py index 52d2be0..ea5768e 100644 --- a/addons/point_of_sale/wizard/pos_box_out.py +++ b/addons/point_of_sale/wizard/pos_box_out.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,118 +15,116 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv, fields +import time from tools.translate import _ -from tools.misc import UpdateableStr from mx import DateTime -from tools.translate import _ import pos_box_entries -print dir(pos_box_entries) + class pos_box_out(osv.osv_memory): _name = 'pos.box.out' _description = 'Pos Box Out' - - def _get_expense_product(self,cr,uid,context): - - """ - Make the selection list of expense product. + + def _get_expense_product(self, cr, uid, context): + + """ + Make the selection list of expense 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 :Return of operation of product - """ + @param context: A standard dictionary + @return :Return of operation of product + """ obj = self.pool.get('product.product') company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id ids = obj.search(cr, uid, ['&', ('expense_pdt', '=', True), '|', ('company_id', '=', company_id), ('company_id', '=', None)]) res = obj.read(cr, uid, ids, ['id', 'name'], context) res = [(r['id'], r['name']) for r in res] res.insert(0, ('', '')) - return res - + return res + _columns = { - 'name': fields.char('Name', size=32,required=True), - 'journal_id': fields.selection(pos_box_entries.get_journal, "Journal",required=True), - 'product_id': fields.selection(_get_expense_product, "Operation",required=True), - 'amount' :fields.float('Amount', digits=(16,2)), - 'ref':fields.char('Ref', size=32), + 'name': fields.char('Name', size=32, required=True), + 'journal_id': fields.selection(pos_box_entries.get_journal, "Journal", required=True), + 'product_id': fields.selection(_get_expense_product, "Operation", required=True), + 'amount': fields.float('Amount', digits=(16, 2)), + 'ref': fields.char('Ref', size=32), } _defaults = { 'journal_id': lambda *a: 1, 'product_id': lambda *a: 1, } def get_out(self, cr, uid, ids, context): - - """ - Create the entries in the CashBox . + + """ + Create the entries in the CashBox . @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 of operation of product - """ + @param context: A standard dictionary + @return :Return of operation of product + """ args = {} - statement_obj= self.pool.get('account.bank.statement') - statement_line_obj=self.pool.get('account.bank.statement.line') - product_obj= self.pool.get('product.template') - productp_obj= self.pool.get('product.product') + statement_obj = self.pool.get('account.bank.statement') + statement_line_obj = self.pool.get('account.bank.statement.line') + product_obj = self.pool.get('product.template') + productp_obj = self.pool.get('product.product') res_obj = self.pool.get('res.users') for data in self.read(cr, uid, ids): - - curr_company = res_obj.browse(cr,uid,uid).company_id.id - statement_id = statement_obj.search(cr,uid, [('journal_id','=',data['journal_id']),('company_id','=',curr_company),('user_id','=',uid),('state','=','open')]) - monday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday,0))).strftime('%Y-%m-%d') - sunday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday,0))).strftime('%Y-%m-%d') - done_statmt = statement_obj.search(cr,uid, [('date','>=',monday+' 00:00:00'),('date','<=',sunday+' 23:59:59'),('journal_id','=',data['journal_id']),('company_id','=',curr_company),('user_id','=',uid)]) - stat_done = statement_obj.browse(cr,uid, done_statmt) - address_u = res_obj.browse(cr,uid,uid).address_id + curr_company = res_obj.browse(cr, uid, uid).company_id.id + statement_id = statement_obj.search(cr, uid, [('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')]) + monday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Monday, 0))).strftime('%Y-%m-%d') + sunday = (DateTime.now() + DateTime.RelativeDateTime(weekday=(DateTime.Sunday, 0))).strftime('%Y-%m-%d') + done_statmt = statement_obj.search(cr, uid, [('date', '>=', monday+' 00:00:00'), ('date', '<=', sunday+' 23:59:59'), ('journal_id', '=', data['journal_id']), ('company_id', '=', curr_company), ('user_id', '=', uid)]) + stat_done = statement_obj.browse(cr, uid, done_statmt) + address_u = res_obj.browse(cr, uid, uid).address_id am = 0.0 - - amount_check = productp_obj.browse(cr,uid,data['product_id']).am_out or False + + amount_check = productp_obj.browse(cr, uid, data['product_id']).am_out or False for st in stat_done: for s in st.line_ids: - if address_u and s.partner_id==address_u.partner_id and s.am_out: - am+=s.amount - if (-data['amount'] or 0.0)+ am <-(res_obj.browse(cr,uid,uid).company_id.max_diff or 0.0) and amount_check: - val = (res_obj.browse(cr,uid,uid).company_id.max_diff or 0.0)+ am + if address_u and s.partner_id == address_u.partner_id and s.am_out: + am += s.amount + if (-data['amount'] or 0.0) + am < -(res_obj.browse(cr, uid, uid).company_id.max_diff or 0.0) and amount_check: + val = (res_obj.browse(cr, uid, uid).company_id.max_diff or 0.0) + am raise osv.except_osv(_('Error !'), _('The maximum value you can still withdraw is exceeded. \n Remaining value is equal to %d ')%(val)) - - acc_id = product_obj.browse(cr,uid,data['product_id']).property_account_income + + acc_id = product_obj.browse(cr, uid, data['product_id']).property_account_income if not acc_id: - raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr,uid,data['product_id']).name)) + raise osv.except_osv(_('Error !'), _('please check that account is set to %s')%(product_obj.browse(cr, uid, data['product_id']).name)) if not statement_id: - raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox')) + raise osv.except_osv(_('Error !'), _('You have to open at least one cashbox')) if statement_id: statement_id = statement_id[0] if not statement_id: - statement_id = statement_obj.create(cr,uid,{'date':time.strftime('%Y-%m-%d 00:00:00'), - 'journal_id':data['journal_id'], - 'company_id':curr_company, - 'user_id':uid, + statement_id = statement_obj.create(cr, uid, {'date': time.strftime('%Y-%m-%d 00:00:00'), + 'journal_id': data['journal_id'], + 'company_id': curr_company, + 'user_id': uid, }) - args['statement_id']= statement_id - args['journal_id']= data['journal_id'] + args['statement_id'] = statement_id + args['journal_id'] = data['journal_id'] if acc_id: - args['account_id']= acc_id.id - amount= data['amount'] or 0.0 + args['account_id'] = acc_id.id + amount = data['amount'] or 0.0 if data['amount'] > 0: - amount= -data['amount'] + amount = -data['amount'] args['amount'] = amount - if productp_obj.browse(cr,uid,data['product_id']).am_out: + if productp_obj.browse(cr, uid, data['product_id']).am_out: args['am_out'] = True args['ref'] = data['ref'] or '' - args['name'] = "%s: %s "%(product_obj.browse(cr,uid,data['product_id']).name, data['name'].decode('utf8')) - address_u = res_obj.browse(cr,uid,uid).address_id + args['name'] = "%s: %s " % (product_obj.browse(cr, uid, data['product_id']).name, data['name'].decode('utf8')) + address_u = res_obj.browse(cr, uid, uid).address_id if address_u: partner_id = address_u.partner_id and address_u.partner_id.id or None args['partner_id'] = partner_id statement_line_id = statement_line_obj.create(cr, uid, args) return {} -pos_box_out() \ No newline at end of file +pos_box_out() + diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py index 4a1d305..7f23236 100644 --- a/addons/point_of_sale/wizard/pos_close_statement.py +++ b/addons/point_of_sale/wizard/pos_close_statement.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,38 +15,38 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv from tools.translate import _ -import time + class pos_close_statement(osv.osv_memory): _name = 'pos.close.statement' _description = 'Close Statements' - def close_statement(self, cr, uid, ids, context): - """ - Close the statements + """ + Close the statements @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 : Blank Dictionary - """ - company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.id + @param context: A standard dictionary + @return : Blank Dictionary + """ + company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id statement_obj = self.pool.get('account.bank.statement') - singer_obj = self.pool.get('singer.statement') - journal_obj=self.pool.get('account.journal') - journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True),('check_dtls','=',False)]) - journal_ids=journal_obj.browse(cr,uid, journal_lst) + journal_obj = self.pool.get('account.journal') + journal_lst = journal_obj.search(cr, uid, [('company_id', '=', company_id), ('auto_cash', '=', True), ('check_dtls', '=', False)]) + journal_ids = journal_obj.browse(cr, uid, journal_lst) for journal in journal_ids: - ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)]) - statement_obj.button_confirm(cr,uid,ids) + ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)]) + statement_obj.button_confirm(cr, uid, ids) return {} + pos_close_statement() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/point_of_sale/wizard/pos_confirm.py b/addons/point_of_sale/wizard/pos_confirm.py index f2765a5..de293ea 100644 --- a/addons/point_of_sale/wizard/pos_confirm.py +++ b/addons/point_of_sale/wizard/pos_confirm.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,46 +15,47 @@ # 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 . +# along with this program. If not, see . # ############################################################################## import netsvc -from osv import osv,fields +from osv import osv from tools.translate import _ + class pos_confirm(osv.osv_memory): _name = 'pos.confirm' _description = 'Point of Sale Confirm' + def action_confirm(self, cr, uid, ids, context): - """ - Confirm the order and close the sales . + """ + Confirm the order and close the sales. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param context: A standard dictionary + @param context: A standard dictionary @return :Blank dictionary - """ - - this = self.browse(cr, uid, ids[0], context=context) - record_id = context and context.get('active_id',False) + """ + + record_id = context and context.get('active_id', False) if record_id: if isinstance(record_id, (int, long)): - record_id=[record_id] + record_id = [record_id] if record_id: - company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id order_obj = self.pool.get('pos.order') - + for order_id in order_obj.browse(cr, uid, record_id, context=context): - if order_id.state =='paid': - order_obj.write(cr,uid,[order_id.id],{'journal_entry':True}) + if order_id.state == 'paid': + order_obj.write(cr, uid, [order_id.id], {'journal_entry': True}) order_obj.create_account_move(cr, uid, [order_id.id], context=context) - + wf_service = netsvc.LocalService("workflow") for i in record_id: wf_service.trg_validate(uid, 'pos.order', i, 'done', cr) return {} - + pos_confirm() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/wizard/pos_details.py b/addons/point_of_sale/wizard/pos_details.py index d51b30b..22d29b4 100644 --- a/addons/point_of_sale/wizard/pos_details.py +++ b/addons/point_of_sale/wizard/pos_details.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,48 +15,50 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv, fields from tools.translate import _ -from mx import DateTime import time + class pos_details(osv.osv_memory): _name = 'pos.details' _description = 'Sales Details' _columns = { - 'date_start': fields.date('Date Start',required=True), - 'date_end': fields.date('Date End',required=True) + 'date_start': fields.date('Date Start', required=True), + 'date_end': fields.date('Date End', required=True) } _defaults = { - 'date_start': lambda *a: time.strftime('%Y-%m-%d'), - 'date_end': lambda *a: time.strftime('%Y-%m-%d'), - } + 'date_start': lambda *a: time.strftime('%Y-%m-%d'), + 'date_end': lambda *a: time.strftime('%Y-%m-%d'), + } + def print_report(self, cr, uid, ids, context={}): - """ - To get the date and print the report + """ + 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 + @param context: A standard dictionary @return : retrun report """ - - datas = {'ids' : context.get('active_ids', [])} - res = self.read(cr, uid, ids, ['date_start','date_end'], context) - res = res and res[0] or {} + + datas = {'ids': context.get('active_ids', [])} + res = self.read(cr, uid, ids, ['date_start', 'date_end'], context) + res = res and res[0] or {} datas['form'] = res - - return { - 'type':'ir.actions.report.xml', - 'report_name':'pos.details', - 'datas':datas, + + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'pos.details', + 'datas': datas, } + pos_details() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/wizard/pos_discount.py b/addons/point_of_sale/wizard/pos_discount.py index 8c9f9ac..f85a9d2 100644 --- a/addons/point_of_sale/wizard/pos_discount.py +++ b/addons/point_of_sale/wizard/pos_discount.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,60 +15,60 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv, fields from tools.translate import _ + class pos_discount(osv.osv_memory): _name = 'pos.discount' _description = 'Add Discount' _columns = { 'discount': fields.float('Discount ', required=True), - 'discount_notes': fields.char('Discount Notes',size= 128, required=True), + 'discount_notes': fields.char('Discount Notes', size= 128, required=True), } _defaults = { 'discount': lambda *a: 5, } - + def apply_discount(self, cr, uid, ids, context): - """ + """ To give the discount of product and check the. - + @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param context: A standard dictionary + @param context: A standard dictionary @return : nothing - """ + """ this = self.browse(cr, uid, ids[0], context=context) record_id = context and context.get('active_id', False) if isinstance(record_id, (int, long)): - record_id=[record_id] - + record_id = [record_id] + order_ref = self.pool.get('pos.order') - order_line_ref =self.pool.get('pos.order.line') - + order_line_ref = self.pool.get('pos.order.line') + for order in order_ref.browse(cr, uid, record_id, context=context): - - for line in order.lines : + + for line in order.lines: company_discount = order.company_id.company_discount applied_discount = this.discount - + if applied_discount == 0.00: notice = 'No Discount' - elif company_discount >= applied_discount: + elif company_discount >= applied_discount: notice = 'Minimum Discount' else: notice = this.discount_notes - + res_new = { } - + if this.discount <= company_discount: res_new = { 'discount': this.discount, @@ -79,26 +79,26 @@ class pos_discount(osv.osv_memory): res_new = { 'discount': this.discount, 'notice': notice, - 'price_ded': line.price_unit * line.qty * (this.discount or 0) * 0.01 or 0.0 + 'price_ded': line.price_unit * line.qty * (this.discount or 0) * 0.01 or 0.0 } - + order_line_ref.write(cr, uid, [line.id], res_new, context=context) return {} # def check_discount(self, cr, uid, record_id, discount, context): -# """ -# Check the discount of define by company . +# """ +# Check the discount of define by company . # @param self: The object pointer. # @param cr: A database cursor # @param uid: ID of the user currently logged in # @param record_id:Current Order id # @param discount:Select Discount -# @param context: A standard dictionary +# @param context: A standard dictionary # @return : retrun to apply and used the company discount base on condition # """ # order_ref = self.pool.get('pos.order') -# +# # for order in order_ref.browse(cr, uid, record_id, context=context): # company_disc = order.company_id.company_discount # for line in order.lines : @@ -106,6 +106,8 @@ class pos_discount(osv.osv_memory): # if prod_disc <= company_disc : # return 'apply_discount' # else : -# return 'disc_discount' +# return 'disc_discount' + pos_discount() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/wizard/pos_get_sale.py b/addons/point_of_sale/wizard/pos_get_sale.py index 901cc3a..9187054 100644 --- a/addons/point_of_sale/wizard/pos_get_sale.py +++ b/addons/point_of_sale/wizard/pos_get_sale.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,55 +15,55 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv, fields from tools.translate import _ + class pos_get_sale(osv.osv_memory): _name = 'pos.get.sale' _description = 'Get From Sale' _columns = { - 'picking_id': fields.many2one('stock.picking', 'Sale Order', domain=[('state','in',('assigned','confirmed')), ('type', '=', 'out')],context="{'contact_display':'partner'}",required=True), + 'picking_id': fields.many2one('stock.picking', 'Sale Order', domain=[('state', 'in', ('assigned', 'confirmed')), ('type', '=', 'out')], context="{'contact_display':'partner'}", required=True), } - + def sale_complete(self, cr, uid, ids, context): - """ - Select the picking order and add the in Point of sale order + """ + Select the picking order and add the in Point of sale order @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param context: A standard dictionary + @param context: A standard dictionary @return : nothing - """ + """ this = self.browse(cr, uid, ids[0], context=context) - record_id = context and context.get('active_id',False) - + record_id = context and context.get('active_id', False) + proxy_pos = self.pool.get('pos.order') proxy_pick = self.pool.get('stock.picking') - proxy_order_line=self.pool.get('pos.order.line') - + proxy_order_line = self.pool.get('pos.order.line') + if record_id: - order=proxy_pos.browse(cr, uid, record_id, context) - + order = proxy_pos.browse(cr, uid, record_id, context) + if order.state in ('paid', 'invoiced'): - raise osv.except_osv(_('UserError '), _("You can't modify this order. It has already been paid")) - + raise osv.except_osv(_('UserError '), _("You can't modify this order. It has already been paid")) + for pick in proxy_pick.browse(cr, uid, [this.picking_id.id], context): proxy_pos.write(cr, uid, record_id, { - 'last_out_picking':this.picking_id.id, + 'last_out_picking': this.picking_id.id, 'partner_id': pick.address_id and pick.address_id.partner_id.id }) - + order = proxy_pick.write(cr, uid, [this.picking_id.id], { 'invoice_state': 'none', 'pos_order': record_id }) - + for line in pick.move_lines: proxy_order_line.create(cr, uid, { 'name': line.sale_line_id.name, @@ -73,7 +73,10 @@ class pos_get_sale(osv.osv_memory): 'price_unit': line.sale_line_id.price_unit, 'discount': line.sale_line_id.discount, }) - + return {} + pos_get_sale() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/point_of_sale/wizard/pos_open_statement.py b/addons/point_of_sale/wizard/pos_open_statement.py index 1c02221..6605f3e 100644 --- a/addons/point_of_sale/wizard/pos_open_statement.py +++ b/addons/point_of_sale/wizard/pos_open_statement.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,76 +15,81 @@ # 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 . +# along with this program. If not, see . # ############################################################################## -import netsvc -from osv import osv,fields +from osv import osv from tools.translate import _ import time + + class pos_open_statement(osv.osv_memory): _name = 'pos.open.statement' _description = 'Open Statements' - def open_statement(self, cr, uid, ids, context): - """ - Open the statements + """ + Open the statements @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 : Blank Directory - """ - company_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.id - statement_obj =self.pool.get('account.bank.statement') + @param context: A standard dictionary + @return : Blank Directory + """ + company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id + statement_obj = self.pool.get('account.bank.statement') singer_obj = self.pool.get('singer.statement') - journal_obj=self.pool.get('account.journal') - journal_lst=journal_obj.search(cr,uid,[('company_id','=',company_id),('auto_cash','=',True)]) - journal_ids=journal_obj.browse(cr,uid, journal_lst) + journal_obj = self.pool.get('account.journal') + journal_lst = journal_obj.search(cr, uid, [('company_id', '=', company_id), ('auto_cash', '=', True)]) + journal_ids = journal_obj.browse(cr, uid, journal_lst) for journal in journal_ids: - ids = statement_obj.search(cr, uid, [('state','!=','confirm'),('user_id','=',uid),('journal_id','=',journal.id)]) + ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)]) if len(ids): - raise osv.except_osv(_('Message'),_('You can not open a Cashbox for "%s". \n Please close the cashbox related to. '%(journal.name) )) + raise osv.except_osv(_('Message'), _('You can not open a Cashbox for "%s". \n Please close the cashbox related to. ' % (journal.name))) sql = """ Select id from account_bank_statement where journal_id=%d and company_id =%d - order by id desc limit 1"""%(journal.id,company_id) - singer_ids=None + order by id desc limit 1""" % (journal.id, company_id) cr.execute(sql) st_id = cr.fetchone() - number='' - sequence_obj=self.pool.get('ir.sequence') + number = '' + sequence_obj = self.pool.get('ir.sequence') if journal.statement_sequence_id: number = sequence_obj.get_id(cr, uid, journal.id) else: number = sequence_obj.get(cr, uid, 'account.bank.statement') - + # statement_id=statement_obj.create(cr,uid,{'journal_id':journal.id, # 'company_id':company_id, # 'user_id':uid, # 'state':'open', # 'name':number # }) - period=statement_obj._get_period(cr,uid,context) or None - cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id,company_id,uid,number, period, time.strftime('%Y-%m-%d %H:%M:%S'))) + period = statement_obj._get_period(cr, uid, context) or None + cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id, company_id, uid, number, period, time.strftime('%Y-%m-%d %H:%M:%S'))) cr.commit() - cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id,company_id,uid,number)) - statement_id=cr.fetchone()[0] + cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id, company_id, uid, number)) + statement_id = cr.fetchone()[0] if st_id: - statemt_id=statement_obj.browse(cr,uid,st_id[0]) + statemt_id = statement_obj.browse(cr, uid, st_id[0]) if statemt_id and statemt_id.ending_details_ids: - statement_obj.write(cr, uid,[statement_id], {'balance_start':statemt_id.balance_end, - 'state':'open'}) + statement_obj.write(cr, uid, [statement_id], { + 'balance_start': statemt_id.balance_end, + 'state': 'open', + }) if statemt_id.ending_details_ids: for i in statemt_id.ending_details_ids: - c=singer_obj.create(cr,uid, { 'pieces':i.pieces, - 'number':i.number, - 'starting_id':statement_id, - }) + c = singer_obj.create(cr, uid, { + 'pieces': i.pieces, + 'number': i.number, + 'starting_id': statement_id, + }) cr.commit() return {} + pos_open_statement() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index b29a6a4..1d9214c 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,97 +15,97 @@ # 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 . +# along with this program. If not, see . # ############################################################################## import netsvc -from osv import osv,fields +from osv import osv, fields from tools.translate import _ import pos_box_entries import time -from decimal import Decimal -from tools.translate import _ -import pos_receipt + class pos_make_payment(osv.osv_memory): _name = 'pos.make.payment' _description = 'Point of Sale Payment' - - def default_get(self, cr, uid, fields, context): - """ + + def default_get(self, cr, uid, fields, context=None): + """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - @return: A dictionary which of fields with values. + @param fields: List of fields for which we want default values + @param context: A standard dictionary + @return: A dictionary which of fields with values. """ + if context is None: + context = {} + res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context) - record_id = context and context.get('active_id',False) + record_id = context and context.get('active_id', False) j_obj = self.pool.get('account.journal') - company_id = self.pool.get('res.users').browse(cr,uid,uid).company_id.id + company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', company_id)]) if journal: journal = journal[0] else: journal = None - wf_service = netsvc.LocalService("workflow") - order = self.pool.get('pos.order').browse(cr, uid, record_id, context) #get amount to pay amount = order.amount_total - order.amount_paid - - if amount<=0.0: - context.update({'flag':True}) - self.pool.get('pos.order').action_paid(cr,uid,[record_id],context) + + if amount <= 0.0: + context.update({'flag': True}) + self.pool.get('pos.order').action_paid(cr, uid, [record_id], context) elif order.amount_paid > 0.0: - self.pool.get('pos.order').write(cr, uid, [record_id],{'state':'advance'}) - + self.pool.get('pos.order').write(cr, uid, [record_id], {'state': 'advance'}) + invoice_wanted_checked = False - + current_date = time.strftime('%Y-%m-%d') - + if 'journal' in fields: - res.update({'journal':journal}) + res.update({'journal': journal}) if 'amount' in fields: - res.update({'amount':amount}) + res.update({'amount': amount}) if 'invoice_wanted' in fields: - res.update({'invoice_wanted':invoice_wanted_checked}) + res.update({'invoice_wanted': invoice_wanted_checked}) if 'payment_date' in fields: - res.update({'payment_date':current_date}) - if 'payment_name' in fields: - res.update({'payment_name':'Payment'}) + res.update({'payment_date': current_date}) + if 'payment_name' in fields: + res.update({'payment_name': 'Payment'}) return res + def view_init(self, cr, uid, fields_list, context=None): res = super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context) - record_id = context and context.get('active_id', False) or False + record_id = context and context.get('active_id', False) or False order = self.pool.get('pos.order').browse(cr, uid, record_id) if not order.lines: - raise osv.except_osv('Error!','No Order Lines ') + raise osv.except_osv('Error!', 'No Order Lines ') True - + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - """ + """ Changes the view dynamically - + @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in - @param context: A standard dictionary - + @param context: A standard dictionary + @return: New arch of view. - + """ - record_id = context and context.get('record_id', False) or False - res = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) - + record_id = context and context.get('record_id', False) or False + res = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) + if record_id: order = self.pool.get('pos.order').browse(cr, uid, record_id) amount = order.amount_total - order.amount_paid - if amount==0.0: + if amount == 0.0: res['arch'] = """