This question has been flagged

Hi,

It is possible that when creating an RFQ and selecting a vendor, the list of products that can be added is limited to products related to that vendor, or if I add first the product I can only choose the vendor(s) related to this product?

Thanks,

Ricardo

Avatar
Discard

Can you use Supplier Price Lists (product.supplierinfo) for the linkage?

Best Answer

Adding this domain to the product_id field on the Request for Quotation Form View will do that:

 ['|',  ('seller_ids.name', '=', parent.partner_id),
        ('seller_ids.name.child_ids', '=', parent.partner_id),
        ('purchase_ok', '=', True)] 
Avatar
Discard

Hi Ray, thanks for your great Idea. I try to use your code in V13 last update. It seems that the code is changed a little.

I get this result:

["&","|",["seller_ids.name","=","parent.partner_id"],["seller_ids.name.child_ids","=","parent.partner_id"],["purchase_ok","=",True]]

However, I am doing something wrong, because I do not get any product. Can you please guide. Tks a lot.

Your domain is wrong. I posted an example tested with v13. You are asking Odoo to show you products where (1) the name of one of the Vendors is the same as the Vendor on the PO "and" (2) the name of one of the child records of the Vendors is the same as the Vendor on the PO "or" (3) the product can be purchased. (1) and (2) cannot be true at the same time.

Best Answer

Some update for Odoo 16 as the datamodel changed slightly:

domain="[('seller_ids.partner_id','=',parent.partner_id),('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"

Seems to work in terms of limiting the access to only the product sold by this supplier.

Avatar
Discard

Hello Ray & Antoine, hope you are keeping well.
I am new Odoo user, just wanted to say thanks for your help.
I was struggling with this for a long time and finally I got it today :)
I found clues to the problem in both of your answers and that is how it became possible for me. So yeah, thanks once again.

Here I would like to share how I did it! I thought this might be useful for new avid users.

First clue to the problem was knowing that you had to change the field domain code, in this case the product field domain code, Ray was explicit about it, as to where to find it. That was such a great help!!!!! That got me going. Secondly, notice he was also clear that the code had to be ADDED and not changed, (point that I completely missed :) and went about trying to changing the code, good luck with that!!! So, this is something really to watch out)

Time to jump to Antoine's code (because its applicable to current version), he got the code right (Thank you, Antoine) however, he was not explicit like Ray. So knowing that you need to ADD the code as an extension and not changing the already
existing code is the solution.

Finally here is my complete working domain code (the existing plus the Antoine's extension)
domain="[('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id), ('seller_ids.partner_id','=',parent.partner_id),('purchase_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/>

To edit the product form, here is step by step instructions;
>First enable the developers mode
> then go to the RFQ form page
> click on the developer mode mark next to chat
> on the pop up menu look for edit view form and click to open it
> a new window will open
> on the Architecture tab, scroll down to row 90 & 115 where you will find the required field: product_id
> scroll to the right further up the columns up you will find the domain code where it will say (domain=) this is where you copy paste the above code (remember to change on both row 90 and 115) > save and go back to RFQ > its done!

Still learning and hoping to progress! please correct if I am wrong!

Author

Hi Gulraiz, good explanation, but still incomplete, because if for some reason, you have to do an update of the purchase module or a base upgrade, your changes will be lost, so it would be important to add the steps:
- go to settings->technical->views
- open the view "purchase.order.form"
- in developer tools open -> view metadata and by clicking on top (false) change the value of No Update to "true (change)"
so your changes will not be lost in an update

Yes Ricardo, when I made the change, system did display a message window saying that this change will not last an update, it talked about making the changes in the inherit view but I did not know what to do. So I did what you said, and that makes sense. While I still don't fully appreciate the different views but I think I am beginning to understand some bit :) Thank you so much once again. Good day to all, Later.