1

every product in odoo should have quantity minimum

i have created product and i set the quantity min to it in reordering rule

what i want to do is get the product name and it's quantity min in python

this is my python file

from odoo import fields,models,api

class Qty_Min_Alert(models.Model):
    _inherit='product.template'
    product_name = # here i want to set the product name from product.template
    product_qty_min = # here i want to set the product quantity minimum from product.template

i added 'product' in depends on manifest.py can you help me please

Sidharth Panda
  • 404
  • 3
  • 17
Zoro
  • 47
  • 5

1 Answers1

2

your question is bit unclear, according to your question what i understood is that you want to set every product in product with a particular quantity which is in your case will be the minimum quantity?

if so then you have to inherit the product.product and create a method to search all records and then update the in_hand_qty to your desired minimum value as you have set it already on a field

@api.onchange('product_qty_min')
def min_in_hand(self):
    all_stocks = self.env['stock.quant'].search(['product_tmpl_id', '=', self.id])
    for rec in all_stocks:
        rec.update({'inventory_quantity': self.product_qty_min}).action_assign()

if you will set a value in minimum value field it will be automatically added to the in hand quantity as a min value

Sidharth Panda
  • 404
  • 3
  • 17