Skip to Content
Menú
This question has been flagged
3072 Vistes

Hi all,

I have two classes in the models.py file to extend two different model. The first class is working fine, the second one is not working and the sql constraint are not applied.

followin the code:

# -*- coding: utf-8 -*-
from odoo import models, fields, api
# class custom_accounting_mgmt(models.Model):
# _name = 'custom_accounting_mgmt.custom_accounting_mgmt'
# name = fields.Char()
# value = fields.Integer()
# value2 = fields.Float(compute="_value_pc", store=True)
# description = fields.Text()
#
# @api.depends('value')
# def _value_pc(self):
# self.value2 = float(self.value) / 100
class Partner(models.Model):
_inherit = 'res.partner'
_sql_constraints = [
('vat_unique',
'UNIQUE(name, vat)',
"Attenzione!!! la Partita deve essere univoca, esiste già un altro cliente con lo stesso nome e la stessa partita iva."),
('x_fiscal_code_unique',
'UNIQUE(x_fiscal_code)',
"Attenzione!!! Esiste già un altro cliente con lo stesso Codice Fiscale."),
]
class Product(models.Model):
_inherit = 'product.template'
_sql_constraints = [
('x_rfid',
'UNIQUE(x_rfid)',
"Attenzione!!! l'rfid deve essere univoco, esiste già un altro prodotto con lo stesso rfid."),
('default_code',
'UNIQUE(default_code)',
"Attenzione!!! Esiste già un altro prodotto con lo stesso riferimento interno."),
]

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de jul. 24
13552
1
de jul. 21
7608
0
d’abr. 20
4375
1
de maig 18
2629
4
de març 25
3451