Skip to content

Commit

Permalink
[ADD] sale_end_customer
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKoKoLin1997 committed Feb 10, 2025
1 parent 28332aa commit f087089
Show file tree
Hide file tree
Showing 20 changed files with 784 additions and 0 deletions.
78 changes: 78 additions & 0 deletions sale_end_customer/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
=================
Sale End Customer
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e2189bcddcbb1aff8a5a5140465abaa48d95c4e22582f54ecaa5c7375f9cfed5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_end_customer
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_end_customer
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module introduces the partner_end_customer_id field in both sales and invoices, ensuring its propagation from sales orders to invoices.
Additionally, this field enables grouping in sales and invoice analysis.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

In a wholesale company, products are distributed to agents, who then sell them to end customers.
The company also wants to analyze sales based on the end customer, not just the agent.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_end_customer%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Quartile

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_end_customer>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions sale_end_customer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import reports
18 changes: 18 additions & 0 deletions sale_end_customer/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Sale End Customer",
"version": "16.0.1.0.0",
"category": "Sale",
"author": "Quartile, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": ["sale"],
"license": "AGPL-3",
"data": [
"reports/account_invoice_report_views.xml",
"reports/sale_report_views.xml",
"views/account_move_views.xml",
"views/sale_order_views.xml",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions sale_end_customer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move
from . import sale_order
15 changes: 15 additions & 0 deletions sale_end_customer/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountMove(models.Model):
_inherit = "account.move"

partner_end_customer_id = fields.Many2one(
"res.partner",
string="End Customer",
tracking=True,
check_company=True,
)
20 changes: 20 additions & 0 deletions sale_end_customer/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"

partner_end_customer_id = fields.Many2one(
"res.partner",
string="End Customer",
tracking=True,
check_company=True,
)

def _prepare_invoice(self):
invoice_vals = super()._prepare_invoice()
invoice_vals["partner_end_customer_id"] = self.partner_end_customer_id.id
return invoice_vals
2 changes: 2 additions & 0 deletions sale_end_customer/readme/CONTEXT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In a wholesale company, products are distributed to agents, who then sell them to end customers.
The company also wants to analyze sales based on the end customer, not just the agent.
2 changes: 2 additions & 0 deletions sale_end_customer/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module introduces the partner_end_customer_id field in both sales and invoices, ensuring its propagation from sales orders to invoices.
Additionally, this field enables grouping in sales and invoice analysis.
2 changes: 2 additions & 0 deletions sale_end_customer/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_invoice_report
from . import sale_report
17 changes: 17 additions & 0 deletions sale_end_customer/reports/account_invoice_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountInvoiceReport(models.Model):
_inherit = "account.invoice.report"

partner_end_customer_id = fields.Many2one("res.partner", string="End Customer")

def _select(self):
select_str = super()._select()
select_str += """
, move.partner_end_customer_id as partner_end_customer_id
"""
return select_str
16 changes: 16 additions & 0 deletions sale_end_customer/reports/account_invoice_report_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_account_invoice_report_search" model="ir.ui.view">
<field name="inherit_id" ref="account.view_account_invoice_report_search" />
<field name="model">account.invoice.report</field>
<field name="arch" type="xml">
<filter name="user" position="after">
<filter
string="End Customer"
name="partner_end_customer_id"
context="{'group_by':'partner_end_customer_id'}"
/>
</filter>
</field>
</record>
</odoo>
21 changes: 21 additions & 0 deletions sale_end_customer/reports/sale_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 Quartile (https://www.quartile.co)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleReport(models.Model):
_inherit = "sale.report"

partner_end_customer_id = fields.Many2one("res.partner", string="End Customer")

def _select_additional_fields(self):
res = super()._select_additional_fields()
res["partner_end_customer_id"] = "s.partner_end_customer_id"
return res

def _group_by_sale(self):
res = super()._group_by_sale()
res += """,
s.partner_end_customer_id"""
return res
16 changes: 16 additions & 0 deletions sale_end_customer/reports/sale_report_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_order_product_search" model="ir.ui.view">
<field name="inherit_id" ref="sale.view_order_product_search" />
<field name="model">sale.report</field>
<field name="arch" type="xml">
<filter name="User" position="after">
<filter
string="End Customer"
name="partner_end_customer_id"
context="{'group_by':'partner_end_customer_id'}"
/>
</filter>
</field>
</record>
</odoo>
Loading

0 comments on commit f087089

Please sign in to comment.