Odoo 12 CE
Class Diagram:
,-------------------.
| question_request |
|-------------------|
| +Char Name |
| +Char LastName |
| +Integer Age |
| +Text Description |
|-------------------|
`-------------------'
Code
from odoo import models, fields, api
class Request(models.Model):
_name = 'test.request'
_description = "Request"
name = fields.Char(string="Name", required=True)
last_name = fields.Char(string="Last Name", required=True)
age = fields.Integer(string="Age", required=True)
description = fields.Text()
Goal:
Feature for field's value manual validations by users.
Ex: Customer send a request with fiel's values as follow:
Name: "Peterrrrrrrrrr"
LastName: "Smith"
Age: 150
It's not a feature about value validation ( odoo.api.constrains(*args) ), but about manual values verification by an user ("Peterrrrrr" is a valid value for the 'name' field, but an user need to confirm or verify that).
The first idea was to use an extra field for verification and another extra field for the comment
Name: State=Invalid, Comment="Typo error"
LastName: State=Valid
Age: State:Invalid, Comment="Confirm real age"
The first idea was to use an extra field for validation and another extra field for the comment
from odoo import models, fields, api
class Request(models.Model):
_name = 'test.request'
_description = "Request"
name = fields.Char(string="Name", required=True)
last_name = fields.Char(string="Last Name", required=True)
age = fields.Integer(string="Age", required=True)
description = fields.Text()
# fields for validation
name_valid = fields.Selection([
('valid', 'Valid'),
('invalid', 'Invalid'),
('unvalidated', 'Unvalidated')
], default="unvalidated")
name_valid_comment = fields.Text()
But this is not a good aproach because the need of implmenting the 'field_value_validation' for each field and each model wich need the validation feature
So i thing to store the 'field_value_validation' in the 'FieldsValidation' related model as follows:
from odoo import models, fields, api
class Request(models.Model):
_name = 'test.request'
_description = "Request"
name = fields.Char(string="Name", required=True)
last_name = fields.Char(string="Last Name", required=True)
age = fields.Integer(string="Age", required=True)
description = fields.Text()
fueld_validation_ids = ???
class FieldsValidation(models.Model):
_name = 'test.fields_validation'
_description = "Validation"
class_name = fields.Char(strng="Class")
record_id = ???
field_name = fields.Char(string="Field")
status = fields .Selection([
('valid', 'Valid'),
('invalid', 'Invalid'),
('unvalidated', 'Unvalidated')
], default="unvalidated")
Just right here i got stuck, so i thought to ask to the community.
Thanks in advance