Skip to content

Commit

Permalink
[ADD] sale_margin_delivered_dropshipping: Compute delivered margins o…
Browse files Browse the repository at this point in the history
…n Dropshipping
  • Loading branch information
Shide committed Jun 19, 2024
1 parent ee56536 commit 6d53293
Show file tree
Hide file tree
Showing 15 changed files with 721 additions and 0 deletions.
124 changes: 124 additions & 0 deletions sale_margin_delivered_dropshipping/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
==================================
Sale Margin Delivered Dropshipping
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5a597b346c2f49f2ccba1b1f44ed58c0c66d0bf10be25e6e8aeb9c56e4674328
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |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%2Fmargin--analysis-lightgray.png?logo=github
:target: https://github.com/OCA/margin-analysis/tree/16.0/sale_margin_delivered_dropshipping
:alt: OCA/margin-analysis
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/margin-analysis-16-0/margin-analysis-16-0-sale_margin_delivered_dropshipping
: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/margin-analysis&target_branch=16.0
:alt: Try me on Runboat

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

Computes sale order lines margins for the delivered items.

This module takes in consideration Outgoing, Returns and Dropship.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

#. To grant Sales Margin view privileges to a user, go to *Settings > Users &
Companies > Users*, select the user and set *Show Sale Margin* on.
#. Go to *Settings > Purchase > Logistics* and activate *Dropshipping*.
#. Configure Dropship Product: Create or Edit an Storable product,
activate Dropship route on *Inventory Tab > Routes* and
add a Product Supplierinfo under *Purchase tab > Vendors*.

Usage
=====

#. Go to *Sales > Orders > Quotations*.
#. Create a new *Sales Order* and add a line with an stockable product. Set a
quantity higher than one.
#. Confirm the *Sales Order* and deliver just a partial amount of product in
the picking.
#. Go to *Sales > Reporting > Sales* and unfold the *Order Reference* dimension
and the *Margin* and *Margin Delivered* to compare them.

For example:

In an order line with a product at a cost of 10 and a sell price of 25 we
deliver 2 of 3 units. Then, the reported margins would be:

`margin`: 45 (3 * 15)
`margin_delivered`: 30 (2 * 15)

Additionally, you can check the margin and the margin percent in the sales
order line.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/margin-analysis/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/margin-analysis/issues/new?body=module:%20sale_margin_delivered_dropshipping%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
~~~~~~~

* Moduon

Contributors
~~~~~~~~~~~~

* Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)

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.

.. |maintainer-Shide| image:: https://github.com/Shide.png?size=40px
:target: https://github.com/Shide
:alt: Shide

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Shide|

This module is part of the `OCA/margin-analysis <https://github.com/OCA/margin-analysis/tree/16.0/sale_margin_delivered_dropshipping>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_margin_delivered_dropshipping/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions sale_margin_delivered_dropshipping/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 Moduon Team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Sale Margin Delivered Dropshipping",
"version": "16.0.1.0.0",
"author": "Moduon, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/margin-analysis",
"category": "Sales",
"license": "AGPL-3",
"depends": ["sale_margin_delivered", "stock_dropshipping"],
"data": [],
"installable": True,
"auto_install": True,
"development_status": "Alpha",
"maintainers": ["Shide"],
}
1 change: 1 addition & 0 deletions sale_margin_delivered_dropshipping/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_margin
23 changes: 23 additions & 0 deletions sale_margin_delivered_dropshipping/models/sale_margin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 Moduon Team
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


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

def _get_delivered_margin_valuation_layers(self):
"""Adds Valuation Layers that involves Dropshipping and not considered
in other scenarios."""
valuation_layers = super()._get_delivered_margin_valuation_layers()
for move in self.move_ids.filtered(lambda m: m.state == "done"):
if (
move.location_dest_usage == "customer"
and move.location_usage == "supplier"
):
# Dropship moves have 2 valuation layers. Use negative one
valuation_layers |= move.stock_valuation_layer_ids.filtered(
lambda vl: vl.quantity < 0
)
return valuation_layers
6 changes: 6 additions & 0 deletions sale_margin_delivered_dropshipping/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#. To grant Sales Margin view privileges to a user, go to *Settings > Users &
Companies > Users*, select the user and set *Show Sale Margin* on.
#. Go to *Settings > Purchase > Logistics* and activate *Dropshipping*.
#. Configure Dropship Product: Create or Edit an Storable product,
activate Dropship route on *Inventory Tab > Routes* and
add a Product Supplierinfo under *Purchase tab > Vendors*.
2 changes: 2 additions & 0 deletions sale_margin_delivered_dropshipping/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)
3 changes: 3 additions & 0 deletions sale_margin_delivered_dropshipping/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Computes sale order lines margins for the delivered items.

This module takes in consideration Outgoing, Returns and Dropship.
18 changes: 18 additions & 0 deletions sale_margin_delivered_dropshipping/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#. Go to *Sales > Orders > Quotations*.
#. Create a new *Sales Order* and add a line with an stockable product. Set a
quantity higher than one.
#. Confirm the *Sales Order* and deliver just a partial amount of product in
the picking.
#. Go to *Sales > Reporting > Sales* and unfold the *Order Reference* dimension
and the *Margin* and *Margin Delivered* to compare them.

For example:

In an order line with a product at a cost of 10 and a sell price of 25 we
deliver 2 of 3 units. Then, the reported margins would be:

`margin`: 45 (3 * 15)
`margin_delivered`: 30 (2 * 15)

Additionally, you can check the margin and the margin percent in the sales
order line.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6d53293

Please sign in to comment.