[IMP] purchase, product: suggest minimum quantity for vendor
This commit introduces the suggestion of a minimum quantity for the chosen vendor. The minimum quantity is suggested only if the quantity on the line is zero. It still allows the user to set a quantity smaller than the minimum quantity for the given vendor. opw-654300
This commit is contained in:
@@ -925,7 +925,7 @@ class product_product(osv.osv):
|
||||
continue
|
||||
if partner_id and seller.name not in [partner_id, partner_id.parent_id]:
|
||||
continue
|
||||
if quantity_uom_seller and quantity_uom_seller < seller.qty:
|
||||
if quantity_uom_seller < seller.qty:
|
||||
continue
|
||||
if seller.product_id and seller.product_id != product_id:
|
||||
continue
|
||||
|
||||
@@ -440,7 +440,7 @@ class PurchaseOrderLine(models.Model):
|
||||
line.qty_received = total
|
||||
|
||||
name = fields.Text(string='Description', required=True)
|
||||
product_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True, default=1.0)
|
||||
product_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True)
|
||||
date_planned = fields.Datetime(string='Scheduled Date', required=True, select=True)
|
||||
taxes_id = fields.Many2many('account.tax', string='Taxes')
|
||||
product_uom = fields.Many2one('product.uom', string='Product Unit of Measure', required=True)
|
||||
@@ -581,6 +581,14 @@ class PurchaseOrderLine(models.Model):
|
||||
self.date_planned = self._get_date_planned(seller).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
if not seller:
|
||||
if not self.product_qty:
|
||||
# Suggest a minimum quantity if possible
|
||||
seller_min_qty = self.product_id.seller_ids\
|
||||
.filtered(lambda r: r.name == self.order_id.partner_id)\
|
||||
.sorted(key=lambda r: r.min_qty)
|
||||
if seller_min_qty:
|
||||
self.product_qty = seller_min_qty[0].min_qty
|
||||
self.product_uom = seller_min_qty[0].product_uom
|
||||
return result
|
||||
|
||||
fpos = self.order_id.fiscal_position_id
|
||||
|
||||
Reference in New Issue
Block a user