[FIX] point_of_sale :Partner info available for move line from POS,only draft/cancelled POS lines can be deleted

lp bug: https://launchpad.net/bugs/404142 fixed
lp bug: https://launchpad.net/bugs/404155 fixed

bzr revid: jvo@tinyerp.com-20090728125721-r68yepf9sna6ahnr
This commit is contained in:
GPA,JVO 2009-07-28 18:27:21 +05:30 committed by Jay (Open ERP)
parent e26668ccc6
commit cb870be8bd
3 changed files with 26 additions and 6 deletions

View File

@ -573,7 +573,7 @@ class account_move_line(osv.osv):
raise osv.except_osv(_('Error'), _('Entry is already reconciled'))
account = self.pool.get('account.account').browse(cr, uid, account_id, context=context)
if not context.get('fy_closing', False) and not account.reconcile:
raise osv.except_osv(_('Error'), _('The account is not defined to be reconcile !'))
raise osv.except_osv(_('Error'), _('The account is not defined to be reconciled !'))
if r[0][1] != None:
raise osv.except_osv(_('Error'), _('Some entries are already reconciled !'))

View File

@ -638,6 +638,7 @@ class pos_order(osv.osv):
'period_id': period,
'tax_code_id': tax_code_id,
'tax_amount': tax_amount,
'partner_id' : order.partner_id and order.partner_id.id or False,
}, context=context)
# For each remaining tax with a code, whe create a move line
@ -663,6 +664,7 @@ class pos_order(osv.osv):
'period_id': period,
'tax_code_id': tax_code_id,
'tax_amount': tax_amount,
'partner_id' : order.partner_id and order.partner_id.id or False,
}, context=context)
@ -681,6 +683,7 @@ class pos_order(osv.osv):
'period_id': period,
'tax_code_id': key[tax_code_pos],
'tax_amount': amount,
'partner_id' : order.partner_id and order.partner_id.id or False,
}, context=context)
# counterpart
@ -696,6 +699,7 @@ class pos_order(osv.osv):
or 0.0,
'journal_id': order.sale_journal.id,
'period_id': period,
'partner_id' : order.partner_id and order.partner_id.id or False,
}, context=context))
@ -742,6 +746,7 @@ class pos_order(osv.osv):
'debit': ((payment.amount>0) and payment.amount) or 0.0,
'journal_id': payment.journal_id.id,
'period_id': period,
'partner_id' : order.partner_id and order.partner_id.id or False,
}, context=context)
to_reconcile.append(account_move_line_obj.create(cr, uid, {
'name': order.name,
@ -753,6 +758,7 @@ class pos_order(osv.osv):
'debit': ((payment.amount<0) and -payment.amount) or 0.0,
'journal_id': payment.journal_id.id,
'period_id': period,
'partner_id' : order.partner_id and order.partner_id.id or False,
}, context=context))
account_move_obj.button_validate(cr, uid, [move_id, payment_move_id], context=context)
@ -887,7 +893,14 @@ class pos_order_line(osv.osv):
price_line = float(qty)*float(price)
return {'name': product_name, 'product_id': product_id[0], 'price': price, 'price_line': price_line ,'qty': qty }
def unlink(self, cr, uid, ids, context={}):
"""Allows to delete pos order lines in draft,cancel state"""
for rec in self.browse(cr, uid, ids, context=context):
if rec.order_id.state not in ['draft','cancel']:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete an order line which is %s !')%(rec.order_id.state,))
return super(pos_order_line, self).unlink(cr, uid, ids, context=context)
pos_order_line()

View File

@ -215,7 +215,7 @@ class sale_order(osv.osv):
help="""The Shipping Policy is used to synchronise invoice and delivery operations.
- The 'Pay before delivery' choice will first generate the invoice and then generate the packing order after the payment of this invoice.
- The 'Shipping & Manual Invoice' will create the packing order directly and wait for the user to manually click on the 'Invoice' button to generate the draft invoice.
- The 'Invoice on Order Ater Delivery' choice will generate the draft invoice based on sale order after all packing lists have been finished.
- The 'Invoice on Order After Delivery' choice will generate the draft invoice based on sale order after all packing lists have been finished.
- The 'Invoice from the packing' choice is used to create an invoice during the packing process."""),
'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'project_id':fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft':[('readonly', False)]}),
@ -273,7 +273,7 @@ class sale_order(osv.osv):
sale_orders = self.read(cr, uid, ids, ['state'])
unlink_ids = []
for s in sale_orders:
if s['state'] in ['draft','canceled']:
if s['state'] in ['draft','cancel']:
unlink_ids.append(s['id'])
else:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete Sale Order(s) which are already confirmed !'))
@ -730,7 +730,7 @@ class sale_order_line(osv.osv):
'number_packages': fields.function(_number_packages, method=True, type='integer', string='Number Packages'),
'notes': fields.text('Notes'),
'th_weight' : fields.float('Weight'),
'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Canceled'),('exception','Exception')], 'Status', required=True, readonly=True),
'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Cancelled'),('exception','Exception')], 'Status', required=True, readonly=True),
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer')
}
_order = 'sequence, id'
@ -993,7 +993,14 @@ class sale_order_line(osv.osv):
if not uom:
res['value']['price_unit'] = 0.0
return res
def unlink(self, cr, uid, ids, context={}):
"""Allows to delete sale order lines in draft,cancel states"""
for rec in self.browse(cr, uid, ids, context=context):
if rec.state not in ['draft','cancel']:
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a sale order line which is %s !')%(rec.state,))
return super(sale_order_line, self).unlink(cr, uid, ids, context=context)
sale_order_line()