I have this odoo py
class CrmProject(models.Model): _name='crm.project' customer_id = fields.Many2one('res.partner','Customer') project_product_id = fields.Many2one('crm.project.product','Project Product') how to validate and show a warning when the customer_id and project_product_id are inputted together with the same value as the one in the crm.project database? so it must be checked with the database first then show warning if it have the same value with the one in customer_id AND project_product_id input.
For example:
Database table crm.project customer_id = 1 project_product_id = 2 Will create warning ONLY if input:
customer_id = 1 project_product_id = 2 Beside that no warning will be create
I have tried this but no warning created:
@api.model def validate(self,vals): # Add code here res= super(ClassName,self).validate(vals) customer_id = vals.get('customer_id') project_product_id = vals.get('project_product_id') get_customer_id = self.env['customer_id'].search([('customer_id','=',customer_id)]) get_project_product_id = self.env['project_product_id'].search([('project_product_id','=',project_product_id)]) if get_customer_id and get_project_product_id: raise UserError(_('The project has already been set before')) else: return res Any help will be grateful
https://stackoverflow.com/questions/67188814/odoo-add-validation-for-double-field April 21, 2021 at 11:08AM
没有评论:
发表评论