Hi community , its so urgent Plz
I had add a boolean field in 'product.product' named 'is_dmp'. so , i want that if I try to add an artcile who have this field false in purchase order , a warning message appear .
so this what i did :
--------------------------------------------------------------------------------------------------------------------------
from odoo import api, models
from odoo import fields
from odoo.exceptions import UserError
class product_product(models.Model):
_name = 'product.product'
_inherit = 'product.product'
is_dmp = fields.Boolean(help='Est ce que cet articles doit avoir un certificat d enregistrement', string='Necessite un enregistrement')
dmp = fields.Char('Numéro de certificat')
# purchase_ok = fields.Boolean(compute='_check_dmp'),
class PurchaseOrderLineWar(models.Model):
_name = "product.product"
_inherit = "product.product"
@api.onchange('dmp')
def _check_dmp(self):
if self.is_dmp == False:
warning_mess = {
'title': _('Warnnnnning'),
'message' : _('Attention cet article ne necessite pas un certifact DMP'),
}
return {'warning': warning_mess}
-----------------------------------------------------------------------------------------------------------------------
Plz any idea , i need help .
Do you want to show warning when user selects a product in purchase order line?
Now its work , thank you