You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.5 KiB

  1. -
  2. In order to test Contract Recurrent Invoice I create a new Contract with 25% discount
  3. -
  4. !record {model: account.analytic.account, id: contract_main_25}:
  5. name: Maintenance of Servers
  6. company_id: base.main_company
  7. partner_id: base.main_partner
  8. type: contract
  9. recurring_invoices : 1
  10. recurring_interval : 1
  11. recurring_invoice_line_ids:
  12. - quantity: 2.0
  13. price_unit: 100.0
  14. discount: 25.0
  15. name: Database Administration 25
  16. product_id: product.product_product_consultant
  17. uom_id: product.product_uom_hour
  18. - quantity: 2.0
  19. price_unit: 100.0
  20. discount: 50.0
  21. name: Database Administration 50
  22. product_id: product.product_product_consultant
  23. uom_id: product.product_uom_hour
  24. -
  25. I test the contract
  26. -
  27. !python {model: account.analytic.account}: |
  28. aid = ref('contract_discount.contract_main_25')
  29. contract = self.browse(cr, uid, aid,context=context)
  30. assert contract.recurring_invoice_line_ids[0].discount == 25, "The line discount (%s)is different than 25!"%(contract.recurring_invoice_line_ids[0].discount,)
  31. assert contract.recurring_invoice_line_ids[0].price_subtotal == 150.0, "The price subtotal (%s)is different than 150!"%(contract.recurring_invoice_line_ids[0].price_subtotal,)
  32. assert contract.recurring_invoice_line_ids[1].discount == 50, "The line discount (%s)is different than 50!"%(contract.recurring_invoice_line_ids[1].discount,)
  33. assert contract.recurring_invoice_line_ids[1].price_subtotal == 100, "The price subtotal (%s)is different than 100!"%(contract.recurring_invoice_line_ids[1].price_subtotal,)
  34. -
  35. I generate all invoices from contracts having recurring invoicing
  36. -
  37. !python {model: account.analytic.account}: |
  38. self.recurring_create_invoice(cr, uid, [])
  39. -
  40. I test the generated invoice
  41. -
  42. !python {model: account.invoice}: |
  43. aid = ref('contract_discount.contract_main_25')
  44. ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
  45. assert len(ids)>=1, 'No invoice created for the contract'
  46. for invoice in self.browse(cr, uid, ids,context=context):
  47. assert invoice.invoice_line[0].discount == 25, "The invoice discount (%s)is different than 25!"%(invoice.invoice_line[0].discount,)
  48. assert invoice.invoice_line[1].discount == 50, "The invoice discount (%s)is different than 50!"%(invoice.invoice_line[1].discount,)
  49. assert invoice.amount_untaxed == 250.0, "The invoice total (%s)is different than 250!"%(invoice.amount_untaxed,)