How To Give Domain For A Field Based On Another Field || Onchange Domain In Odoo

Поделиться
HTML-код
  • Опубликовано: 4 дек 2024

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

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

    The thing I like most about your vids is - you do not only show and explain the solution for a problem - nope, man.
    You are giving the way how to resolve it yourself next time - this is the real power of these tutorials.

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

      thanks for the lovely words 😘🤩😍🥰 and thanks for all your supports

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

    Dude, I just love you!!! Thank you. I couldn't figured it out by my self.

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

      happy that it helped

  • @javobqcol
    @javobqcol 4 года назад +2

    sorry my english is too bad
    The little bit I know about odoo is because of you, thanks
    This solution is ok when you insert a record, but if you update a record and don't change partner_id, the onchange dont triggered and you update the order_id with any arbitrary record in table 'sale.order', I do not find any solutions for this issue

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

      Use this method: ruclips.net/video/dq5Vtj_pwuI/видео.html

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

    thank you for this nice tutorial. I would like to know how to do this on Odoo studio: I mean in the domain field, I would like to show only the vendor related product in the PO , or the customer re;ated product in an SO. can you please tell us how?

  • @mohammadharb613
    @mohammadharb613 7 месяцев назад

    Can we do the same scenario using domain filter in xml level ?

  • @cricketnews2593
    @cricketnews2593 5 лет назад +1

    Great as you are doing always :-)
    would you like which IDE you are using for developing. As well made short video for that IDE if possible

    • @OdooMates
      @OdooMates  5 лет назад

      We use Pycharm and we already have made a video if it. See: ruclips.net/video/p7SJW36lqVE/видео.html

  • @klauskarwatzki9268
    @klauskarwatzki9268 4 года назад +1

    Great Job! Thanks a lot for your video(s).
    I am looking for an explanation from a pro, so eventually you could help:
    using STUDIO in Odoo v14, I created a field "gender" (as a selection-field with the values 'M', 'F', 'D' ) in the contacts module. I also created a field "salutation" in contacts.
    What I want Odoo to do is to write the correct salutation into the salutation field when the user chooses the appropiate "gender"-field-option M ,F or D.
    How should I program the salutation field?

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

      so you need to write onchange from studio right? see this: ruclips.net/video/psQF5jOrd48/видео.html

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

    Can we make report in both type (excel,Pdf) from wizard? if yes then how to set domain for date from to date to for PDF report

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

      yes possible,see: ruclips.net/video/u7frpEWdrNc/видео.html

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

    I have a problem, the field is always showing more data that a i need. I have to show a res.partner list i did everything and the field show at first the list that i have plus the rest of res.partner, hope can help me. Thanks for the videos are very useful.

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

      can i see the domain you have applied ?

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

      @@OdooMates return {'domain':{'representatives': [('id', 'in', representatives)]}}. "representatives" is a list with all the id's that i need to search

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

      @@sendermolina2321 is the function returning this domain getting executed ?

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

      @@OdooMates Yes, that's the weird thing. For more context, I have a form that contains a many2many(many2many tags) field to res.partner, a have a button that pop up a wizard this wizard contains a field called "representatives" in this field i want to show the list of res.partner selected in the many2many tags in the form.
      If I had, for example, a list of res.partner like (John, Walter, Steve, Myke) and in my many2many tags i choose only (Steve, Walter) the wizard is showing up at first (John, Walter) in the first place but after that is showing (John, Myke). I'm looking that the field "representatives" only shows (Steve, Walter).

  • @dhirenjoshi6745
    @dhirenjoshi6745 4 года назад +1

    how we can do same thing only show the particular One2many field ids of another model in Many2One field

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

      You can directly give domain or from onchange function

  • @nadeemkazi2092
    @nadeemkazi2092 4 года назад +1

    Thanks alot champ....Awesome

  • @hectorstivalet
    @hectorstivalet 4 года назад +1

    Thank you for the video Odoo Mates... Our company just move to Odoo SH (v14) and my team is not accepting warning messages in the automatic test. I do my dynamic domains the way you showed in this video but even though it works in Odoo 14, a deprecation warning is shown: "onchange method the_model.onchange_function returned a domain, this is deprecated". Any advice on how to create dynamic domains in Odoo 14?

    • @hectorstivalet
      @hectorstivalet 4 года назад +1

      I solve this with an auxiliary computed field filled with the domain I needed

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

      Solution For odoo 14: ruclips.net/video/dq5Vtj_pwuI/видео.html

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

      @@hectorstivalet it this method? ruclips.net/video/dq5Vtj_pwuI/видео.html

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

      @@OdooMates Yes Mate. I didn't use that addon module but yes, I did the same thing. Just a comment on your code: @api.multi is not necessary in v14.

  • @usmanfarzand4078
    @usmanfarzand4078 5 лет назад +1

    Amazing Video .....

  • @omargomez9962
    @omargomez9962 3 года назад +2

    This solution is deprecated on Odoo 14, do you know how to accomplish this on Odoo 14? Thanks!

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

      if you check the rst file you will understand how to use this module, we will be making a video soon about this module.

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

      For Odoo14: See this Video: ruclips.net/video/dq5Vtj_pwuI/видео.html

  • @sidimohamedmouleyslimane7835
    @sidimohamedmouleyslimane7835 4 года назад +2

    If you confirm the appointment, and the edit it again and you go directly to the sale_order field you'll get all the sales even if the partner field is already specified :/

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

      Solution: ruclips.net/video/dq5Vtj_pwuI/видео.html

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

    very nice nd informated video...sir how we are call field from another module?

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

      Related field will help ? ruclips.net/video/rLlUQ9GAan8/видео.html

  • @obehobeh9984
    @obehobeh9984 5 лет назад +1

    What will happen in the "Sale order" if the "Customer" pays for the service with two or three documents?

    • @OdooMates
      @OdooMates  5 лет назад

      Documents means ? Invoice ?

    • @obehobeh9984
      @obehobeh9984 5 лет назад +1

      @@OdooMates 8:25 A list of "Sale Order" documents is displayed. And you can choose only one. And if the payment will be several times and different Invoice?
      Then you need to specify several Invoice and the amount for each that goes to this "Sale Order"

    • @OdooMates
      @OdooMates  5 лет назад

      @@obehobeh9984 confirm all the sales, create invoice for all. Make a payment as whole and reconcile with the invoice

  • @odoodiscussions
    @odoodiscussions 4 года назад +2

    The domain will no more work if you refresh the page. Can you please help how we can resolve this issue?

    • @ferchichianis
      @ferchichianis 4 года назад +1

      the solution : fields.many2many(...., domain="[('partner_id','=', partner_id)]", ...) # base on AccountMoveLine.product_uom_id definition

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

    How to create custom fields product and qty, selected product update same product qty please tell me

  • @webcoder7157
    @webcoder7157 4 года назад

    How we can do same thing in wizard customer field in that place where it is and sale order field in wizard then how we can do that please

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

    How to return value for specific fields of m2o (like payment terms), not order ID?

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

      May i know what issue you face with this method

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

      ​@@OdooMates what I mean, we add 2 fields:
      - partner_id = fields.Many2one("res.partner", string="Partner")
      - address_id = fields.Many2one("res.partner", string="Address")
      is it possible to return the same many2one with different values? one is partner name, the other one is address? or is there any alternative solution about it?

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

      @@decajohn6786 there is no issue for adding multiple fields with same co-model in same model

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

      @@OdooMates Agreed. but how to return different values for the same Many2one for above scenario? such as partner name and address name, but using the same comodel name, that is res.partner?

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

      @@decajohn6786 return {'domain': {'field_1': [('type', '=', 'individual')],
      'field_2': [('type', '=', 'company')]}}

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

    How can we do this if I have 2 fields .
    eg: i need to get result in Filed C based on Field A and Field B

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

      use the same logic, write common onchange function for both fields A and B, and then return domain of field C from it

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

      See: ruclips.net/video/dq5Vtj_pwuI/видео.html

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

    Thanks :)

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

    thanks for this interesting video,
    How to return domain for an one2many field using web domain module?

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

      Did you tried the same way for o2m field and not succeeded ?

  • @sansoftinfotech-career9282
    @sansoftinfotech-career9282 3 года назад

    what are the columns in the odoo AccountType master , documentType master and how these are accessed in a code ?

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

      if you activate developer mode and navigate go to Settings -> Technical -> Database Structure -> Models, search for the models and open it, then you can see all the fields/columns in the table/model

  • @Антон-е7щ4н
    @Антон-е7щ4н 3 года назад +1

    Hello. Thank you for the video. Could you help me please again? ;) I'm trying to return domain in onchange function, but it doesn't work. The error message is: onchange method ProductManufacturer.get_selected_manufacturer returned a domain, this is deprecated. Odoo 14. What can I do with this?

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

      The method shown in this video is deprecated in odoo14, from odoo14 you can use this method shown in this video: ruclips.net/video/dq5Vtj_pwuI/видео.html

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

      See: ruclips.net/video/dq5Vtj_pwuI/видео.html

    • @Антон-е7щ4н
      @Антон-е7щ4н 3 года назад +1

      @@OdooMates Thank you, but the module does not load for Odoo 14 :\

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

      Which module ?

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

      @@Антон-е7щ4н understood, please download it from github: github.com/OCA/web/tree/14.0

  • @rajeshkumarcbm
    @rajeshkumarcbm 5 лет назад

    Hi bro, without onchange & compute function can we write domain like this?

    • @OdooMates
      @OdooMates  5 лет назад

      No other options is available i think, this is the common practice i have seen. Not sure, anyway you can try some other ways if you it might work out and explore it (y)

    • @rajeshkumarcbm
      @rajeshkumarcbm 5 лет назад

      @@OdooMates for eg,
      if not choosing customer, respective value should be open
      Or we choose customer, all sale order value wants to open,
      Is it possible?

    • @OdooMates
      @OdooMates  5 лет назад +1

      @@rajeshkumarcbm Yes, this can be done inside the function, check whether there is value given in partner field or not and return domain accordingly using a if condition

    • @rajeshkumarcbm
      @rajeshkumarcbm 5 лет назад +1

      @@OdooMates thnx bro let me check.

  • @MdYusufAlam
    @MdYusufAlam 4 года назад +1

    How we can do the same using odoo studio?

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

      you can write an onchange using the automated action and return the domain from there

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

      ruclips.net/video/psQF5jOrd48/видео.html

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

      @@OdooMates have any example how can i give Domain For A Field Based On Another Field with odoo studio?

  • @ibrahimhalouane8130
    @ibrahimhalouane8130 4 года назад

    In v11 I didn't need to use "rec" variable, since there is only one instance in "self".

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

      you cannot assure it. this will depends on the scenario and it is same in all odoo versions :)

    • @ibrahimhalouane8130
      @ibrahimhalouane8130 4 года назад

      @@OdooMates you mean by scenarios, when a user attempt to multi-select or single-select records, right?

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

    👍👍

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

    how to give domain to product inside one2many field?

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

      inside one2many model, when we define product field, you can give the domain in python level or in the xml along with product field

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

      @@OdooMates
      i had a problem in that!
      @api.onchange('category_id')
      def _onchange_category_id(self):
      print('hi....................', self.category_id)
      products = []
      if self.category_id:
      products = self.env['product.product'].search([('categ_id', '=', self.category_id.id)]).ids
      print('list....................', products)
      return {'domain': {'farm_materials_oline.product_id': [
      ('id', 'in', products)
      ]}}

  • @moadboutahor4045
    @moadboutahor4045 5 лет назад +1

    👍🏻

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

    How To Give Domain For A Field Based On Another Field with odoo studio?

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

      Using the studio, you can trigger an onchange using the automated action and return the domain for the other field from there. See how to trigger onchange from UI from here: ruclips.net/video/psQF5jOrd48/видео.html

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

    Hello i'm having this error "TypeError: unhashable type: 'list'" and this is what i am returning
    return {'domain':{'commune': [('state_id', 'in ', rec.wilaya.mapped('id'))]}} (wilaya is a may2many field)

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

      try: {'domain':{'commune': [('state_id', 'in ', rec.wilaya.ids)]}}