Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2102 Zobrazení

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

Avatar
Zrušit

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

Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
kvě 25
4195
0
lis 24
1317
1
srp 24
3901
2
kvě 23
2533
2
kvě 20
36