48.Model Constraints || Python Constrains in Odoo || Constrains Decorator In Odoo || api.constrains

Поделиться
HTML-код
  • Опубликовано: 1 авг 2024
  • Constrains decorator in Odoo can be used to force some criteria's to satisfy before creating and editing the record. Ensure data before saving the record. Working of api.constrains in Odoo. Working of constrains decorator in Odoo. Odoo ORM. Odoo 14 development videos. Odoo 14 development tutorials.
    Odoo 14 Playlist: • 2. How To Create Modul...
    Module: apps.odoo.com/apps/modules/14...
    Website: www.odoomates.tech/
    Github: github.com/odoomates
    Email : odoomates@gmail.com
    Facebook: / odoomate
    Twitter: / odoomates
    Support Us in Ko Fi : ko-fi.com/odoomates
  • НаукаНаука

Комментарии • 27

  • @bonjourmonde1500
    @bonjourmonde1500 2 года назад +1

    .. my encouragements for u..keep going ..

    • @OdooMates
      @OdooMates  2 года назад +1

      ❤️❤️❤️

  • @nadeemkazi2092
    @nadeemkazi2092 3 года назад

    Thanks champ..

  • @johnurena2863
    @johnurena2863 Год назад

    Can i use something similar to pre process my data? like, changing the name, like windows when you try to save a file with the same name for example: filename, if you write "filename" then windows is gonna save "filename(1)"

  • @futhedude4848
    @futhedude4848 2 года назад +1

    Hi, I don't understand about the part that function check_name() that search([('name','=',rec.name),('id','!=',rec.id)])
    Should it be enough with ('name','=',rec.name)? When i check with actual code, search([('name','=',rec.name),('id','!=',rec.id)]) work, but ('name','=',rec.name) didn't.
    Can you explain this part please? Thanks you sir.

    • @futhedude4848
      @futhedude4848 2 года назад +1

      Oh i get it, it's because when in constrain, we have to ignore the current record, or else, it will always return the record.
      This only happen in constrain.

    • @OdooMates
      @OdooMates  2 года назад

      @@futhedude4848 yes you got it

  • @Hahayougotbann
    @Hahayougotbann 2 года назад +1

    i have 2 modules that are connected in many2many. One is inventory, the other is employees. How do I make it that 1 employee can have many items from inventory, but 1 item can only be used by 1 person at a time. Thanks

    • @OdooMates
      @OdooMates  2 года назад

      by using this contrains itself, you can achieve this, add constrains for the field, then using search orm, check record is having another relation, then show message

  • @ntcuong01ct1
    @ntcuong01ct1 3 года назад +1

    Can I apply to Odoo v12, v13?

  • @futhedude4848
    @futhedude4848 2 года назад +1

    Hi sir, i've a problem that i made a field called "doctor_id" and many2one to res.users. Then use constrain on that field to check if doctor_id is already exists.
    But now, the constrain trigger every action i do in doctor model, such as go back to doctors list. How to ignore that, and only trigger the constrain in "save" action?
    Thanks.

    • @OdooMates
      @OdooMates  2 года назад

      can i see the added code

    • @futhedude4848
      @futhedude4848 2 года назад +1

      @@OdooMates for some reason, my github link are removed automatic, even when i post it without the link format. Do you have any idea on how i can post my code here?

    • @futhedude4848
      @futhedude4848 2 года назад +1

      Sir, please check facebook, i've send you the github link through it.

    • @OdooMates
      @OdooMates  2 года назад +1

      @@futhedude4848 can you drop a email to odoomates@gmail.com

    • @futhedude4848
      @futhedude4848 2 года назад +1

      @@OdooMates yes sir, i'll do that as soon as posible

  • @younesschekri
    @younesschekri Год назад +1

    Hi sir thx for your videos
    i'm trying to add sql_constraints on res_partner model without any result
    i ll be glad if you could help me
    thx you

    • @OdooMates
      @OdooMates  Год назад

      if there is already some data that violates the constrains in the db, it will not work

    • @younesschekri
      @younesschekri Год назад

      @@OdooMatesyes i have 6 users in res_partner model

  • @malikkamil6596
    @malikkamil6596 Год назад +1

    Error while installing pos v14
    line 315, in _handle_exception raise exception.with_traceback(None) from new_cause odoo.tools.convert.ParseError: while parsing /home/kamal/odoo/odoo14/odoo14/addons/point_of_sale/data/point_of_sale_data.xml:49, near

    • @OdooMates
      @OdooMates  Год назад

      Can you try with the latest odoo source code

    • @malikkamil6596
      @malikkamil6596 Год назад

      @@OdooMates Hi I hope you are doing well I want to Upload I module to Odoo app store that module depend on multiple modules how i Can manage All module in one app thanks in advance