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.

28 lines
2.0 KiB

6 years ago
  1. from odoo import models, fields, api
  2. #Main Agreement clause Records Model
  3. class AgreementClause(models.Model):
  4. _name = 'partner_agreement.clause'
  5. _order = 'clause_sequence'
  6. #General
  7. name = fields.Char(string="Title", required=True)
  8. clause_sequence = fields.Integer(string="Sequence")
  9. agreement = fields.Many2one('partner_agreement.agreement', string="Agreement", ondelete="cascade")
  10. section = fields.Many2one('partner_agreement.section', string="Section", ondelete="cascade")
  11. content = fields.Html(string="Clause Content")
  12. active = fields.Boolean(string="Active", default=True, help="If unchecked, it will allow you to hide the agreement without removing it.")
  13. #Placeholder fields
  14. model_id = fields.Many2one('ir.model', string="Applies to", help="The type of document this template can be used with.")
  15. model_object_field = fields.Many2one('ir.model.fields', string="Field", help="Select target field from the related document model. If it is a relationship field you will be able to select a target field at the destination of the relationship.")
  16. sub_object = fields.Many2one('ir.model', string="Sub-model", help="When a relationship field is selected as first field, this field shows the document model the relationship goes to.")
  17. sub_model_object_field = fields.Many2one('ir.model.fields', string="Sub-field", help="When a relationship field is selected as first field, this field lets you select the target field within the destination document model (sub-model).")
  18. null_value = fields.Char(string="Default Value", help="Optional value to use if the target field is empty.")
  19. copyvalue = fields.Char(string="Placeholder Expression", help="Final placeholder expression, to be copy-pasted in the desired template field.")
  20. @api.model
  21. def create(self, vals):
  22. seq = self.env['ir.sequence'].next_by_code('agreement.clause') or '/'
  23. vals['clause_sequence'] = seq
  24. return super(AgreementClause, self).create(vals)