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.

80 lines
2.5 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. # Copyright (C) 2018 - TODAY, Pavlov Media
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import models, fields, api
  4. # Main Agreement clause Records Model
  5. class AgreementClause(models.Model):
  6. _name = 'agreement.clause'
  7. _order = 'clause_sequence'
  8. # General
  9. name = fields.Char(
  10. string="Title",
  11. required=True
  12. )
  13. clause_sequence = fields.Integer(
  14. string="Sequence"
  15. )
  16. agreement_id = fields.Many2one(
  17. 'agreement',
  18. string="Agreement",
  19. ondelete="cascade"
  20. )
  21. section_id = fields.Many2one(
  22. 'agreement.section',
  23. string="Section",
  24. ondelete="cascade"
  25. )
  26. content = fields.Html(
  27. string="Clause Content"
  28. )
  29. active = fields.Boolean(
  30. string="Active",
  31. default=True,
  32. help="If unchecked, it will allow you to hide the agreement without "
  33. "removing it."
  34. )
  35. # Placeholder fields
  36. model_id = fields.Many2one(
  37. 'ir.model',
  38. string="Applies to",
  39. help="The type of document this template can be used with."
  40. )
  41. model_object_field_id = fields.Many2one(
  42. 'ir.model.fields',
  43. string="Field",
  44. help="Select target field from the related document model. If it is a "
  45. "relationship field you will be able to select a target field at "
  46. "the destination of the relationship."
  47. )
  48. sub_object_id = fields.Many2one(
  49. 'ir.model',
  50. string="Sub-model",
  51. help="When a relationship field is selected as first field, this "
  52. "field shows the document model the relationship goes to."
  53. )
  54. sub_model_object_field_id = fields.Many2one(
  55. 'ir.model.fields',
  56. string="Sub-field",
  57. help="When a relationship field is selected as first field, this "
  58. "field lets you select the target field within the destination "
  59. "document model (sub-model)."
  60. )
  61. null_value = fields.Char(
  62. string="Default Value",
  63. help="Optional value to use if the target field is empty."
  64. )
  65. copyvalue = fields.Char(
  66. string="Placeholder Expression",
  67. help="Final placeholder expression, to be copy-pasted in the desired "
  68. "template field."
  69. )
  70. @api.model
  71. def create(self, vals):
  72. seq = self.env['ir.sequence'].next_by_code('agreement.clause') or '/'
  73. vals['clause_sequence'] = seq
  74. return super(AgreementClause, self).create(vals)