This question has been flagged
15 Replies
9742 Views

I've found that my users are accidentally creating way too many garbage product records directly from the sales order/quote form. I'd like to curb this.

Odoo makes it pretty easy to create a new product record from the quotation/sales order form. If you start searching for a product and don't find it, the default option is to create it if you press "enter". Many users are in a hurry and just press "enter" mindlessly, creating the new product record. This leaves a lot of cleanup to be done later. I can usually find the products because they are "Consumables" by default, with a $1.00 price, no internal reference, no description, etc.

I've tried marking the Internal Reference field as required. I thought this would help because you can't enter the internal reference from the product form, so therefore users wouldn't be able to create records mindlessly. This didn't work. It seems that products created from sales orders/quotes completely skip model validation (!). As long as there is something in the product field Odoo will blindly create the product.

Does anybody have a solution to prevent users from blindly creating product records from the sales order/quotes form?

Avatar
Discard

The question remains whatever bypass or blocking rules are: why do the users "accidentally" create new products instead of refering to approprite existing ones?

I can imagine 2 causes

1 the users do not well know the way the products are named into the system (name or reference or any other form of index) >>> make sure the naming conventions are the cleanest possible and train users

2 the searching function is using "brute force" i.e not accepting alternative orthograph, or not refering to additional fields >>> allow developpers to improve the searching function.

Best Answer

Remove the ability to create products on the sale.order form view:

<field name="product_id" options="{'no_create': True}"/>
Avatar
Discard
Author

This ended up being the simplest solution. Thank you.

Where is the path for the sales.order?

I tried it on odoo13/addons/sale/view/sale_views.xml

but it does not have any effect.

Best Answer

It turns out to be not quite so straightforward to do this in Odoo Studio (Odoo 13):

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

The workaround is to change the widget

Now those two checkboxes are visible, so:

  1. Click on both checkboxes
  2. Exit Studio
  3. Now there’s no option to add a product:

This is the 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.

I think you can remove the line that changes the widget

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

Avatar
Discard
Best Answer

Is there any way this solution (<field name="product_id" options="{'no_create': True}"/>) can be implemented through the "Studio" app?  I've tried various ways of entering this option in both the "domain" and "context" fields, to no avail.

If not possible, can someone please walk me through where to enter the <field name="product_id" options="{'no_create': True}"/>? ...preferably starting from the odoo dashboard.

Avatar
Discard

I also tried it on odoo13/addons/sale/view/sale_views.xml

but it does not have any effect.

so, someone please give us information where should we put that code?

Best Answer

HI Michael, you can use the below syntax at sale.order.line view for product_id field to prevent users to create the product from Sale Order/Quote form view.

<field name="product_id" options="{'no_quick_create': True,'no_create_edit':True}"/>
Avatar
Discard
Best Answer

Thanks ray Carnes,

it helped me so much

i did it for sale.order.form, purchase.order.form and stock.picking.form

the difficulty is to find the right line to add this option but after several trials, i got it and it was a different line for each form

Avatar
Discard

Where is the path for the sales.order?

I tried it on odoo13/addons/sale/view/sale_views.xml

but it does not have any effect.

Hi LIma

the simple way i found is to modify it by the web interface

It is surely not the right way but it worked for me. You can do as below :

1/ connection in developper mode

2/ open a sale order

3/ cilck on develpment tools ( top right corner )

4/ select the item ' modify the view : form '

and then you can modifiy the model form

hope it will help

kind regards

@Arnaud You will loose these amendments as soon as you update Odoo or the corresponding module.

Hi Ermin,

I know the risk yes but as i'm not a programer, it was a simple way.

We don't plan any upgrade and it is the lonely one amendment done so it is noticed in our software guide

Best Answer

You can set some validation on create function of the product

example:

def create(self, vals):

     if not description: # get description value from vals

         #some warning code

Avatar
Discard