تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2955 أدوات العرض

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."),
]

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 24
13293
1
يوليو 21
7356
0
أبريل 20
4125
1
مايو 18
2517
4
مارس 25
3288