purchase_order_product_recommendation_supermarket: add a setting in products to suggest a minimum purchase when forecast <= 0
This commit is contained in:
parent
3a35955d24
commit
65dd899963
8 changed files with 93 additions and 4 deletions
|
|
@ -1 +1,2 @@
|
||||||
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
"author": "Criptomart",
|
"author": "Criptomart",
|
||||||
"website": "https://criptomart.net",
|
"website": "https://criptomart.net",
|
||||||
"depends": ["purchase_order_product_recommendation"],
|
"depends": ["purchase_order_product_recommendation"],
|
||||||
"data": ["wizards/purchase_order_recommendation.xml"],
|
"data": [
|
||||||
|
"wizards/purchase_order_recommendation.xml",
|
||||||
|
"views/product_template_view.xml",
|
||||||
|
],
|
||||||
"demo": [],
|
"demo": [],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,31 @@ msgstr ""
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Plural-Forms: \n"
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__include_previous_period
|
||||||
|
msgid "Include previous period stats"
|
||||||
|
msgstr "Incluir estadísticas del periodo previo"
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__include_previous_period
|
||||||
|
msgid "If disabled, the previous period (same number of days immediately preceding) is NOT queried. This saves a read_group on stock move lines and skips zero-stock day analysis for that window."
|
||||||
|
msgstr "Si se desactiva, no se consulta el periodo previo (mismo número de días inmediatamente anteriores). Ahorra tiempo en el cálculo al no consultar movimientos de stock y omite el análisis de días sin stock para esa ventana de tiempo."
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_product_template__po_min_suggest_if_forecast_le_zero
|
||||||
|
msgid "Suggest minimum purchase when forecast <= 0"
|
||||||
|
msgstr "Sugerir compra mínima cuando el stock previsto <= 0"
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_product_template__po_min_suggest_if_forecast_le_zero
|
||||||
|
msgid "If enabled, the purchase recommendation wizard will always propose at least 1 unit (or 1 full package when ordering by packages) when the forecasted stock is less or equal to 0."
|
||||||
|
msgstr "Si se activa, el asistente de recomendación de compras propondrá siempre al menos 1 unidad (o 1 paquete completo al pedir por paquetes) cuando el stock previsto sea menor o igual que 0."
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model_terms:ir.ui.view,arch_db:purchase_order_product_recommendation_supermarket.view_product_template_form_po_min_suggest
|
||||||
|
msgid "Purchase Recommendation"
|
||||||
|
msgstr "Recomendación de compra"
|
||||||
|
|
||||||
#. module: purchase_order_product_recommendation_supermarket
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_avg_delivered_prev
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_avg_delivered_prev
|
||||||
msgid "Average daily consumption during the previous period"
|
msgid "Average daily consumption during the previous period"
|
||||||
|
|
@ -103,7 +128,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Indica durante cuantos días el nuevo pedido debe cubrir el stock. Si no se "
|
"Indica durante cuantos días el nuevo pedido debe cubrir el stock. Si no se "
|
||||||
"rellena este campo las recomendaciones mostradas se calcularán para cubrir "
|
"rellena este campo las recomendaciones mostradas se calcularán para cubrir "
|
||||||
"un periodo equivalente al mostrado en días totales."
|
"un periodo equivalente al mostrado en días analizados."
|
||||||
|
|
||||||
#. module: purchase_order_product_recommendation_supermarket
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__order_by_packages
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__order_by_packages
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,31 @@ msgstr ""
|
||||||
"Content-Transfer-Encoding: \n"
|
"Content-Transfer-Encoding: \n"
|
||||||
"Plural-Forms: \n"
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__include_previous_period
|
||||||
|
msgid "Include previous period stats"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__include_previous_period
|
||||||
|
msgid "If disabled, the previous period (same number of days immediately preceding) is NOT queried. This saves a read_group on stock move lines and skips zero-stock day analysis for that window."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_product_template__po_min_suggest_if_forecast_le_zero
|
||||||
|
msgid "Suggest minimum purchase when forecast <= 0"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_product_template__po_min_suggest_if_forecast_le_zero
|
||||||
|
msgid "If enabled, the purchase recommendation wizard will always propose at least 1 unit (or 1 full package when ordering by packages) when the forecasted stock is less or equal to 0."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
|
#: model_terms:ir.ui.view,arch_db:purchase_order_product_recommendation_supermarket.view_product_template_form_po_min_suggest
|
||||||
|
msgid "Purchase Recommendation"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: purchase_order_product_recommendation_supermarket
|
#. module: purchase_order_product_recommendation_supermarket
|
||||||
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_avg_delivered_prev
|
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_avg_delivered_prev
|
||||||
msgid "Average daily consumption during the previous period"
|
msgid "Average daily consumption during the previous period"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
from . import product_template
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
|
||||||
|
po_min_suggest_if_forecast_le_zero = fields.Boolean(
|
||||||
|
string='Suggest minimum purchase when forecast <= 0',
|
||||||
|
help='If enabled, the purchase recommendation wizard will always propose at least 1 unit (or 1 full package when ordering by packages) when the forecasted stock is less or equal to 0.'
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_product_template_form_po_min_suggest" model="ir.ui.view">
|
||||||
|
<field name="name">product.template.form.po.min.suggest</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="inherit_id" ref="product.product_template_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group[@name='bill']" position="before">
|
||||||
|
<group string="Purchase Recommendation">
|
||||||
|
<field name="po_min_suggest_if_forecast_le_zero"/>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
|
|
@ -22,7 +22,7 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
|
||||||
)
|
)
|
||||||
include_previous_period = fields.Boolean(
|
include_previous_period = fields.Boolean(
|
||||||
string="Include previous period stats",
|
string="Include previous period stats",
|
||||||
default=True,
|
default=False,
|
||||||
help="If disabled, the previous period (same number of days immediately preceding) is NOT queried. This saves a read_group on stock move lines and skips zero-stock day analysis for that window.",
|
help="If disabled, the previous period (same number of days immediately preceding) is NOT queried. This saves a read_group on stock move lines and skips zero-stock day analysis for that window.",
|
||||||
)
|
)
|
||||||
total_days = fields.Integer(
|
total_days = fields.Integer(
|
||||||
|
|
@ -181,6 +181,15 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
|
||||||
(self.order_days * res["units_avg_delivered"])
|
(self.order_days * res["units_avg_delivered"])
|
||||||
- res["units_virtual_available"],
|
- res["units_virtual_available"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Force a minimum suggested quantity when forecast <= 0 and product configured
|
||||||
|
# We apply this BEFORE packaging adjustment so packages logic can upscale it.
|
||||||
|
if (
|
||||||
|
product_id.po_min_suggest_if_forecast_le_zero
|
||||||
|
and res["units_virtual_available"] <= 0
|
||||||
|
):
|
||||||
|
# If ordering by packages we later bump to one full package.
|
||||||
|
qty_to_order = max(qty_to_order, 1)
|
||||||
res["units_included_original"] = qty_to_order
|
res["units_included_original"] = qty_to_order
|
||||||
|
|
||||||
# Adjust qty_to_order to packaging multiples if order_by_packages is checked
|
# Adjust qty_to_order to packaging multiples if order_by_packages is checked
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue