[IMP] sale: update some statements in yml & clear unwanted code in sale.py file.

bzr revid: cha@tinyerp.com-20120912091040-yezbspjjucempq2e
This commit is contained in:
Ajay Chauhan (OpenERP) 2012-09-12 14:40:40 +05:30
parent aa779d5000
commit 427200a241
2 changed files with 28 additions and 24 deletions

View File

@ -145,13 +145,6 @@ class sale_order(osv.osv):
res[sale.id] = 0.0 res[sale.id] = 0.0
return res return res
def _get_invoiced_amount(self, cr, uid, sale, context=None):
invoiced_amount = 0
for invoice in sale.invoice_ids:
if invoice.state!='cancel':
invoiced_amount += invoice.amount_total
return invoiced_amount
def _invoice_exists(self, cursor, user, ids, name, arg, context=None): def _invoice_exists(self, cursor, user, ids, name, arg, context=None):
res = {} res = {}
for sale in self.browse(cursor, user, ids, context=context): for sale in self.browse(cursor, user, ids, context=context):
@ -535,25 +528,35 @@ class sale_order(osv.osv):
This function returns an action that display existing invoices of given sale order ids. It can either be a in a list or in a form view, if there is only one invoice to show. This function returns an action that display existing invoices of given sale order ids. It can either be a in a list or in a form view, if there is only one invoice to show.
''' '''
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window') result = {
'name': _('Cutomer Invoice'),
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1') 'view_type': 'form',
id = result and result[1] or False 'res_model': 'account.invoice',
result = act_obj.read(cr, uid, [id], context=context)[0] 'context': "{'type':'out_invoice', 'journal_type': 'sale'}",
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
}
#compute the number of invoices to display #compute the number of invoices to display
inv_ids = [] inv_ids = []
for so in self.browse(cr, uid, ids, context=context): for so in self.browse(cr, uid, ids, context=context):
inv_ids += [invoice.id for invoice in so.invoice_ids] inv_ids += [invoice.id for invoice in so.invoice_ids]
#choose the view_mode accordingly #choose the view_mode accordingly
if len(inv_ids) > 1: if len(inv_ids)>1:
result['domain'] = "[('id','in',["+','.join(map(str, inv_ids))+"])]" res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree')
result.update({
'view_mode': 'tree,form',
'res_id': inv_ids or False
})
else: else:
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form') res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
result['views'] = [(res and res[1] or False, 'form')] result.update({
result['res_id'] = inv_ids and inv_ids[0] or False 'view_mode': 'form',
'res_id': inv_ids and inv_ids[0] or False,
})
result.update(view_id = res and res[1] or False)
return result return result
def action_view_delivery(self, cr, uid, ids, context=None): def action_view_delivery(self, cr, uid, ids, context=None):
''' '''
This function returns an action that display existing delivery orders of given sale order ids. It can either be a in a list or in a form view, if there is only one delivery order to show. This function returns an action that display existing delivery orders of given sale order ids. It can either be a in a list or in a form view, if there is only one delivery order to show.

View File

@ -1,5 +1,5 @@
- -
I confirm the Quotation with "Deliver & invoice on demand". I confirm the Quotation with "On Demand" order policy.
- -
!workflow {model: sale.order, action: order_confirm, ref: sale_order_2} !workflow {model: sale.order, action: order_confirm, ref: sale_order_2}
- -
@ -9,7 +9,7 @@
sale_order = self.browse(cr, uid, ref("sale_order_2")) sale_order = self.browse(cr, uid, ref("sale_order_2"))
assert len(sale_order.invoice_ids) == False, "Invoice should not created." assert len(sale_order.invoice_ids) == False, "Invoice should not created."
- -
I create advance invoice. I create advance invoice where type is 'Fixed Price'.
- -
!python {model: sale.advance.payment.inv}: | !python {model: sale.advance.payment.inv}: |
ctx = context.copy() ctx = context.copy()
@ -24,7 +24,7 @@
order = self.browse(cr, uid, ref('sale_order_2')) order = self.browse(cr, uid, ref('sale_order_2'))
assert order.invoice_ids, "Invoice should be created after make advance invoice." assert order.invoice_ids, "Invoice should be created after make advance invoice."
- -
I create advance invoice where payment method is 'all'. I create advance invoice where type is 'Invoice all the Sale Order'.
- -
!python {model: sale.advance.payment.inv}: | !python {model: sale.advance.payment.inv}: |
ctx = context.copy() ctx = context.copy()
@ -32,11 +32,11 @@
pay_id = self.create(cr, uid, {'advance_payment_method': 'all'}) pay_id = self.create(cr, uid, {'advance_payment_method': 'all'})
self.create_invoices(cr, uid, [pay_id], context=ctx) self.create_invoices(cr, uid, [pay_id], context=ctx)
- -
I check Invoice which made advance where payment method is 'all'. I check Invoice which made advance where type is 'Invoice all the Sale Order'.
- -
!python {model: sale.order}: | !python {model: sale.order}: |
order = self.browse(cr, uid, ref('sale_order_2')) order = self.browse(cr, uid, ref('sale_order_2'))
assert order.invoice_ids, "Invoice should be created after make advance invoice where payment method is 'all'." assert order.invoice_ids, "Invoice should be created after make advance invoice where type is 'Invoice all the Sale Order'."
- -
I open the Invoice. I open the Invoice.
- -
@ -47,7 +47,7 @@
for invoice in so.invoice_ids: for invoice in so.invoice_ids:
wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr) wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
- -
I pay the invoice I pay the invoice.
- -
!python {model: account.invoice}: | !python {model: account.invoice}: |
sale_order = self.pool.get('sale.order') sale_order = self.pool.get('sale.order')
@ -65,7 +65,8 @@
!python {model: sale.order}: | !python {model: sale.order}: |
sale_order = self.browse(cr, uid, ref("sale_order_2")) sale_order = self.browse(cr, uid, ref("sale_order_2"))
assert sale_order.invoice_ids, "Invoice should be created." assert sale_order.invoice_ids, "Invoice should be created."
assert sale_order.invoiced, "Order is not invoiced." assert sale_order.invoice_exists, "Order is not invoiced."
assert sale_order.invoiced, "Order is not paid."
assert sale_order.state == 'progress', 'Order should be in Progress.' assert sale_order.state == 'progress', 'Order should be in Progress.'
- -