Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3087 Widoki

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lip 24
13557
1
lip 21
7619
0
kwi 20
4387
1
maj 18
2630
4
mar 25
3454