common.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo.addons.sale.tests.common import TestSaleCommon
  4. class TestSaleProjectCommon(TestSaleCommon):
  5. @classmethod
  6. def setUpClass(cls, chart_template_ref=None):
  7. super().setUpClass(chart_template_ref=chart_template_ref)
  8. cls.env['res.config.settings'] \
  9. .create({'group_project_milestone': True}) \
  10. .execute()
  11. cls.uom_hour = cls.env.ref('uom.product_uom_hour')
  12. cls.account_sale = cls.company_data['default_account_revenue']
  13. cls.analytic_plan = cls.env['account.analytic.plan'].create({
  14. 'name': 'Plan Test',
  15. 'company_id': cls.company_data['company'].id,
  16. })
  17. cls.analytic_account_sale = cls.env['account.analytic.account'].create({
  18. 'name': 'Project for selling timesheet - AA',
  19. 'code': 'AA-2030',
  20. 'plan_id': cls.analytic_plan.id,
  21. 'company_id': cls.company_data['company'].id,
  22. })
  23. Project = cls.env['project.project'].with_context(tracking_disable=True)
  24. cls.project_global = Project.create({
  25. 'name': 'Project Global',
  26. 'analytic_account_id': cls.analytic_account_sale.id,
  27. 'allow_billable': True,
  28. })
  29. cls.project_template = Project.create({
  30. 'name': 'Project TEMPLATE for services',
  31. })
  32. cls.project_template_state = cls.env['project.task.type'].create({
  33. 'name': 'Only stage in project template',
  34. 'sequence': 1,
  35. 'project_ids': [(4, cls.project_template.id)]
  36. })
  37. # -- manual (delivered, manual)
  38. cls.product_delivery_manual1 = cls.env['product.product'].create({
  39. 'name': "Service delivered, create no task",
  40. 'standard_price': 11,
  41. 'list_price': 13,
  42. 'type': 'service',
  43. 'invoice_policy': 'delivery',
  44. 'uom_id': cls.uom_hour.id,
  45. 'uom_po_id': cls.uom_hour.id,
  46. 'default_code': 'SERV-DELI1',
  47. 'service_type': 'manual',
  48. 'service_tracking': 'no',
  49. 'project_id': False,
  50. 'taxes_id': False,
  51. 'property_account_income_id': cls.account_sale.id,
  52. })
  53. cls.product_delivery_manual2 = cls.env['product.product'].create({
  54. 'name': "Service delivered, create task in global project",
  55. 'standard_price': 30,
  56. 'list_price': 90,
  57. 'type': 'service',
  58. 'invoice_policy': 'delivery',
  59. 'uom_id': cls.uom_hour.id,
  60. 'uom_po_id': cls.uom_hour.id,
  61. 'default_code': 'SERV-DELI2',
  62. 'service_type': 'manual',
  63. 'service_tracking': 'task_global_project',
  64. 'project_id': cls.project_global.id,
  65. 'taxes_id': False,
  66. 'property_account_income_id': cls.account_sale.id,
  67. })
  68. cls.product_delivery_manual3 = cls.env['product.product'].create({
  69. 'name': "Service delivered, create task in new project",
  70. 'standard_price': 10,
  71. 'list_price': 20,
  72. 'type': 'service',
  73. 'invoice_policy': 'delivery',
  74. 'uom_id': cls.uom_hour.id,
  75. 'uom_po_id': cls.uom_hour.id,
  76. 'default_code': 'SERV-DELI3',
  77. 'service_type': 'manual',
  78. 'service_tracking': 'task_in_project',
  79. 'project_id': False, # will create a project
  80. 'taxes_id': False,
  81. 'property_account_income_id': cls.account_sale.id,
  82. })
  83. cls.product_delivery_manual4 = cls.env['product.product'].create({
  84. 'name': "Service delivered, create project only",
  85. 'standard_price': 15,
  86. 'list_price': 30,
  87. 'type': 'service',
  88. 'invoice_policy': 'delivery',
  89. 'uom_id': cls.uom_hour.id,
  90. 'uom_po_id': cls.uom_hour.id,
  91. 'default_code': 'SERV-DELI4',
  92. 'service_type': 'manual',
  93. 'service_tracking': 'project_only',
  94. 'project_id': False,
  95. 'taxes_id': False,
  96. 'property_account_income_id': cls.account_sale.id,
  97. })
  98. cls.product_delivery_manual5 = cls.env['product.product'].create({
  99. 'name': "Service delivered, create project only with template",
  100. 'standard_price': 17,
  101. 'list_price': 34,
  102. 'type': 'service',
  103. 'invoice_policy': 'delivery',
  104. 'uom_id': cls.uom_hour.id,
  105. 'uom_po_id': cls.uom_hour.id,
  106. 'default_code': 'SERV-DELI4',
  107. 'service_type': 'manual',
  108. 'service_tracking': 'project_only',
  109. 'project_id': False,
  110. 'project_template_id': cls.project_template.id,
  111. 'taxes_id': False,
  112. 'property_account_income_id': cls.account_sale.id,
  113. })
  114. # -- devliered_milestones (delivered, milestones)
  115. product_milestone_vals = {
  116. 'type': 'service',
  117. 'invoice_policy': 'delivery',
  118. 'uom_id': cls.uom_hour.id,
  119. 'uom_po_id': cls.uom_hour.id,
  120. 'default_code': 'SERV-MILES',
  121. 'service_type': 'milestones',
  122. 'service_tracking': 'no',
  123. 'property_account_income_id': cls.account_sale.id,
  124. }
  125. cls.product_milestone, cls.product_milestone2 = cls.env['product.product'].create([
  126. {**product_milestone_vals, 'name': 'Milestone Product', 'list_price': 20},
  127. {**product_milestone_vals, 'name': 'Milestone Product 2', 'list_price': 15},
  128. ])
  129. def set_project_milestone_feature(self, value):
  130. self.env['res.config.settings'] \
  131. .create({'group_project_milestone': value}) \
  132. .execute()