33.Default Get Function in Odoo || Set Default Values Using Default Get Function

Поділитися
Вставка

КОМЕНТАРІ • 18

  • @NMNaufaldo
    @NMNaufaldo 2 роки тому

    Thank you for the good tutorial brother 🙂

    • @OdooMates
      @OdooMates  2 роки тому

      welcome 😍😍😍😍

  • @hoangvunhat3600
    @hoangvunhat3600 3 роки тому +1

    Hi thank you for the video. Can you explain the difference between the default_get fuction and the create fuction (above the def default_get in the patient.py)? Because as I see, the create function also sets the default value of 'note' field to 'New Patient' and sequential value for 'reference' field. Are these fuctions similar?

    • @hoangvunhat3600
      @hoangvunhat3600 3 роки тому +3

      Oh I might understand now, correct me if I'm wrong. The default_get function gives us default value of a field when we click the 'Create' button in UI and we still can change that value before saving it. On the other hand, the create fuction gives us default value of a field when we click the 'Save' button, right?

    • @bonjourmonde1500
      @bonjourmonde1500 3 роки тому +1

      @@hoangvunhat3600 thats right

    • @OdooMates
      @OdooMates  2 роки тому +1

      you are right

  • @indeveloperid6061
    @indeveloperid6061 2 роки тому +1

    What is the different with using default attribute in field model ?

    • @NMNaufaldo
      @NMNaufaldo 2 роки тому +1

      What if you have a complex calculation to get the default value? For example like field One2many, you can't use the default attribute field. The default_get function can solve that problem

  • @williamshuyinqiu1656
    @williamshuyinqiu1656 3 роки тому

    can you explain how to disable ACTION button for a group of users?

  • @DEENALAURA
    @DEENALAURA 3 місяці тому

    I cant change the default_get value in form

    • @OdooMates
      @OdooMates  3 місяці тому

      What issue you are facing ?

  • @abdulazimatapy8872
    @abdulazimatapy8872 2 роки тому +1

    thank you for your videos it is amazing, i face a problem when i use default_get method
    @api.model
    def default_get(self, fields):
    print("override default get")
    error -----------------> (AttributeError: 'NoneType' object has no attribute 'get')
    can you explain why this error please.

    • @OdooMates
      @OdooMates  2 роки тому +1

      can i see the code that you have added

    • @abdulazimatapy8872
      @abdulazimatapy8872 2 роки тому +1

      @api.model
      def default_get(self, fields):
      print("override default get")

    • @OdooMates
      @OdooMates  2 роки тому +1

      Over ride it, I mean use super and add print in it

    • @abdulazimatapy8872
      @abdulazimatapy8872 2 роки тому

      @@OdooMates
      @api.model
      def default_get(self, fields):
      res = super(HospitalPatient, self).default_get(fields)
      print(res)
      ---------------------------------------------------------------------------------
      error still apear

    • @abdulazimatapy8872
      @abdulazimatapy8872 2 роки тому +1

      @@OdooMates thank you very much for helping me, the cause of error is that i missed return statement