diff --git a/sale_margin_delivered_dropshipping/README.rst b/sale_margin_delivered_dropshipping/README.rst new file mode 100644 index 00000000..563e4aa1 --- /dev/null +++ b/sale_margin_delivered_dropshipping/README.rst @@ -0,0 +1,127 @@ +================================== +Sale Margin Delivered Dropshipping +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:26f521c15e749b2b0fc883532c1cdec7a52007cc59d5b3e33232fbc636a011d6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.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-17-0/margin-analysis-17-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=17.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 `_ + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +1. To grant Sales Margin view privileges to a user, go to *Settings > + Users & Companies > Users*, select the user and set *Show Sale + Margin* on. +2. Go to *Settings > Purchase > Logistics* and activate *Dropshipping*. +3. 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 +===== + +1. Go to *Sales > Orders > Quotations*. +2. Create a new *Sales Order* and add a line with an stockable product. + Set a quantity higher than one. +3. Confirm the *Sales Order* and deliver just a partial amount of + product in the picking. +4. 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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Moduon + +Contributors +------------ + +- Eduardo de Miguel (`Moduon `__) +- Rafael Blasco (`Moduon `__) +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia + +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 `__: + +|maintainer-Shide| + +This module is part of the `OCA/margin-analysis `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_margin_delivered_dropshipping/__init__.py b/sale_margin_delivered_dropshipping/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/sale_margin_delivered_dropshipping/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_margin_delivered_dropshipping/__manifest__.py b/sale_margin_delivered_dropshipping/__manifest__.py new file mode 100644 index 00000000..d304f65d --- /dev/null +++ b/sale_margin_delivered_dropshipping/__manifest__.py @@ -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": "17.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"], +} diff --git a/sale_margin_delivered_dropshipping/i18n/it.po b/sale_margin_delivered_dropshipping/i18n/it.po new file mode 100644 index 00000000..5dbf84e4 --- /dev/null +++ b/sale_margin_delivered_dropshipping/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_margin_delivered_dropshipping +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-24 14:36+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: sale_margin_delivered_dropshipping +#: model:ir.model,name:sale_margin_delivered_dropshipping.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga ordine di vendita" diff --git a/sale_margin_delivered_dropshipping/i18n/sale_margin_delivered_dropshipping.pot b/sale_margin_delivered_dropshipping/i18n/sale_margin_delivered_dropshipping.pot new file mode 100644 index 00000000..1b6f914f --- /dev/null +++ b/sale_margin_delivered_dropshipping/i18n/sale_margin_delivered_dropshipping.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_margin_delivered_dropshipping +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sale_margin_delivered_dropshipping +#: model:ir.model,name:sale_margin_delivered_dropshipping.model_sale_order_line +msgid "Sales Order Line" +msgstr "" diff --git a/sale_margin_delivered_dropshipping/models/__init__.py b/sale_margin_delivered_dropshipping/models/__init__.py new file mode 100644 index 00000000..7df041a9 --- /dev/null +++ b/sale_margin_delivered_dropshipping/models/__init__.py @@ -0,0 +1 @@ +from . import sale_margin diff --git a/sale_margin_delivered_dropshipping/models/sale_margin.py b/sale_margin_delivered_dropshipping/models/sale_margin.py new file mode 100644 index 00000000..160ffa4c --- /dev/null +++ b/sale_margin_delivered_dropshipping/models/sale_margin.py @@ -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 diff --git a/sale_margin_delivered_dropshipping/pyproject.toml b/sale_margin_delivered_dropshipping/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/sale_margin_delivered_dropshipping/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_margin_delivered_dropshipping/readme/CONFIGURE.md b/sale_margin_delivered_dropshipping/readme/CONFIGURE.md new file mode 100644 index 00000000..ee4c8bb3 --- /dev/null +++ b/sale_margin_delivered_dropshipping/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +1. To grant Sales Margin view privileges to a user, go to *Settings \> + Users & Companies \> Users*, select the user and set *Show Sale + Margin* on. +2. Go to *Settings \> Purchase \> Logistics* and activate + *Dropshipping*. +3. 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*. diff --git a/sale_margin_delivered_dropshipping/readme/CONTRIBUTORS.md b/sale_margin_delivered_dropshipping/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..87f9e568 --- /dev/null +++ b/sale_margin_delivered_dropshipping/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Eduardo de Miguel ([Moduon](https://www.moduon.team/)) +- Rafael Blasco ([Moduon](https://www.moduon.team/)) +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/sale_margin_delivered_dropshipping/readme/DESCRIPTION.md b/sale_margin_delivered_dropshipping/readme/DESCRIPTION.md new file mode 100644 index 00000000..8748901a --- /dev/null +++ b/sale_margin_delivered_dropshipping/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +Computes sale order lines margins for the delivered items. + +This module takes in consideration Outgoing, Returns and Dropship. diff --git a/sale_margin_delivered_dropshipping/readme/USAGE.md b/sale_margin_delivered_dropshipping/readme/USAGE.md new file mode 100644 index 00000000..66db6963 --- /dev/null +++ b/sale_margin_delivered_dropshipping/readme/USAGE.md @@ -0,0 +1,17 @@ +1. Go to *Sales \> Orders \> Quotations*. +2. Create a new *Sales Order* and add a line with an stockable product. + Set a quantity higher than one. +3. Confirm the *Sales Order* and deliver just a partial amount of + product in the picking. +4. 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. diff --git a/sale_margin_delivered_dropshipping/static/description/icon.png b/sale_margin_delivered_dropshipping/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/sale_margin_delivered_dropshipping/static/description/icon.png differ diff --git a/sale_margin_delivered_dropshipping/static/description/index.html b/sale_margin_delivered_dropshipping/static/description/index.html new file mode 100644 index 00000000..9695fc42 --- /dev/null +++ b/sale_margin_delivered_dropshipping/static/description/index.html @@ -0,0 +1,469 @@ + + + + + +Sale Margin Delivered Dropshipping + + + +
+

