Skip to content

Commit

Permalink
[IMP] product_template_year_consumption: Use sales_count
Browse files Browse the repository at this point in the history
  • Loading branch information
unaiberis committed Oct 11, 2024
1 parent 7d98a80 commit e32b23a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 29 deletions.
55 changes: 41 additions & 14 deletions product_template_year_consumption/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,89 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-02-10 09:57+0000\n"
"PO-Revision-Date: 2022-02-10 09:57+0000\n"
"POT-Creation-Date: 2024-10-10 14:26+0000\n"
"PO-Revision-Date: 2024-10-10 14:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__consumed_last_twelve_months
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__consumed_last_twelve_months
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint__consumed_last_twelve_months
msgid "Consumed last twelve months"
msgstr "Consumo últ. 12 meses a fecha"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__year_consumption
msgid "Consumption in a Year"
msgstr "Consumo en un año"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__display_name
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__display_name
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__id
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__id
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint__id
msgid "ID"
msgstr ""

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product____last_update
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template____last_update
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint____last_update
msgid "Last Modified on"
msgstr "Última modificación el"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__main_seller_id
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__main_seller_id
#: model_terms:ir.ui.view,arch_db:product_template_year_consumption.product_template_search_view
msgid "Main Seller"
msgstr "Proveedor principal"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__main_seller_price
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__main_seller_price
msgid "Main Seller Price"
msgstr "Precio proveedor principal"
#: model:ir.model,name:product_template_year_consumption.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr "Regla de inventario mínimo"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__month_forecast
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__month_forecast
msgid "Month Forecast"
msgstr "Previsión"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint__months_with_stock_sales_count
msgid "Months with Stock (Sales Count and Qty Forecast)"
msgstr "Meses stock ventas"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_product__months_with_stock
#: model:ir.model.fields,field_description:product_template_year_consumption.field_product_template__months_with_stock
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint__months_with_stock
msgid "Months with stock"
msgstr "Meses con stock"

#. module: product_template_year_consumption
#: model:ir.model,name:product_template_year_consumption.model_product_product
msgid "Product"
msgstr "Producto"

#. module: product_template_year_consumption
#: model:ir.model,name:product_template_year_consumption.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: product_template_year_consumption
#: model:ir.model.fields,field_description:product_template_year_consumption.field_stock_warehouse_orderpoint__sales_count
msgid "Sales Count"
msgstr "Ventas ult.12 meses"

#. module: product_template_year_consumption
#: model:ir.actions.server,name:product_template_year_consumption.action_update_product_consumption
msgid "Update Product Consumption"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ class StockWarehouseOrderpoint(models.Model):
related="product_id.consumed_last_twelve_months",
)
months_with_stock = fields.Integer(
string="Months with stock", related="product_id.months_with_stock"
string="Months with stock",
related="product_id.months_with_stock",
)
sales_count = fields.Float(
string="Sales Count", related="product_id.sales_count", store=True
string="Sales Count",
related="product_id.sales_count",
store=True,
)
months_with_stock_sales_count = fields.Float(
string="Months with Stock (Sales Count)",
compute="_compute_months_with_stock_sales_count",
months_sales_count_and_qty_forecast = fields.Integer(
string="Months with Stock (Sales Count and Qty Forecast)",
compute="_compute_months_sales_count_and_qty_forecast",
)

def _compute_months_with_stock_sales_count(self):
# prevision / sales_count * 12
def _compute_months_sales_count_and_qty_forecast(self):
for orderpoint in self:
months_with_stock = 0
consumed_last_twelve_months = orderpoint.consumed_last_twelve_months
if consumed_last_twelve_months:
virtual_available = orderpoint.product_id.virtual_available
months_with_stock = virtual_available / (
consumed_last_twelve_months / 12
)
orderpoint.months_with_stock_sales_count = months_with_stock
sales_count = orderpoint.sales_count
if sales_count:
qty_forecast = orderpoint.qty_forecast
months_with_stock = round(qty_forecast / (sales_count / 12))
orderpoint.months_sales_count_and_qty_forecast = months_with_stock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field name="consumed_last_twelve_months" optional="show" />
<field name="months_with_stock" optional="show" />
<field name="sales_count" optional="show" />
<field name="months_with_stock_sales_count" optional="show" />
<field name="months_sales_count_and_qty_forecast" optional="show" />
</field>
</field>
</record>
Expand All @@ -24,7 +24,7 @@
<field name="consumed_last_twelve_months" optional="show" />
<field name="months_with_stock" optional="show" />
<field name="sales_count" optional="show" />
<field name="months_with_stock_sales_count" optional="show" />
<field name="months_sales_count_and_qty_forecast" optional="show" />
</field>
</field>
</record>
Expand Down

0 comments on commit e32b23a

Please sign in to comment.