Skip to content

Commit

Permalink
[ADD] sale_order_blanket_order_sale_margin: Manage margin on call off…
Browse files Browse the repository at this point in the history
… orders

This module extends the functionality of the module sale_order_blanket_order and sale_margin to ensure that the margin calculation takes into account the specific case of cutt off orders. In the case of a cutt off order, the margin must be set to 0 since the financial impact of the order is managed on the blanket order.
  • Loading branch information
lmignon committed Dec 17, 2024
1 parent dff351c commit 8437e3e
Show file tree
Hide file tree
Showing 15 changed files with 627 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ jobs:
name: test with OCB
makepot: "true"
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
exclude: "sale_packaging_default,sale_order_product_recommendation,sale_order_product_recommendation_packaging_default,sale_order_product_recommendation_elaboration,sale_order_blanket_order,sale_order_blanket_order_stock_prebook"
exclude: "sale_packaging_default,sale_order_product_recommendation,sale_order_product_recommendation_packaging_default,sale_order_product_recommendation_elaboration,sale_order_blanket_order,sale_order_blanket_order_stock_prebook,sale_order_blanket_order_sale_margin"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
exclude: "sale_packaging_default,sale_order_product_recommendation,sale_order_product_recommendation_packaging_default,sale_order_product_recommendation_elaboration,sale_order_blanket_order,sale_order_blanket_order_stock_prebook"
exclude: "sale_packaging_default,sale_order_product_recommendation,sale_order_product_recommendation_packaging_default,sale_order_product_recommendation_elaboration,sale_order_blanket_order,sale_order_blanket_order_stock_prebook,sale_order_blanket_order_sale_margin"
name: test with OCB
makepot: "true"
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
include: "sale_order_blanket_order,sale_order_blanket_order_stock_prebook"
include: "sale_order_blanket_order,sale_order_blanket_order_stock_prebook,sale_order_blanket_order_sale_margin"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
include: "sale_order_blanket_order,sale_order_blanket_order_stock_prebook"
include: "sale_order_blanket_order,sale_order_blanket_order_stock_prebook,sale_order_blanket_order_sale_margin"
name: test with OCB
makepot: "true"
services:
Expand Down
87 changes: 87 additions & 0 deletions sale_order_blanket_order_sale_margin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
====================================
Sale Order Blanket Order Sale Margin
====================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a07cbf0ee02f74a6c7f6713cf50738d7bbedecc906b7e8ade43e2a1ad390edaf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_order_blanket_order_sale_margin
: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_order_blanket_order_sale_margin
: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 extends the functionality of the module
sale_order_blanket_order and sale_margin to ensure that the margin
calculation takes into account the specific case of cutt off orders. In
the case of a cutt off order, the margin must be set to 0 since the
financial impact of the order is managed on the blanket order.

**Table of contents**

.. contents::
:local:

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_order_blanket_order_sale_margin%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
-------

* ACSONE SA/NV

Contributors
------------

- Laurent Mignon\ [email protected] (https://www.acsone.eu)

Other credits
-------------

The development of this module has been financially supported by:

- ALCYON Belux

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_order_blanket_order_sale_margin>`_ 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_order_blanket_order_sale_margin/__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_order_blanket_order_sale_margin/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sale Order Blanket Order Sale Margin",
"summary": """Ensure sale margins are properly set on call off order lines""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": [
"sale_order_blanket_order",
"sale_margin",
],
"auto_install": True,
}
1 change: 1 addition & 0 deletions sale_order_blanket_order_sale_margin/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order_line
16 changes: 16 additions & 0 deletions sale_order_blanket_order_sale_margin/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models


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

def _compute_margin(self):
# Overload to consider the call-off order lines in the computation
# For these lines the margin must be set to 0
call_off_lines = self.filtered(lambda l: l.order_type == "call_off")
other_lines = self - call_off_lines
call_off_lines.margin = 0
call_off_lines.margin_percent = 0
return super(SaleOrderLine, other_lines)._compute_margin()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Laurent Mignon<[email protected]> (https://www.acsone.eu)
3 changes: 3 additions & 0 deletions sale_order_blanket_order_sale_margin/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

- ALCYON Belux
1 change: 1 addition & 0 deletions sale_order_blanket_order_sale_margin/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module extends the functionality of the module sale_order_blanket_order and sale_margin to ensure that the margin calculation takes into account the specific case of cutt off orders. In the case of a cutt off order, the margin must be set to 0 since the financial impact of the order is managed on the blanket order.
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 8437e3e

Please sign in to comment.