This question has been flagged
3 Replies
12348 Views

I have one Company per Country that I sell into.

I have a Product Catalog that is shared.


Most of my products can be sold in all Countries, so I am not assigning a Company to each product, this way they are visible in all Companies.


Some of my products can only be sold in specific countries, so I'd like to somehow manage this.

Is this possible?

Avatar
Discard

 \Ray Carnes response is the easyiest way to do it

Extremely useful. Thank you very much Ray.

Best Answer

In this example, we have three Companies:

  • USA, Canada, Australia

... and five products:

  • Sold Everywhere, Sold in USA and Canada, Sold in USA, Sold in Australia, Sold in USA and Australia.




First, create a custom field on the Product that you can use to store which Countries a given Product can be sold in.  We will use the logic that if NO country is listed, it can be sold in ALL Countries.

(the yellow area is completed automatically for you by Odoo)


Then, add this field to the User Interface so you can start managing this relationship.

<page name="inventory" position="after">
<page name="countries" string="Allowed Companies">
<field name="x_company_ids"/>
</page>
</page>


Then, associate the Products with the Companies:


We now need a record rule that restricts the products seen.  I would recommend only applying this record rule based on a specific group of users.  Since the intention is to prevent Salespeople selling products, I would use one of the Sales Groups.


We also need a record rule that clears this restriction.  I recommend setting up a separate group for users who are allowed to see all products.


This is what Users in the Sales Group will see when logged into USA:

This is what Users in the Sales Group will see when logged into Canada:


This is what Users in the Sales Group will see when logged into Australia:




Avatar
Discard

Hi Ray, this looks very useful.

Super useful!

Works but did some minor edits as of odoo 17 needs some changes
First of all Model should be only Product not product template
secondly adding this field to the User Interface should be done with Studio , couldnt do with this code

Best Answer

Hi Ray,

That solutions works for sales module, will it work for ecommerce as well?

Thanks!

Avatar
Discard
Best Answer

Hi, 

You can see following for this:

https://youtu.be/GkNgc-fZO-I

Hope it helps,

Thanks

Avatar
Discard