[IMP] sale: update some statements in yml & clear unwanted code in sale.py file.
authorAjay Chauhan (OpenERP) <cha@tinyerp.com>
Wed, 12 Sep 2012 09:10:40 +0000 (14:40 +0530)
committerAjay Chauhan (OpenERP) <cha@tinyerp.com>
Wed, 12 Sep 2012 09:10:40 +0000 (14:40 +0530)
bzr revid: cha@tinyerp.com-20120912091040-yezbspjjucempq2e

addons/sale/sale.py
addons/sale/test/manual_order_policy.yml

index f86d572..04523e8 100644 (file)
@@ -145,13 +145,6 @@ class sale_order(osv.osv):
                 res[sale.id] = 0.0
         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):
         res = {}
         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.
         '''
         mod_obj = self.pool.get('ir.model.data')
-        act_obj = self.pool.get('ir.actions.act_window')
-
-        result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1')
-        id = result and result[1] or False
-        result = act_obj.read(cr, uid, [id], context=context)[0]
+        result = {
+            'name': _('Cutomer Invoice'),
+            'view_type': 'form',
+            'res_model': 'account.invoice',
+            'context': "{'type':'out_invoice', 'journal_type': 'sale'}",
+            'type': 'ir.actions.act_window',
+            'nodestroy': True,
+            'target': 'current',
+        }
         #compute the number of invoices to display
         inv_ids = []
         for so in self.browse(cr, uid, ids, context=context):
             inv_ids += [invoice.id for invoice in so.invoice_ids]
         #choose the view_mode accordingly
-        if len(inv_ids) > 1:
-            result['domain'] = "[('id','in',["+','.join(map(str, inv_ids))+"])]"
+        if len(inv_ids)>1:
+            res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree')
+            result.update({
+                'view_mode': 'tree,form',
+                'res_id': inv_ids or False
+            })
         else:
             res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
-            result['views'] = [(res and res[1] or False, 'form')]
-            result['res_id'] = inv_ids and inv_ids[0] or False
+            result.update({
+                '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
 
-
     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.
index d67677c..17ebeb9 100644 (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}
 -
@@ -9,7 +9,7 @@
     sale_order = self.browse(cr, uid, ref("sale_order_2"))
     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}: |
     ctx = context.copy()
@@ -24,7 +24,7 @@
     order = self.browse(cr, uid, ref('sale_order_2'))
     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}: |
     ctx = context.copy()
     pay_id = self.create(cr, uid, {'advance_payment_method': 'all'})
     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}: |
     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.
 -
@@ -47,7 +47,7 @@
     for invoice in so.invoice_ids:
       wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
 -
-  I pay the invoice
+  I pay the invoice.
 -
   !python {model: account.invoice}: |
     sale_order = self.pool.get('sale.order')
@@ -65,7 +65,8 @@
   !python {model: sale.order}: |
     sale_order = self.browse(cr, uid, ref("sale_order_2"))
     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.'
     
 -