Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2954 Tampilan

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Jul 24
13293
1
Jul 21
7356
0
Apr 20
4124
1
Mei 18
2517
4
Mar 25
3288