Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

0
Avatar

Maarten Bressers

--Maarten Bressers--

2546
| 3 1 2
Oisterwijk, Nederland
--Maarten Bressers--
Maarten Bressers
Op 06-10-20 09:24



see URL: https://odootricks.tips/prevent-users-create-products-on-the-fly/

Odoo has a “helpful” feature that allows users to create products (and customers, suppliers, etc., etc.) “on the fly”. This is when you enter a product name, no match is found, and Odoo lets you “Create” or “Create and Edit” a new product.

There are several potential problems with this:

  • the user may have mis-typed the name of the product (or customer, or supplier) and will create a duplicate that will cause further confusion.
  • there may be some information that needs to be added for a new product and that will not be entered.
  • a different user or department should be creating products (customers, suppliers) – of course, it may be possible to block this with security rules

The end result can be multiple products with similar names, products with incomplete or incorrect definition, products that should be services, etc.

Fortunately, Odoo does allow you to block this, and it can be done in Odoo Studio, as explained here.

There is a small complication when doing this for products on a sales order in Odoo 13, but there is a workaround.

  1. Enable Studio
  2. Click on the sales order line
  3. Click on the “Edit List View” button.
  4. Click on the “Product” field”
  5. Information about this field is displayed in the left-hand panel.

Note that in Odoo 13 Enterprise Edition, the field is product_template_id. In Odoo 13 Community Edition and previous versions (both Enterprise and Community), the field is product_id.

You will notice that:

  1. The widget is product_configurator
  2. No checkboxes for “Disable creation” and “Disable opening”

The workaround is to change the widget

Now, as you can see, those two checkboxes are visible.

  1. Click on both checkboxes (you may need to do this twice!!)
  2. Exit Studio
  3. Now there’s no option to add a product:

What’s happened here is that Odoo Studio has created an Extension View:

This is the XML:

</data>
   <xpath expr="//field[@name='product_template_id']" position="attributes">
     <attribute name="options">{"no_open":true,"no_create":true}</attribute>
     <attribute name="widget">many2one</attribute>
   </xpath>
</data>

If you don’t have Odoo Studio you could achieve the same effect by creating an Extension View manually.

  • You can probably remove the line that changes the widget, it doesn’t seem to cause any problems.

In older versions of Odoo Studio you would have to make another change (e.g. amend the field description) and then manually update the XML (you could remove the amended field description at the same time).

As noted above, the field is product_id

The XML will be something like this:

<data>
   <xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/tree[1]/field[@name='product_id']" position="attributes">
     <attribute name="string">_Product_ </attribute>
   </xpath>
</data>

Yes, Odoo Studio uses “path” statements like that!

You can amend it as follows:

  1. remove the change to the field description
  2. replace it with the “options”:
<data>
   <xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/tree[1]/field[@name='product_id']" position="attributes">
      <attribute name="options">{'no_quick_create':True,'no_create_edit':True}</attribute>
   </xpath>
</data>

Community Edition

Obviously there’s no Odoo Studio so you would have to create the Extension View manually (and the field is product_id).


Blijf geïnformeerd

Over deze community

This is a forum for internal use only... Lees de regels

Vraag hulpmiddelen

3 volger(s)

Statistieken

Gevraagd: 06-10-20 09:22
Gezien: 30 keer
Laatst bijgewerkt: 06-10-20 09:24