mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[10.0][REW] remove dependency with stock_orderpoint_uom
This commit is contained in:
committed by
Joan Sisquella
parent
bd4e5e031a
commit
8353b80770
@@ -13,7 +13,6 @@
|
||||
"category": "Warehouse Management",
|
||||
"depends": [
|
||||
"stock",
|
||||
"stock_orderpoint_uom",
|
||||
],
|
||||
"data": [
|
||||
"security/stock_orderpoint_manual_procurement_security.xml",
|
||||
|
||||
@@ -25,6 +25,30 @@ class StockWarehouseOrderpoint(models.Model):
|
||||
compute="_compute_procure_recommended",
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _get_procure_recommended_qty(self, virtual_qty, op_qtys):
|
||||
self.ensure_one()
|
||||
procure_recommended_qty = 0.0
|
||||
qty = max(self.product_min_qty, self.product_max_qty) - virtual_qty
|
||||
remainder = \
|
||||
self.qty_multiple > 0 and qty % self.qty_multiple or 0.0
|
||||
if float_compare(
|
||||
remainder, 0.0,
|
||||
precision_rounding=self.product_uom.rounding) > 0:
|
||||
qty += self.qty_multiple - remainder
|
||||
|
||||
if float_compare(
|
||||
qty, 0.0,
|
||||
precision_rounding=self.product_uom.rounding) <= 0:
|
||||
return procure_recommended_qty
|
||||
|
||||
qty -= op_qtys[self.id]
|
||||
qty_rounded = float_round(
|
||||
qty, precision_rounding=self.product_uom.rounding)
|
||||
if qty_rounded > 0:
|
||||
procure_recommended_qty = qty_rounded
|
||||
return procure_recommended_qty
|
||||
|
||||
@api.multi
|
||||
@api.depends("product_min_qty", "product_id", "qty_multiple")
|
||||
def _compute_procure_recommended(self):
|
||||
@@ -32,34 +56,9 @@ class StockWarehouseOrderpoint(models.Model):
|
||||
for op in self:
|
||||
op.procure_recommended_date = op._get_date_planned(
|
||||
datetime.today())
|
||||
procure_recommended_qty = 0.0
|
||||
virtual_qty = op.with_context(
|
||||
location=op.location_id.id).product_id.virtual_available
|
||||
if float_compare(virtual_qty, op.product_min_qty,
|
||||
precision_rounding=op.product_uom.rounding) < 0:
|
||||
qty = max(op.product_min_qty, op.product_max_qty) - virtual_qty
|
||||
remainder = \
|
||||
op.qty_multiple > 0 and qty % op.qty_multiple or 0.0
|
||||
if float_compare(
|
||||
remainder, 0.0,
|
||||
precision_rounding=op.product_uom.rounding) > 0:
|
||||
qty += op.qty_multiple - remainder
|
||||
|
||||
if float_compare(
|
||||
qty, 0.0,
|
||||
precision_rounding=op.product_uom.rounding) <= 0:
|
||||
continue
|
||||
|
||||
qty -= op_qtys[op.id]
|
||||
qty_rounded = float_round(
|
||||
qty, precision_rounding=op.product_uom.rounding)
|
||||
if qty_rounded > 0:
|
||||
procure_recommended_qty = qty_rounded
|
||||
if op.procure_uom_id:
|
||||
product_qty = op.procure_uom_id._compute_qty(
|
||||
op.product_id.uom_id.id, procure_recommended_qty,
|
||||
op.procure_uom_id.id)
|
||||
else:
|
||||
product_qty = procure_recommended_qty
|
||||
|
||||
op.procure_recommended_qty = product_qty
|
||||
op.procure_recommended_qty = op._get_procure_recommended_qty(
|
||||
virtual_qty, op_qtys)
|
||||
|
||||
@@ -17,15 +17,9 @@ class MakeProcurementOrderpoint(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _prepare_item(self, orderpoint):
|
||||
|
||||
if orderpoint.procure_uom_id:
|
||||
product_uom = orderpoint.procure_uom_id
|
||||
else:
|
||||
product_uom = orderpoint.product_uom
|
||||
|
||||
return {
|
||||
'qty': orderpoint.procure_recommended_qty,
|
||||
'uom_id': product_uom.id,
|
||||
'uom_id': orderpoint.product_uom.id,
|
||||
'date_planned': orderpoint.procure_recommended_date,
|
||||
'orderpoint_id': orderpoint.id,
|
||||
'product_id': orderpoint.product_id.id,
|
||||
@@ -120,9 +114,6 @@ class MakeProcurementOrderpointItem(models.TransientModel):
|
||||
@api.onchange('uom_id')
|
||||
def onchange_uom_id(self):
|
||||
for rec in self:
|
||||
uom = rec.orderpoint_id.procure_uom_id or \
|
||||
rec.orderpoint_id.product_uom
|
||||
rec.qty = rec.uom_id._compute_qty(
|
||||
uom.id,
|
||||
rec.qty = rec.orderpoint_id.product_uom._compute_quantity(
|
||||
rec.orderpoint_id.procure_recommended_qty,
|
||||
rec.uom_id.id)
|
||||
rec.uom_id)
|
||||
|
||||
Reference in New Issue
Block a user