Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Python Constraints & Model Constraints in Odoo 15

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 12 Anuncio

Python Constraints & Model Constraints in Odoo 15

Descargar para leer sin conexión

Odoo helps you to set constraints to variants which we can perform using python and model constraints. In odoo python constraints are specified along with methods. This Slide will provide an insight on python and model constraints in Odoo 15. In python, constraints are defined along with a method decorated with constraints().

Odoo helps you to set constraints to variants which we can perform using python and model constraints. In odoo python constraints are specified along with methods. This Slide will provide an insight on python and model constraints in Odoo 15. In python, constraints are defined along with a method decorated with constraints().

Anuncio
Anuncio

Más Contenido Relacionado

Similares a Python Constraints & Model Constraints in Odoo 15 (20)

Más de Celine George (20)

Anuncio

Más reciente (20)

Python Constraints & Model Constraints in Odoo 15

  1. 1. Model Constraints & Python Constraints in Odoo 15 www.cybrosys.com
  2. 2. INTRODUCTION  Odoo helps you to set constraints to variants which we can perform using python and model constraints. In odoo python constraints are specified along with methods.  This Slide will provide an insight on python and model constraints in Odoo 15.  In python, constraints are defined along with a method decorated with constraints().
  3. 3. Python Constraints Add a constraint while saving a record you can use the following code which restricts the user from entering a negative value for the amount.
  4. 4.  The field for which constraint is to be applied is specified along with the decorator constraints().  provide multiple field values as arguments in the function. Therefore, the function gets invoked each time the value in the field gets modified/changed
  5. 5. @api.constrains(field1, field2) def _check_values(self): for record in self: if record.field1 == record.field2: raise ValidationError("Fields field1 and field2 must be not be same") Example code
  6. 6. There are certain limitations for using constraints() 1. constrains() are not supported along with related fields. They can only be applied to simple fields. For example related fields like partner_id.phone. 2. constrains() can only be applied to fields that are included in the create and write call because if the field is which is not contained in the view will not trigger a call to python function.
  7. 7. SQL constraints  The SQL constraints are applied on models using _sql_constraints.  In odoo _sql_constraints consist of three parts they are name, definition, and message.
  8. 8.  name - Name for the sql constraint  definition - Constraint to be applied on the table.  message - Validation message to be displayed.
  9. 9. Unique Constraint: It is used along with a ‘unique’ keyword. The unique constraint helps you to check whether a specified column in rows satisfies the unique constraint.
  10. 10. For More Details Check our company website for related blogs and Odoo book. Odoo Book V15 Check our YouTube channel for functional and technical videos in Odoo. Model Constraints & Python Constraints in Odoo15
  11. 11. Thank You

×