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 verification by users.
Ex: Customer send a request with field's values as follow:
Name: "Peterrrrrrrrrr"
LastName: "Smith"
Age: 150
An employee user would be able to inform to the customer about the wrong values as follows:
Name: State=Invalid, Comment="Probably Typo error"
LastName: State=Valid
Age: State=Invalid, Comment="Confirm real age"
It's not a feature about value validation (odoo.api.constrains(*args)), but about manual values verification by an user (abcde 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
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 verification
name_verification = fields.Selection([
('valid', 'Valid'),
('invalid', 'Invalid'),
('notverified', 'Not verified')
], default="notverified")
name_verification_comment = fields.Text()
But this is not a good approach because the need of implementing the 'field_value_verification' for each field and each model which need the verification feature. So I thought to store the 'field_value_verification' in the 'FieldsVerification' 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_verification_ids = ???
class FieldsVerification(models.Model):
_name = 'test.fields_verification'
_description = "Verification"
class_name = fields.Char(strng="Class")
record_id = ???
field_name = fields.Char(string="Field")
status = fields .Selection([
('valid', 'Valid'),
('invalid', 'Invalid'),
('notverified', 'Not verified')
], default="notverified")
Just right here I got stuck, so I thought to ask to the community. Thanks in advance