Sale Margin Delivered Dropshipping

+ + +

Alpha License: AGPL-3 OCA/margin-analysis Translate me on Weblate Try me on Runboat

+

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

+
+

Table of contents

+ +
+

Configuration

+
    +
  1. To grant Sales Margin view privileges to a user, go to Settings > +Users & Companies > Users, select the user and set Show Sale +Margin on.
  2. +
  3. Go to Settings > Purchase > Logistics and activate Dropshipping.
  4. +
  5. 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.
  6. +
+
+
+

Usage

+
    +
  1. Go to Sales > Orders > Quotations.
  2. +
  3. Create a new Sales Order and add a line with an stockable product. +Set a quantity higher than one.
  4. +
  5. Confirm the Sales Order and deliver just a partial amount of +product in the picking.
  6. +
  7. Go to Sales > Reporting > Sales and unfold the Order Reference +dimension and the Margin and Margin Delivered to compare them.
  8. +
+

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. +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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Moduon
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

Shide

+

This module is part of the OCA/margin-analysis project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/sale_margin_delivered_dropshipping/tests/__init__.py b/sale_margin_delivered_dropshipping/tests/__init__.py new file mode 100644 index 00000000..1b3e385e --- /dev/null +++ b/sale_margin_delivered_dropshipping/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl +from . import test_sale_margin_delivered_dropship diff --git a/sale_margin_delivered_dropshipping/tests/test_sale_margin_delivered_dropship.py b/sale_margin_delivered_dropshipping/tests/test_sale_margin_delivered_dropship.py new file mode 100644 index 00000000..29f5afcf --- /dev/null +++ b/sale_margin_delivered_dropshipping/tests/test_sale_margin_delivered_dropship.py @@ -0,0 +1,52 @@ +# Copyright 2024 Moduon Team +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl + + +from odoo.addons.sale_margin_delivered.tests.test_sale_margin_delivered import ( + TestSaleMarginDelivered, +) + + +class TestSaleMarginDeliveredDropship(TestSaleMarginDelivered): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.supplier = cls.env["res.partner"].create( + {"name": "supplier test", "property_product_pricelist": cls.pricelist.id} + ) + dropship_route = cls.env.ref("stock_dropshipping.route_drop_shipping") + cls.dropship_product = cls.env["product.product"].create( + { + "name": "Dropship Product Test", + "type": "product", + "uom_id": cls.product_uom_id.id, + "standard_price": 10.0, + "list_price": 20.00, + "tracking": "none", + "route_ids": [(6, 0, dropship_route.ids)], + } + ) + cls.dropship_product.seller_ids = [ + (0, 0, {"partner_id": cls.supplier.id, "price": 3.0}) + ] + + def test_sale_margin_delivered_dropship(self): + """Delivered quantities by Dropship""" + sale_order = self._new_sale_order(product=self.dropship_product) + sale_order.action_confirm() + purchases = sale_order._get_purchase_orders() + purchases.button_confirm() + dropship_picking = purchases.picking_ids + dropship_picking.move_line_ids.quantity = 6.0 + dropship_picking._action_done() + # Create return for Dropship + picking_return = self._create_return( + dropship_picking, qty_refund=3.0, to_refund=True + ) + picking_return.action_assign() + picking_return.move_line_ids.quantity = 3.0 + picking_return._action_done() + order_line = sale_order.order_line[:1] + self.assertEqual(order_line.margin_delivered, 30.0) + self.assertEqual(order_line.margin_delivered_percent, 0.5) + self.assertEqual(order_line.purchase_price_delivery, order_line.purchase_price) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..f23446af --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-sale_margin_delivered @ git+https://github.com/OCA/margin-analysis.git@refs/pull/239/head#subdirectory=sale_margin_delivered