Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
108 มุมมอง

Hi all,

I’m trying to generate reports that show how much of our sales (for example, last month) came from new customers vs. existing customers.

Here’s what I’ve tried so far:

  • Looked at invoices: but this only lets me separate whether a customer has been invoiced or not, not when they were first invoiced.
  • Looked at the customer’s creation date: but our sales cycles often extend beyond 28 days, so this isn’t accurate
  • Exported all Sales Orders with order dates into Excel to check if I can filter out based on each customer’s first order date.
  • Checked the documentation, but couldn’t find anything specific to this requirement (just general custom filter examples).

One option I see going forward is to create a custom field on Sales Orders where the sales team can mark/unmark “First Order”. This could help from now on, but it won’t solve the need to look back over the last couple of months.

👉 Has anyone implemented a way to automatically detect whether a Sales Order is the customer’s first order? Ideally, I’d like to have a field (boolean or tag) that marks this, so we can use it directly in Sales Reporting to split revenue between new vs. existing customers.

Thanks in advance for any guidance or best practices!

อวตาร
ละทิ้ง

What you describe initially sounds more like you're interested in the count of SOs, rather than the first date, which would be a computed field on the Contact already. Can you explain?

คำตอบที่ดีที่สุด

Hi,

Odoo doesn’t provide an “out of the box” split between new vs. existing customers in sales reporting.


The most robust way is to flag a Sales Order when it’s the customer’s first order. That way:

    You can easily filter “First Order = True” vs. “False” in sales reporting.

    You can also do revenue analysis for “New Customers” vs. “Returning Customers.”


How to implement it:

    Custom Boolean Field (is_first_order) on sale.order.

    Compute or On-Create Logic:

        When a new Sale Order is created, check if the partner already has a confirmed Sale Order.

        If not, mark is_first_order = True. Otherwise, False.

    Example Python logic:

from odoo import models, fields, api

class SaleOrder(models.Model):

    _inherit = "sale.order"


    is_first_order = fields.Boolean(

        string="First Order", compute="_compute_is_first_order", store=True

    )


    @api.depends('partner_id')

    def _compute_is_first_order(self):

        for order in self:

            if order.partner_id:

                # Check for earlier confirmed sale orders

                previous_orders = self.env['sale.order'].search_count([

                    ('partner_id', '=', order.partner_id.id),

                    ('state', 'in', ['sale', 'done']),

                    ('id', '!=', order.id)

                ])

                order.is_first_order = previous_orders == 0

            else:

                order.is_first_order = False


Use in Reports:

    Add is_first_order to pivot views and custom filters in Sales Analysis.

    Group by “First Order” to split revenue into New vs. Existing customers.


Odoo doesn’t natively distinguish “new vs. existing customers” in reporting. The best practice is to add a custom boolean field on Sales Orders (is_first_order) that is automatically set when the partner has no prior confirmed orders. This allows you to directly filter and group sales by new vs. returning customers in standard Odoo reporting, and you can also retroactively compute it for past orders.


Hope it helps

อวตาร
ละทิ้ง