[IMP] point_of_sale: code cleaning
bzr revid: psi@tinyerp.co.in-20101026134031-ee7geo6vzj1npv5r
This commit is contained in:
@@ -26,7 +26,7 @@ class pos_close_statement(osv.osv_memory):
|
||||
_name = 'pos.close.statement'
|
||||
_description = 'Close Statements'
|
||||
|
||||
def close_statement(self, cr, uid, ids, context):
|
||||
def close_statement(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Close the statements
|
||||
@param self: The object pointer.
|
||||
@@ -39,34 +39,33 @@ class pos_close_statement(osv.osv_memory):
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
|
||||
"WHERE user_id=%s ORDER BY journal_id", (uid,))
|
||||
"WHERE user_id=%s ORDER BY journal_id", (uid, ))
|
||||
j_ids = map(lambda x1: x1[0], cr.fetchall())
|
||||
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)])
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)])
|
||||
for journal in journal_obj.browse(cr, uid, journal_ids):
|
||||
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', journal_ids)], context=context)
|
||||
for journal in journal_obj.browse(cr, uid, journal_ids, context=context):
|
||||
if not ids:
|
||||
raise osv.except_osv(_('Message'), _('Registers are already closed.'))
|
||||
else:
|
||||
if not journal.check_dtls:
|
||||
statement_obj.button_confirm_cash(cr, uid, ids, context)
|
||||
statement_obj.button_confirm_cash(cr, uid, ids, context=context)
|
||||
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
|
||||
id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
|
||||
result = data_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_confirm_cash_statement_filter')
|
||||
id2 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
|
||||
id3 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
|
||||
result = mod_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_confirm_cash_statement_filter')
|
||||
search_id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
id2 = mod_obj.browse(cr, uid, id2, context=context).res_id
|
||||
if id3:
|
||||
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
|
||||
id3 = mod_obj.browse(cr, uid, id3, context=context).res_id
|
||||
return {
|
||||
'domain': "[('id','in'," + str(ids) + ")]",
|
||||
'domain': "[('id', 'in', " + str(ids) + ")]",
|
||||
'name': 'Close Statements',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'view_mode': 'tree, form',
|
||||
'search_view_id': search_id['res_id'],
|
||||
'res_model': 'account.bank.statement',
|
||||
'views': [(id2, 'tree'),(id3, 'form')],
|
||||
'views': [(id2, 'tree'), (id3, 'form')],
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class pos_confirm(osv.osv_memory):
|
||||
_name = 'pos.confirm'
|
||||
_description = 'Point of Sale Confirm'
|
||||
|
||||
def action_confirm(self, cr, uid, ids, context):
|
||||
def action_confirm(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Confirm the order and close the sales.
|
||||
@param self: The object pointer.
|
||||
@@ -37,7 +37,8 @@ class pos_confirm(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return :Blank dictionary
|
||||
"""
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
record_id = context and context.get('active_id', False)
|
||||
if record_id:
|
||||
if isinstance(record_id, (int, long)):
|
||||
@@ -47,7 +48,7 @@ class pos_confirm(osv.osv_memory):
|
||||
|
||||
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})
|
||||
order_obj.write(cr, uid, [order_id.id], {'journal_entry': True}, context=context)
|
||||
order_obj.create_account_move(cr, uid, [order_id.id], context=context)
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
import time
|
||||
|
||||
|
||||
class pos_details(osv.osv_memory):
|
||||
@@ -33,11 +34,11 @@ class pos_details(osv.osv_memory):
|
||||
'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': time.strftime('%Y-%m-%d'),
|
||||
'date_end': time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context={}):
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
To get the date and print the report
|
||||
@param self: The object pointer.
|
||||
@@ -46,12 +47,12 @@ class pos_details(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return : retrun report
|
||||
"""
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
datas = {'ids': context.get('active_ids', [])}
|
||||
res = self.read(cr, uid, ids, ['date_start', 'date_end'], context)
|
||||
res = self.read(cr, uid, ids, ['date_start', 'date_end'], context=context)
|
||||
res = res and res[0] or {}
|
||||
datas['form'] = res
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'pos.details',
|
||||
|
||||
@@ -32,7 +32,7 @@ class pos_discount(osv.osv_memory):
|
||||
'discount_notes': fields.char('Discount Notes', size= 128, required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'discount': lambda *a: 5,
|
||||
'discount': 5,
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ class pos_discount(osv.osv_memory):
|
||||
"""
|
||||
res = super(pos_discount, self).view_init(cr, uid, fields_list, context=context)
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
order = self.pool.get('pos.order').browse(cr, uid, record_id)
|
||||
order = self.pool.get('pos.order').browse(cr, uid, record_id, context=context)
|
||||
if not order.lines:
|
||||
raise osv.except_osv('Error!','No Order Lines ')
|
||||
True
|
||||
def apply_discount(self, cr, uid, ids, context):
|
||||
def apply_discount(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
To give the discount of product and check the.
|
||||
|
||||
@@ -61,16 +61,16 @@ class pos_discount(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return : nothing
|
||||
"""
|
||||
order_ref = self.pool.get('pos.order')
|
||||
order_line_ref = self.pool.get('pos.order.line')
|
||||
if context is None:
|
||||
context = {}
|
||||
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]
|
||||
|
||||
order_ref = self.pool.get('pos.order')
|
||||
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:
|
||||
company_discount = order.company_id.company_discount
|
||||
applied_discount = this.discount
|
||||
@@ -81,10 +81,7 @@ class pos_discount(osv.osv_memory):
|
||||
notice = 'Minimum Discount'
|
||||
else:
|
||||
notice = this.discount_notes
|
||||
|
||||
res_new = {
|
||||
}
|
||||
|
||||
res_new = {}
|
||||
if this.discount <= company_discount:
|
||||
res_new = {
|
||||
'discount': this.discount,
|
||||
|
||||
@@ -28,10 +28,10 @@ class pos_get_sale(osv.osv_memory):
|
||||
_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):
|
||||
def sale_complete(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Select the picking order and add the in Point of sale order
|
||||
@param self: The object pointer.
|
||||
@@ -40,29 +40,29 @@ class pos_get_sale(osv.osv_memory):
|
||||
@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)
|
||||
|
||||
proxy_pos = self.pool.get('pos.order')
|
||||
proxy_pick = self.pool.get('stock.picking')
|
||||
proxy_order_line = self.pool.get('pos.order.line')
|
||||
if context is None:
|
||||
context = {}
|
||||
this = self.browse(cr, uid, ids[0], context=context)
|
||||
record_id = context and context.get('active_id', False)
|
||||
|
||||
if record_id:
|
||||
order = proxy_pos.browse(cr, uid, record_id, context)
|
||||
|
||||
order = proxy_pos.browse(cr, uid, record_id, context=context)
|
||||
if order.state in ('paid', 'invoiced'):
|
||||
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):
|
||||
for pick in proxy_pick.browse(cr, uid, [this.picking_id.id], context=context):
|
||||
proxy_pos.write(cr, uid, record_id, {
|
||||
'picking_id': this.picking_id.id,
|
||||
'partner_id': pick.address_id and pick.address_id.partner_id.id
|
||||
})
|
||||
}, context=context)
|
||||
|
||||
order = proxy_pick.write(cr, uid, [this.picking_id.id], {
|
||||
'invoice_state': 'none',
|
||||
'pos_order': record_id
|
||||
})
|
||||
}, context=context)
|
||||
|
||||
for line in pick.move_lines:
|
||||
proxy_order_line.create(cr, uid, {
|
||||
@@ -72,8 +72,7 @@ class pos_get_sale(osv.osv_memory):
|
||||
'product_id': line.product_id.id,
|
||||
'price_unit': line.sale_line_id.price_unit,
|
||||
'discount': line.sale_line_id.discount,
|
||||
})
|
||||
|
||||
}, context=context)
|
||||
return {}
|
||||
|
||||
pos_get_sale()
|
||||
|
||||
@@ -26,7 +26,7 @@ class pos_open_statement(osv.osv_memory):
|
||||
_name = 'pos.open.statement'
|
||||
_description = 'Open Statements'
|
||||
|
||||
def open_statement(self, cr, uid, ids, context):
|
||||
def open_statement(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Open the statements
|
||||
@param self: The object pointer.
|
||||
@@ -37,20 +37,20 @@ class pos_open_statement(osv.osv_memory):
|
||||
"""
|
||||
data = {}
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
sequence_obj = self.pool.get('ir.sequence')
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
|
||||
"WHERE user_id=%s ORDER BY journal_id"% (uid,))
|
||||
"WHERE user_id = %s ORDER BY journal_id"% (uid, ))
|
||||
j_ids = map(lambda x1: x1[0], cr.fetchall())
|
||||
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)])
|
||||
journal_ids = journal_obj.search(cr, uid, [('auto_cash', '=', True), ('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
|
||||
|
||||
for journal in journal_obj.browse(cr, uid, journal_ids):
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
|
||||
for journal in journal_obj.browse(cr, uid, journal_ids, context=context):
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)], context=context)
|
||||
if len(ids):
|
||||
raise osv.except_osv(_('Message'), _('You can not open a Cashbox for "%s".\nPlease close its related Register.' %(journal.name)))
|
||||
|
||||
|
||||
number = ''
|
||||
if journal.sequence_id:
|
||||
number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)
|
||||
@@ -62,27 +62,26 @@ class pos_open_statement(osv.osv_memory):
|
||||
'user_id': uid,
|
||||
'state': 'draft',
|
||||
'name': number })
|
||||
statement_id = statement_obj.create(cr, uid, data)
|
||||
statement_id = statement_obj.create(cr, uid, data, context=context)
|
||||
statement_obj.button_open(cr, uid, [statement_id], context)
|
||||
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
|
||||
id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
|
||||
result = data_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_open_cash_statement_filter')
|
||||
id2 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
|
||||
id3 = mod_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
|
||||
result = mod_obj._get_id(cr, uid, 'point_of_sale', 'view_pos_open_cash_statement_filter')
|
||||
search_id = mod_obj.read(cr, uid, result, ['res_id'], context=context)
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
id2 = mod_obj.browse(cr, uid, id2, context=context).res_id
|
||||
if id3:
|
||||
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
|
||||
id3 = mod_obj.browse(cr, uid, id3, context=context).res_id
|
||||
|
||||
return {
|
||||
'domain': "[('state','=','open'),('user_id','=',"+ str(uid) +")]",
|
||||
'domain': "[('state', '=', 'open'),('user_id', '=', "+ str(uid) +")]",
|
||||
'name': 'Open Statement',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'view_mode': 'tree, form',
|
||||
'search_view_id': search_id['res_id'],
|
||||
'res_model': 'account.bank.statement',
|
||||
'views': [(id2, 'tree'),(id3, 'form')],
|
||||
'views': [(id2, 'tree'), (id3, 'form')],
|
||||
'context': {'search_default_open': 1},
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
@@ -19,16 +19,18 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv,fields
|
||||
import time
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
import pos_box_entries
|
||||
import time
|
||||
|
||||
|
||||
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.
|
||||
@@ -38,40 +40,40 @@ class pos_make_payment(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
j_obj = self.pool.get('account.journal')
|
||||
order_obj=self.pool.get('pos.order')
|
||||
res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context)
|
||||
active_id = context and context.get('active_id',False)
|
||||
active_id = context and context.get('active_id', False)
|
||||
if active_id:
|
||||
j_obj = self.pool.get('account.journal')
|
||||
cr.execute("SELECT DISTINCT journal_id FROM pos_journal_users "
|
||||
"WHERE user_id=%d ORDER BY journal_id"% (uid,))
|
||||
"WHERE user_id = %d ORDER BY journal_id"% (uid, ))
|
||||
j_ids = map(lambda x1: x1[0], cr.fetchall())
|
||||
journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
|
||||
|
||||
journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)], context=context)
|
||||
journal = journal and journal[0] or False
|
||||
|
||||
order_obj=self.pool.get('pos.order')
|
||||
order = order_obj.browse(cr, uid, active_id, context)
|
||||
order = order_obj.browse(cr, uid, active_id, context=context)
|
||||
#get amount to pay
|
||||
amount = order.amount_total - order.amount_paid
|
||||
if amount <= 0.0:
|
||||
context.update({'flag': True})
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
elif order.amount_paid > 0.0:
|
||||
order_obj.write(cr, uid, [active_id], {'state': 'advance'})
|
||||
order_obj.write(cr, uid, [active_id], {'state': 'advance'}, context=context)
|
||||
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})
|
||||
res.update({'payment_date': current_date})
|
||||
if 'payment_name' in fields:
|
||||
res.update({'payment_name':'Payment'})
|
||||
res.update({'payment_name': 'Payment'})
|
||||
if 'partner_id' in fields:
|
||||
res.update({'partner_id': order.partner_id.id or False})
|
||||
if 'pricelist_id' in fields:
|
||||
@@ -82,7 +84,7 @@ class pos_make_payment(osv.osv_memory):
|
||||
super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
|
||||
active_id = context and context.get('active_id', False) or False
|
||||
if active_id:
|
||||
order = self.pool.get('pos.order').browse(cr, uid, active_id)
|
||||
order = self.pool.get('pos.order').browse(cr, uid, active_id, context=context)
|
||||
if not order.lines:
|
||||
raise osv.except_osv(_('Error!'),_('No order lines defined for this sale '))
|
||||
return True
|
||||
@@ -99,15 +101,15 @@ class pos_make_payment(osv.osv_memory):
|
||||
@return: New arch of view.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
result = 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 context is None:
|
||||
context = {}
|
||||
active_model = context.get('active_model')
|
||||
active_id = context.get('active_id', False)
|
||||
if not active_id or (active_model and active_model != 'pos.order'):
|
||||
return result
|
||||
|
||||
order = self.pool.get('pos.order').browse(cr, uid, active_id)
|
||||
order = self.pool.get('pos.order').browse(cr, uid, active_id, context=context)
|
||||
if order.amount_total == order.amount_paid:
|
||||
result['arch'] = """ <form string="Make Payment" colspan="4">
|
||||
<group col="2" colspan="2">
|
||||
@@ -132,26 +134,25 @@ class pos_make_payment(osv.osv_memory):
|
||||
amount = amount - product.list_price
|
||||
return {'value': {'amount': amount}}
|
||||
|
||||
def check(self, cr, uid, ids, context):
|
||||
|
||||
def check(self, cr, uid, ids, context=None):
|
||||
"""Check the order:
|
||||
if the order is not paid: continue payment,
|
||||
if the order is paid print invoice (if wanted) or ticket.
|
||||
"""
|
||||
active_id = context and context.get('active_id',False)
|
||||
order_obj = self.pool.get('pos.order')
|
||||
active_id = context and context.get('active_id', False)
|
||||
order = order_obj.browse(cr, uid, active_id, context)
|
||||
amount = order.amount_total - order.amount_paid
|
||||
data = self.read(cr, uid, ids)[0]
|
||||
data = self.read(cr, uid, ids, context=context)[0]
|
||||
invoice_wanted = data['invoice_wanted']
|
||||
is_accompte = data['is_acc']
|
||||
# Todo need to check ...
|
||||
if is_accompte:
|
||||
line_id, price = order_obj.add_product(cr, uid, order.id, data['product_id'], -1.0, context)
|
||||
amount = order.amount_total - order.amount_paid - price
|
||||
|
||||
|
||||
if amount != 0.0:
|
||||
order_obj.write(cr, uid, [active_id], {'invoice_wanted': invoice_wanted, 'partner_id': data['partner_id']})
|
||||
order_obj.write(cr, uid, [active_id], {'invoice_wanted': invoice_wanted, 'partner_id': data['partner_id']}, context=context)
|
||||
order_obj.add_payment(cr, uid, active_id, data, context=context)
|
||||
|
||||
if order_obj.test_paid(cr, uid, [active_id]):
|
||||
@@ -159,33 +160,33 @@ class pos_make_payment(osv.osv_memory):
|
||||
order_obj.action_invoice(cr, uid, [active_id], context)
|
||||
order_obj.create_picking(cr, uid, [active_id], context)
|
||||
if context.get('return'):
|
||||
order_obj.write(cr, uid, [active_id],{'state':'done'})
|
||||
order_obj.write(cr, uid, [active_id], {'state':'done'}, context=context)
|
||||
else:
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'})
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'}, context=context)
|
||||
return self.create_invoice(cr, uid, ids, context)
|
||||
else:
|
||||
context.update({'flag': True})
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
if context.get('return'):
|
||||
order_obj.write(cr, uid, [active_id],{'state':'done'})
|
||||
order_obj.write(cr, uid, [active_id], {'state':'done'}, context=context)
|
||||
else:
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'})
|
||||
order_obj.write(cr, uid, [active_id], {'state':'paid'}, context=context)
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
|
||||
if order.amount_paid > 0.0:
|
||||
context.update({'flag': True})
|
||||
# Todo need to check
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
order_obj.write(cr, uid, [active_id],{'state': 'advance'})
|
||||
order_obj.write(cr, uid, [active_id], {'state': 'advance'}, context=context)
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
return {}
|
||||
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context):
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Create a invoice
|
||||
"""
|
||||
active_ids = [context and context.get('active_id',False)]
|
||||
active_ids = [context and context.get('active_id', False)]
|
||||
datas = {'ids': active_ids}
|
||||
datas['form'] = {}
|
||||
return {
|
||||
@@ -204,12 +205,11 @@ class pos_make_payment(osv.osv_memory):
|
||||
@return : retrun report
|
||||
"""
|
||||
if not context:
|
||||
context={}
|
||||
active_id=context.get('active_id',[])
|
||||
context = {}
|
||||
active_id = context.get('active_id', [])
|
||||
datas = {'ids' : [active_id]}
|
||||
res = {}
|
||||
datas['form'] = res
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'pos.receipt',
|
||||
@@ -217,14 +217,14 @@ class pos_make_payment(osv.osv_memory):
|
||||
}
|
||||
|
||||
_columns = {
|
||||
'journal':fields.selection(pos_box_entries.get_journal, "Cash Register",required=True),
|
||||
'journal': fields.selection(pos_box_entries.get_journal, "Cash Register", required=True),
|
||||
'product_id': fields.many2one('product.product', "Advance"),
|
||||
'amount':fields.float('Amount', digits=(16,2) ,required= True),
|
||||
'amount': fields.float('Amount', digits=(16,2) ,required= True),
|
||||
'payment_name': fields.char('Payment name', size=32, required=True),
|
||||
'payment_date': fields.date('Payment date', required=True),
|
||||
'is_acc': fields.boolean('Advance'),
|
||||
'invoice_wanted': fields.boolean('Invoice'),
|
||||
'num_sale':fields.char('Num.File', size=32),
|
||||
'num_sale': fields.char('Num.File', size=32),
|
||||
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer'),
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,20 +15,18 @@
|
||||
# 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 tools.translate import _
|
||||
|
||||
|
||||
class pos_payment_report(osv.osv_memory):
|
||||
_name = 'pos.payment.report'
|
||||
_description = 'Payment Report'
|
||||
|
||||
def print_report(self, cr, uid, ids, context={}):
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
To get the date and print the report
|
||||
@param self: The object pointer.
|
||||
@@ -37,7 +35,8 @@ class pos_payment_report(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return : retrun report
|
||||
"""
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
datas = {'ids': context.get('active_ids', [])}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,20 +15,21 @@
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
import time
|
||||
|
||||
|
||||
class pos_payment_report_date(osv.osv_memory):
|
||||
_name = 'pos.payment.report.date'
|
||||
_description = 'POS Payment Report according to date'
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
To get the date and print the report
|
||||
@param self: The object pointer.
|
||||
@@ -37,8 +38,10 @@ class pos_payment_report_date(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return : retrun report
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
datas = {'ids': context.get('active_ids', [])}
|
||||
res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_id'])
|
||||
res = self.read(cr, uid, ids, ['date_start', 'date_end', 'user_id'], context=context)
|
||||
res = res and res[0] or {}
|
||||
datas['form'] = res
|
||||
|
||||
@@ -54,8 +57,8 @@ class pos_payment_report_date(osv.osv_memory):
|
||||
'user_id': fields.many2many('res.users', 'res_user_sale', 'user_id', 'sale_id', 'Salesman')
|
||||
}
|
||||
_defaults = {
|
||||
'date_start': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date_end': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'date_start': time.strftime('%Y-%m-%d'),
|
||||
'date_end': time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
|
||||
pos_payment_report_date()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,19 +15,16 @@
|
||||
# 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 osv, fields
|
||||
|
||||
class pos_payment_report_user(osv.osv_memory):
|
||||
_name = 'pos.payment.report.user'
|
||||
_description = 'Sales lines by Users'
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
|
||||
"""
|
||||
To get the date and print the report
|
||||
@param self: The object pointer.
|
||||
@@ -36,11 +33,12 @@ class pos_payment_report_user(osv.osv_memory):
|
||||
@param context: A standard dictionary
|
||||
@return : retrun report
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
datas = {'ids': context.get('active_ids', [])}
|
||||
res = self.read(cr, uid, ids, ['user_id'])
|
||||
res = self.read(cr, uid, ids, ['user_id'], context=context)
|
||||
res = res and res[0] or {}
|
||||
datas['form'] = res
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'pos.payment.report.user',
|
||||
|
||||
Reference in New Issue
Block a user