Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1359 Vizualizări

just wanna find out all products which got no sales, so that we could re -consider the strategy about them.

Imagine profil
Abandonează

It looks like this module - https://apps.odoo.com/apps/modules/17.0/low_sales_report - serve exactly for the goal.

Cel mai bun răspuns

Hi Sigma, 

without any customization, I propose to use a scheduled action with python code. The code will give you a nice error message listing all products which were not sold during a specific period, which you can adjust in the code. Below is an example for getting these values. Of course if you want to only see which products are not delivered in a period or not invoiced in a period, you could use the same strategy but different models in odoo.

This is the code:

def get_unsold_products_in_january(self):

    # Step 1: Find all products that were sold in the given period

    env.cr.execute("""

        SELECT DISTINCT(product_id)

        FROM sale_order_line

        WHERE order_id IN (

            SELECT id FROM sale_order

            WHERE date_order >= '2024-01-01' AND date_order

        )

    """)

    sold_product_ids = [row[0] for row in env.cr.fetchall()]


    # Step 2: Find all products that were not sold in January 2024

    unsold_products = self.env['product.product'].search([

        ('id', 'not in', sold_product_ids)

    ])


    # Step 3: Prepare the message with product internal reference and name

    if unsold_products:

        message = "\n".join([f"{prod.default_code} - {prod.name}" for prod in unsold_products])

        raise UserError(f"The following products were not sold:\n\n{message}")

    else:

        raise UserError("All products were sold.")


Can I help you with this? Contact me at hi (at) latus . ch / thanks! Cheers, Joep

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
mai 25
3217
0
nov. 24
866
1
aug. 24
2625
2
mai 23
1806
2
mai 20
36