purchase_order_product_recommendation_supermarket: add filter products by main supplier

This commit is contained in:
Luis 2026-04-07 11:47:35 +02:00
parent 524e3d643c
commit f775050ea8
5 changed files with 38 additions and 1 deletions

View file

@ -8,7 +8,7 @@
"license": "AGPL-3", "license": "AGPL-3",
"author": "Criptomart", "author": "Criptomart",
"website": "https://criptomart.net", "website": "https://criptomart.net",
"depends": ["purchase_order_product_recommendation"], "depends": ["purchase_order_product_recommendation", "product_main_seller"],
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",
"wizards/purchase_order_recommendation.xml", "wizards/purchase_order_recommendation.xml",

View file

@ -532,6 +532,20 @@ msgstr ""
"Cantidad de productos comprados durante el periodo (Entre la fecha de inicio" "Cantidad de productos comprados durante el periodo (Entre la fecha de inicio"
" y fecha final)." " y fecha final)."
#. module: purchase_order_product_recommendation_supermarket
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__filter_by_main_seller
msgid "Only main vendor products"
msgstr "Solo productos del proveedor principal"
#. module: purchase_order_product_recommendation_supermarket
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__filter_by_main_seller
msgid ""
"If enabled, only products whose main vendor matches the purchase order "
"vendor will be recommended."
msgstr ""
"Si está activado, solo se recomendarán productos cuyo proveedor principal "
"coincida con el proveedor del pedido de compra."
#. module: purchase_order_product_recommendation_supermarket #. module: purchase_order_product_recommendation_supermarket
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_scrapped #: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_scrapped
msgid "Units Scrapped" msgid "Units Scrapped"

View file

@ -458,6 +458,18 @@ msgstr ""
msgid "Units Received" msgid "Units Received"
msgstr "" msgstr ""
#. module: purchase_order_product_recommendation_supermarket
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__filter_by_main_seller
msgid "Only main vendor products"
msgstr ""
#. module: purchase_order_product_recommendation_supermarket
#: model:ir.model.fields,help:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation__filter_by_main_seller
msgid ""
"If enabled, only products whose main vendor matches the purchase order "
"vendor will be recommended."
msgstr ""
#. module: purchase_order_product_recommendation_supermarket #. module: purchase_order_product_recommendation_supermarket
#: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_scrapped #: model:ir.model.fields,field_description:purchase_order_product_recommendation_supermarket.field_purchase_order_recommendation_line__units_scrapped
msgid "Units Scrapped" msgid "Units Scrapped"

View file

@ -25,6 +25,11 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
default=False, 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.",
) )
filter_by_main_seller = fields.Boolean(
string="Only main vendor products",
default=False,
help="If enabled, only products whose main vendor matches the purchase order vendor will be recommended.",
)
total_days = fields.Integer( total_days = fields.Integer(
string="Total days", string="Total days",
compute="_compute_total_days", compute="_compute_total_days",
@ -306,6 +311,11 @@ class PurchaseOrderRecommendationSupermarketWizard(models.TransientModel):
products = products.filtered( products = products.filtered(
lambda x: x.categ_id.id in self.product_category_ids.ids lambda x: x.categ_id.id in self.product_category_ids.ids
) )
if self.filter_by_main_seller:
partner = self.order_id.partner_id.commercial_partner_id
products = products.filtered(
lambda x: x.product_tmpl_id.main_seller_id == partner
)
return products return products

View file

@ -26,6 +26,7 @@
<field name="date_last_order" /> <field name="date_last_order" />
</field> </field>
<field name="show_all_products" position="after"> <field name="show_all_products" position="after">
<field name="filter_by_main_seller" />
<field name="order_by_packages" /> <field name="order_by_packages" />
<field name="ignore_zero_stock_days" /> <field name="ignore_zero_stock_days" />
<field name="include_previous_period" /> <field name="include_previous_period" />