İçereği Atla
Menü
Bu soru işaretlendi
3149 Görünümler

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Tem 24
13568
1
Tem 21
7651
0
Nis 20
4400
1
May 18
2667
4
Mar 25
3472