[pos] fix: context problems

bzr revid: hmo@tinyerp.com-20100506143430-0kshbbhq00hm43q2
This commit is contained in:
Harry (Open ERP) 2010-05-06 20:04:30 +05:30
parent 56ded53b7c
commit 7de93b1c1f
2 changed files with 28 additions and 26 deletions

View File

@ -43,6 +43,7 @@ class pos_make_payment(osv.osv_memory):
@return: A dictionary which of fields with values.
"""
res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context)
active_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
@ -84,8 +85,8 @@ class pos_make_payment(osv.osv_memory):
active_id = context and context.get('active_id', False) or False
order = self.pool.get('pos.order').browse(cr, uid, active_id)
if not order.lines:
raise osv.except_osv('Error!','No order lines defined for this sale ')
True
raise osv.except_osv('Error!','No order lines defined for this sale ')
return True
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
"""
@ -103,24 +104,21 @@ class pos_make_payment(osv.osv_memory):
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)
active_model = context.get('active_model')
if not active_model and active_model != 'pos.order':
return result
active_id = context.get('active_id', False)
if active_id:
try:
order = self.pool.get('pos.order').browse(cr, uid, active_id)
if order.amount_total == order.amount_paid:
res['arch'] = """ <form string="Make Payment" colspan="4">
<group col="2" colspan="2">
<label string="Do you want to print the Receipt?" colspan="4"/>
<separator colspan="4"/>
<button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
<button name="print_report" string="Print Receipt" type="object" icon="gtk-print"/>
</group>
</form>
"""
except:
return result
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)
if order.amount_total == order.amount_paid:
res['arch'] = """ <form string="Make Payment" colspan="4">
<group col="2" colspan="2">
<label string="Do you want to print the Receipt?" colspan="4"/>
<separator colspan="4"/>
<button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
<button name="print_report" string="Print Receipt" type="object" icon="gtk-print"/>
</group>
</form>
"""
return result
def check(self, cr, uid, ids, context=None):

View File

@ -131,6 +131,7 @@ class pos_return(osv.osv_memory):
'view_id': False,
'target':'new',
'views': False,
'context': context,
'type': 'ir.actions.act_window',
}
def create_returns2(self, cr, uid, ids, context):
@ -193,6 +194,7 @@ class pos_return(osv.osv_memory):
'auto_refresh':0,
'res_id':new_order,
'view_id': False,
'context':context,
'type': 'ir.actions.act_window'
}
return act
@ -276,7 +278,7 @@ class add_product(osv.osv_memory):
}
def close_action(self, cr, uid, ids, context):
active_id=context.get('active_id', False)
active_ids=context.get('active_ids', False)
order_obj = self.pool.get('pos.order')
lines_obj = self.pool.get('pos.order.line')
picking_obj = self.pool.get('stock.picking')
@ -284,7 +286,7 @@ class add_product(osv.osv_memory):
move_obj = self.pool.get('stock.move')
property_obj= self.pool.get("ir.property")
invoice_obj=self.pool.get('account.invoice')
picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', [active_id]), ('state', '=', 'done')])
picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', active_ids), ('state', '=', 'done')])
clone_list = []
date_cur=time.strftime('%Y-%m-%d')
uom_obj = self.pool.get('product.uom')
@ -293,7 +295,7 @@ class add_product(osv.osv_memory):
data=return_boj.read(cr,uid,return_id,[])[0]
wf_service = netsvc.LocalService("workflow")
for order_id in order_obj.browse(cr, uid, [active_id], context=context):
for order_id in order_obj.browse(cr, uid, active_ids, context=context):
prop_ids =property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')])
val = property_obj.browse(cr, uid,prop_ids[0]).value_reference
cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id))
@ -328,11 +330,12 @@ class add_product(osv.osv_memory):
})
wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr)
picking_obj.force_assign(cr, uid, [new_picking], context)
obj=order_obj.browse(cr,uid, active_id)
obj=order_obj.browse(cr,uid, active_ids[0])
if obj.amount_total != obj.amount_paid:
return {
'name': _('Make Payment'),
'context ':context and context.get('active_id', False),
'context ':context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'pos.make.payment',
@ -341,7 +344,8 @@ class add_product(osv.osv_memory):
'views': False,
'type': 'ir.actions.act_window',
}
}
return True
add_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: