Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
dd3c220
[ADD] sale_margin_delivered: New Module
chienandalu Jul 9, 2018
84ed49d
[IMP] sale_margin_delivered: Add new computed field for better contro…
sergio-teruel Nov 13, 2018
99d5930
[11.0][FIX] sale_margin_delivered: Set % delivered percent to 0.0 if …
sergio-teruel Jan 14, 2019
5ca1b9d
[11.0][FIX] sale_margin_delivered: Fix cost price unit from stock mov…
sergio-teruel Apr 15, 2019
6bc147b
[11.0][IMP] sale_margin_delivered: take an account returned moves
sergio-teruel Apr 16, 2019
45a65fd
[11.0][IMP] sale_margin_delivered: Compute avoid use product_uom_qty …
sergio-teruel Apr 17, 2019
cc4ed21
[IMP] stock_picking_comment_template: Change field label to fix travi…
sergio-teruel Dec 3, 2019
5b1d7a7
[IMP] sale_margin_delivered: black, isort
sergio-teruel Feb 24, 2020
ea95156
[MIG] sale_margin_delivered: Migration to v13.0
sergio-teruel Feb 24, 2020
fc7db8e
[FIX] sale_margin_delivered: Fix compute avco from stock valuation la…
sergio-teruel Sep 18, 2020
34534cd
[FIX] sale_margin_delivered: Fix cache miss error.
sergio-teruel Sep 22, 2020
cd47d38
[FIX] sale_margin_delivered: Fix division by zero if no price_reduce
sergio-teruel Sep 22, 2020
1137112
[FIX] sale_margin_delivered: Delivered values not zero when sale line…
carlosdauden Oct 8, 2020
62c7154
[FIX] sale_margin_delivered: Use Form in tests to avoid crash test du…
sergio-teruel Sep 6, 2021
8cc7cd6
[MIG] sale_margin_delivered: Migration to 15.0
CarlosRoca13 Nov 7, 2022
5dde111
[FIX] sale_margin_delivered: non storable
chienandalu Jan 3, 2022
5aeda53
[MIG] sale_margin_delivered: Migration to 16.0
pilarvargas-tecnativa Sep 12, 2023
7bd9143
[REF] split sale_margin_delivered into sale_margin_delivered and sale…
legalsylvain Sep 13, 2023
e26f4f7
[OU-ADD] sale_margin_delivered: Script to install sale_margin_deliver…
pilarvargas-tecnativa Sep 14, 2023
6f27dbb
Translated using Weblate (Spanish)
Ivorra78 Sep 27, 2023
70ccba7
[IMP] sale_margin_delivered: test performance improvement
josep-tecnativa Oct 20, 2023
fa6d5a8
Added translation using Weblate (Italian)
mymage Feb 1, 2024
32d1b83
Translated using Weblate (Italian)
mymage Feb 1, 2024
cbff335
[FIX] sale_margin_delivered: Fix calculation when more quantities are…
Shide May 31, 2024
9970837
Translated using Weblate (Italian)
mymage Jun 5, 2024
7a2c748
[FIX] sale_margin_delivered: Margin Delivered (%) help doesn't match …
Shide Jun 14, 2024
fe8825f
[REF] sale_margin_delivered: Preparate module to Dropshipping compati…
Shide Jun 18, 2024
451df4d
[FIX] sale_margin_delivered: Increase version due to multi commit on PR
Shide Jun 19, 2024
888d720
[FIX] sale_margin_delivered: Uses the right field to get price reduce
lmignon Jun 18, 2024
4dcfa65
[IMP] sale_margin_delivered: Improve UI
lmignon Jun 19, 2024
7efc740
[IMP] sale_margin_delivered: Store margin delivered percent as a frat…
lmignon Jun 19, 2024
50ed6ce
[FIX] sale_margin_analysis: Avoid ZeroDivisionError
lmignon Jun 20, 2024
c356d80
Translated using Weblate (Italian)
mymage Jun 24, 2024
03562e3
[IMP] sale_margin_delivered: pre-commit auto fixes
BhaveshHeliconia Feb 21, 2025
e6a2d95
[MIG] sale_margin_delivered: Migration to 17.0
BhaveshHeliconia Feb 21, 2025
38863c6
[REF] split sale_margin_delivered into sale_margin_delivered and sale…
legalsylvain Sep 13, 2023
d25c94f
[ADD] icon.png
OCA-git-bot Sep 15, 2023
4b4de93
Added translation using Weblate (Italian)
mymage Jan 22, 2024
dd1ded0
[IMP] sale_margin_delivered_security: combine with product_cost_security
yajo Mar 8, 2024
ce12410
Translated using Weblate (Italian)
mymage Apr 8, 2024
8bb8c8c
[FIX] sale_margin_delivered_security: Add security groups to right fi…
lmignon Jun 10, 2024
91d5810
Translated using Weblate (Italian)
mymage Jun 24, 2024
c975c6f
[IMP] sale_margin_delivered_security: pre-commit auto fixes
Nov 24, 2025
6f584c7
[MIG] sale_margin_delivered_security: Migration to 18.0
Nov 24, 2025
c2d6136
[UPD] Update sale_margin_delivered_security.pot
Nov 27, 2025
e36dd3f
[BOT] post-merge updates
OCA-git-bot Nov 27, 2025
ea3f259
[IMP] sale_margin_delivered_security: pre-commit auto fixes
rrebollo Feb 28, 2026
d595d08
[MIG] sale_margin_delivered_security: migration to 17.0 (backport fro…
rrebollo Feb 28, 2026
3b3eb87
[DON'T MERGE] test-requirements.txt
rrebollo Feb 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[MIG] sale_margin_delivered: Migration to 15.0
  • Loading branch information
CarlosRoca13 authored and BhaveshHeliconia committed Dec 2, 2025
commit 8cc7cd669ac36c972198a011349042a7c3e45f13
15 changes: 8 additions & 7 deletions sale_margin_delivered/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Sale Margin Delivered
: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/13.0/sale_margin_delivered
:target: https://github.com/OCA/margin-analysis/tree/15.0/sale_margin_delivered
: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-13-0/margin-analysis-13-0-sale_margin_delivered
:target: https://translation.odoo-community.org/projects/margin-analysis-15-0/margin-analysis-15-0-sale_margin_delivered
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/132/13.0
:target: https://runbot.odoo-community.org/runbot/132/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -66,7 +66,7 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/margin-analysis/issues/new?body=module:%20sale_margin_delivered%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/margin-analysis/issues/new?body=module:%20sale_margin_delivered%0Aversion:%2015.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.

Expand All @@ -84,8 +84,9 @@ Contributors

* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel <sergio.teruel@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Sergio Teruel
* David Vidal
* Carlos Roca

Maintainers
~~~~~~~~~~~
Expand All @@ -108,6 +109,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sergio-teruel|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
6 changes: 3 additions & 3 deletions sale_margin_delivered/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Sale Margin Delivered",
"version": "13.0.1.0.2",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"version": "15.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/margin-analysis",
"category": "Sales",
"license": "AGPL-3",
"depends": ["stock_account", "sale_margin_security"],
"depends": ["sale_stock", "sale_margin_security"],
"data": ["views/sale_margin_delivered_view.xml"],
"installable": True,
"development_status": "Production/Stable",
Expand Down
6 changes: 1 addition & 5 deletions sale_margin_delivered/models/sale_margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

margin_delivered = fields.Float(
string="Margin Delivered", compute="_compute_margin_delivered", store=True
)
margin_delivered = fields.Float(compute="_compute_margin_delivered", store=True)
margin_delivered_percent = fields.Float(
string="Margin Delivered Percent",
compute="_compute_margin_delivered",
store=True,
readonly=True,
)
purchase_price_delivery = fields.Float(
string="Purchase Price Delivered",
compute="_compute_margin_delivered",
store=True,
)
Expand Down
5 changes: 3 additions & 2 deletions sale_margin_delivered/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel <sergio.teruel@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Sergio Teruel
* David Vidal
* Carlos Roca
2 changes: 1 addition & 1 deletion sale_margin_delivered/reports/sale_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class SaleReport(models.Model):
_inherit = "sale.report"

margin_delivered = fields.Float(string="Margin Delivered", readonly=True)
margin_delivered = fields.Float(readonly=True)

def _query(self, with_clause="", fields=None, groupby="", from_clause=""):
if fields is None:
Expand Down
18 changes: 8 additions & 10 deletions sale_margin_delivered/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Sale Margin Delivered</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sale Margin Delivered</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/margin-analysis/tree/13.0/sale_margin_delivered"><img alt="OCA/margin-analysis" src="https://img.shields.io/badge/github-OCA%2Fmargin--analysis-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/margin-analysis-13-0/margin-analysis-13-0-sale_margin_delivered"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/132/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/margin-analysis/tree/15.0/sale_margin_delivered"><img alt="OCA/margin-analysis" src="https://img.shields.io/badge/github-OCA%2Fmargin--analysis-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/margin-analysis-15-0/margin-analysis-15-0-sale_margin_delivered"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/132/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Computes sale order lines margins for the delivered items.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -412,7 +412,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/margin-analysis/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/margin-analysis/issues/new?body=module:%20sale_margin_delivered%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/margin-analysis/issues/new?body=module:%20sale_margin_delivered%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -425,14 +425,12 @@ <h2><a class="toc-backref" href="#id5">Authors</a></h2>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul>
<li><p class="first"><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:</p>
<blockquote>
<ul class="simple">
<li>Sergio Teruel &lt;<a class="reference external" href="mailto:sergio.teruel&#64;tecnativa.com">sergio.teruel&#64;tecnativa.com</a>&gt;</li>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Sergio Teruel</li>
<li>David Vidal</li>
<li>Carlos Roca</li>
</ul>
</blockquote>
</li>
</ul>
</div>
Expand All @@ -445,7 +443,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/sergio-teruel"><img alt="sergio-teruel" src="https://github.com/sergio-teruel.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/margin-analysis/tree/13.0/sale_margin_delivered">OCA/margin-analysis</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/margin-analysis/tree/15.0/sale_margin_delivered">OCA/margin-analysis</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
39 changes: 12 additions & 27 deletions sale_margin_delivered/tests/test_sale_margin_delivered.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl
from datetime import datetime

from odoo.tests import Form, SavepointCase
from odoo.tests import Form, TransactionCase


class TestSaleMarginDelivered(SavepointCase):
class TestSaleMarginDelivered(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -50,26 +49,12 @@ def setUpClass(cls):
)

def _new_sale_order(self):
sale_order = self.SaleOrder.new(
{
"date_order": datetime.today(),
"name": "Test_SO011",
"partner_id": self.partner.id,
"order_line": [
(
0,
0,
{
"product_id": self.product.id,
"product_uom_qty": 6,
"product_uom": self.product.uom_id.id,
},
)
],
}
)
sale_order.onchange_partner_id()
return self.SaleOrder.create(sale_order._convert_to_write(sale_order._cache))
sale_order_form = Form(self.SaleOrder)
sale_order_form.partner_id = self.partner
with sale_order_form.order_line.new() as order_line_form:
order_line_form.product_id = self.product
order_line_form.product_uom_qty = 6
return sale_order_form.save()

def get_return_picking_wizard(self, picking):
stock_return_picking_form = Form(
Expand All @@ -94,7 +79,7 @@ def test_sale_margin_delivered(self):
picking = sale_order.picking_ids
picking.action_assign()
picking.move_line_ids.qty_done = 3.0
picking.action_done()
picking._action_done()
order_line = sale_order.order_line[:1]
self.assertEqual(order_line.margin_delivered, 30.0)
self.assertEqual(order_line.margin_delivered_percent, 50.0)
Expand All @@ -117,7 +102,7 @@ def _validate_so_picking(self, sale_order):
picking = sale_order.picking_ids
picking.action_assign()
picking.move_line_ids.qty_done = 6.0
picking.action_done()
picking._action_done()
return picking

def test_sale_margin_delivered_return_to_refund(self):
Expand All @@ -126,7 +111,7 @@ def test_sale_margin_delivered_return_to_refund(self):
picking = self._validate_so_picking(sale_order)
picking_return = self._create_return(picking, to_refund=True)
picking_return.move_line_ids.qty_done = 3.0
picking_return.action_done()
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, 50.0)
Expand All @@ -138,7 +123,7 @@ def test_sale_margin_delivered_return_no_refund(self):
picking = self._validate_so_picking(sale_order)
picking_return = self._create_return(picking, to_refund=False)
picking_return.move_line_ids.qty_done = 3.0
picking_return.action_done()
picking_return._action_done()
order_line = sale_order.order_line[:1]
self.assertEqual(order_line.margin_delivered, 60.0)
self.assertEqual(order_line.margin_delivered_percent, 50.0)
Expand Down
22 changes: 13 additions & 9 deletions sale_margin_delivered/views/sale_margin_delivered_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
<odoo>
<record id="view_order_form" model="ir.ui.view">
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="inherit_id" ref="sale_margin.sale_margin_sale_order_line_form" />
<field
name="groups_id"
eval="[(4,ref('sale_margin_security.group_sale_margin_security'))]"
/>
<field name="arch" type="xml">
<xpath
expr="//field[@name='order_line']/tree//field[@name='tax_id']"
position="before"
>
<field name="margin" string="Margin" />
<field name="purchase_price_delivery" string="Cost Price dlvd." />
<field name="margin_delivered_percent" string="% Margin" />
<field name="margin_delivered" string="Margin dlvd." />
<xpath expr="//field[@name='margin']" position="after">
<field
name="purchase_price_delivery"
string="Cost Price dlvd."
optional="hide"
/>
<field
name="margin_delivered_percent"
string="% Margin"
optional="hide"
/>
<field name="margin_delivered" string="Margin dlvd." optional="hide" />
</xpath>
</field>
</record>
Expand Down