| 1 | from odoo import _, api, fields, models |
| 2 | |
| 3 | from odoo.exceptions import ValidationError |
| 4 | |
| 5 | |
| 6 | class ProductProduct(models.Model): |
| 7 | _inherit = "product.product" |
| 8 | |
| 9 | l10n_tr_ctsp_number = fields.Char(string="CTSP Number", copy=False, index="btree_not_null") |
| 10 | |
| 11 | @api.constrains("l10n_tr_ctsp_number") |
| 12 | def _check_l10n_tr_ctsp_number(self): |
| 13 | for record in self: |
| 14 | if record.l10n_tr_ctsp_number and len(record.l10n_tr_ctsp_number) > 12: |
| 15 | raise ValidationError(_("CTSP Number must be 12 digits or fewer.")) |