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.

83 lines
3.3 KiB

  1. -
  2. In order to test contract invoice journal create a contract with sale invoice journal
  3. -
  4. !record {model: account.analytic.account, id: contract_sale_journal}:
  5. name: Maintenance of Servers
  6. company_id: base.main_company
  7. partner_id: base.main_partner
  8. journal_id: account.sales_journal
  9. type: contract
  10. recurring_invoices : 1
  11. recurring_interval : 1
  12. recurring_invoice_line_ids:
  13. - quantity: 2.0
  14. price_unit: 100.0
  15. name: Database Administration 25
  16. product_id: product.product_product_consultant
  17. uom_id: product.product_uom_hour
  18. -
  19. I create a new custom journal
  20. -
  21. !record {model: account.journal, id: custom_journal}:
  22. name: Custom Sales Journal
  23. code: CSAJ
  24. type: sale
  25. sequence_id: account.sequence_sale_journal
  26. default_credit_account_id: account.a_sale
  27. default_debit_account_id: account.a_sale
  28. analytic_journal_id: account.analytic_journal_sale
  29. user_id: base.user_root
  30. -
  31. Create a contract with custom invoice journal
  32. -
  33. !record {model: account.analytic.account, id: contract_custom_journal}:
  34. name: Maintenance of Servers
  35. company_id: base.main_company
  36. partner_id: base.main_partner
  37. journal_id: contract_journal.custom_journal
  38. type: contract
  39. recurring_invoices : 1
  40. recurring_interval : 1
  41. recurring_invoice_line_ids:
  42. - quantity: 2.0
  43. price_unit: 100.0
  44. name: Database Administration 25
  45. product_id: product.product_product_consultant
  46. uom_id: product.product_uom_hour
  47. -
  48. I test the sale contract
  49. -
  50. !python {model: account.analytic.account}: |
  51. aid = ref('contract_journal.contract_sale_journal')
  52. contract = self.browse(cr, uid, aid,context=context)
  53. assert contract.journal_id.id == ref('account.sales_journal'), "Sale Invoice Journal is not correct in contract"
  54. -
  55. I test the custom contract
  56. -
  57. !python {model: account.analytic.account}: |
  58. aid = ref('contract_journal.contract_custom_journal')
  59. contract = self.browse(cr, uid, aid,context=context)
  60. assert contract.journal_id.id == ref('contract_journal.custom_journal'), "Custom Invoice Journal is not correct in contract"
  61. -
  62. I generate all invoices from contracts having recurring invoicing
  63. -
  64. !python {model: account.analytic.account}: |
  65. self.recurring_create_invoice(cr, uid, [])
  66. -
  67. I test the generated invoice for sale journal contract
  68. -
  69. !python {model: account.invoice}: |
  70. aid = ref('contract_journal.contract_sale_journal')
  71. ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
  72. assert len(ids)>=1, 'No invoice created for the sale journal contract'
  73. for invoice in self.browse(cr, uid, ids,context=context):
  74. assert invoice.journal_id.id == ref('account.sales_journal'), "Sale Invoice Journal is not correct in invoice"
  75. -
  76. I test the generated invoice for custom journal contract
  77. -
  78. !python {model: account.invoice}: |
  79. aid = ref('contract_journal.contract_custom_journal')
  80. ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
  81. assert len(ids)>=1, 'No invoice created for the custom journal contract'
  82. for invoice in self.browse(cr, uid, ids,context=context):
  83. assert invoice.journal_id.id == ref('contract_journal.custom_journal'), "Custom Invoice Journal is not correct in invoice"