Skip to Content
Menu
This question has been flagged

Is there any way to set a maximum or minimum quantity allowed per product in a sales order, or to be able to set this limit from the customer (also on the website)?

 

Avatar
Discard

You can use either constraint or onchange method to set this kind of limit.

Best Answer

In my module i set this functionality by giving limit to <input/> tag in xml template.

<input type="number" name="quantity" min="1" max="5">

if you are creating or overriting view then you simpaly set this attribute this will help u too.


Avatar
Discard

This is for website only? How can we set on float or integer field?

Many2one field store id of other model so it is integer only. This is many2one field not simple integer field so it store integer.

how to set this on simple many2one field?

'simple': fields.integer('Simple integer field'), 'many2one_field': fields.many2one('other model object', 'Many2one field'), here you can see first one is integer field and second one is many2one field and both are integer field. many2one field store only integer type value not float type.

I mean how to set limit(min and max) on integer/float field?

As i above mention. in xml template. tag input type="number" min="0" max="5" t-att-value="object.many2one_field.qty". above code i set value dynamically and also give limit min and max. got it or not?

t-att-value="object.many2one_field.qty. ok now got it. Thanks

ur welcome :)

Author

How would this work if I need to set this on a per product/customer basis? Different groups of customers would have different limits. This will only work for the website, how would I do this for inside the sales process?

As per my knowledge you can take min and max field in model so you can easily access and set max and min limit with per customer/product.

can anyone help? i want 0 not accept on cost
<?xml version="1.0"?>
<xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="after">
<field name="purchase_price" groups="base.group_user" required="1" type="number" min="1"/>
</xpath>

Related Posts Replies Views Activity
1
Oct 23
572
0
May 24
1200
2
May 22
2771
2
May 24
2703
0
Sep 24
120