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.

68 lines
2.4 KiB

  1. -
  2. In order to test mandates in contracts, create a partner with a bank account.
  3. Then, create two mandates, and validate them.
  4. Finally, create a contract with mandate2, create a recurring invoice and
  5. check that the invoice has set the contract mandate (mandate2).
  6. Create a partner
  7. -
  8. !record {model: res.partner, id: test_partner, view: False}:
  9. name: "Contract mandate test"
  10. -
  11. Create a partner bank account
  12. -
  13. !record {model: res.partner.bank, id: test_partner_bank, view: False}:
  14. state: 'bank'
  15. acc_number: '1234'
  16. partner_id: test_partner
  17. -
  18. Create mandate1 on 1st January
  19. -
  20. !record {model: account.banking.mandate, id: test_mandate1, view: False}:
  21. partner_bank_id: test_partner_bank
  22. signature_date: "2014-01-01"
  23. -
  24. Create mandate2 on 15th February
  25. -
  26. !record {model: account.banking.mandate, id: test_mandate2, view: False}:
  27. partner_bank_id: test_partner_bank
  28. signature_date: "2015-02-15"
  29. -
  30. Validate both mandates
  31. -
  32. !python {model: account.banking.mandate}: |
  33. self.validate(cr, uid, [ref('test_mandate1')])
  34. self.validate(cr, uid, [ref('test_mandate2')])
  35. -
  36. Create new contract with a mandate2
  37. -
  38. !record {model: account.analytic.account, id: test_contract}:
  39. name: Recurring with mandate
  40. company_id: base.main_company
  41. partner_id: base.main_partner
  42. type: contract
  43. recurring_invoices : 1
  44. recurring_interval : 1
  45. recurring_rule_type: 'monthly'
  46. recurring_next_date: '2016-02-29'
  47. recurring_invoice_line_ids:
  48. - quantity: 2.0
  49. price_unit: 100.0
  50. name: Database Administration 25
  51. product_id: product.product_product_consultant
  52. uom_id: product.product_uom_hour
  53. mandate_id: test_mandate2
  54. -
  55. Generate all invoices from contracts having recurring invoicing
  56. -
  57. !python {model: account.analytic.account}: |
  58. self.recurring_create_invoice(cr, uid, [])
  59. -
  60. Check created invoice has mandate2
  61. -
  62. !python {model: account.invoice}: |
  63. aid = ref('test_contract')
  64. ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
  65. assert len(ids) == 1, "Expected exactly one invoice created for the contract, got %d"%(len(ids))
  66. for invoice in self.browse(cr, uid, ids,context=context):
  67. assert invoice.mandate_id.id == ref('test_mandate2'), "Recurring invoice has mandate id %d, but should have mandate id %d"%(invoice.mandate_id.id, ref('test_mandate2'))