Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
[MIG] sale_margin_sync: Migration to 17.0
  • Loading branch information
BhaveshHeliconia committed Dec 15, 2025
commit 8c44ce33641dbfa64d2eb6ddefb879a82feaf7fc
4 changes: 4 additions & 0 deletions sale_margin_sync/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Contributors
- Sergio Teruel
- Carlos Roca

- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion sale_margin_sync/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Sale margin sync",
"summary": "Recompute sale margin when stock move cost price is changed",
"version": "16.0.1.0.1",
"version": "17.0.1.0.0",
"category": "Sales",
"website": "https://github.com/OCA/margin-analysis",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
2 changes: 2 additions & 0 deletions sale_margin_sync/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
> - Carlos Dauden
> - Sergio Teruel
> - Carlos Roca
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
5 changes: 5 additions & 0 deletions sale_margin_sync/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
</ul>
</blockquote>
</li>
<li><p class="first"><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></p>
<ul class="simple">
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
30 changes: 13 additions & 17 deletions sale_margin_sync/tests/test_sale_margin_sync.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2019 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
from odoo import Command

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT, BaseCommon


class TestSaleMarginSync(TransactionCase):
class TestSaleMarginSync(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -28,9 +28,7 @@ def setUpClass(cls):
{
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
Command.create(
{
"name": cls.product.name,
"product_id": cls.product.id,
Expand All @@ -39,9 +37,7 @@ def setUpClass(cls):
"price_unit": 100.00,
},
),
(
0,
0,
Command.create(
{
"name": cls.product.name,
"product_id": cls.product.id,
Expand All @@ -59,27 +55,27 @@ def test_sale_margin_sync(self):
self.order.action_confirm()
so_line1 = self.order.order_line[:1]
move1 = so_line1.move_ids[:1]
move1.quantity_done = 10
move1.quantity = 10
so_line2 = self.order.order_line[1:2]
move2 = so_line2.move_ids[:1]
move2.quantity_done = 2
move2.quantity = 2
self.order.picking_ids[:1]._action_done()
move1.stock_valuation_layer_ids[:1].unit_cost = 80.0
move2.stock_valuation_layer_ids[:1].unit_cost = 80.0
self.assertEqual(so_line1.purchase_price, 80.0)
self.assertEqual(so_line1.margin, 200.0)
self.assertEqual(so_line2.purchase_price, 960.0)
self.assertEqual(so_line2.margin, 480)
self.assertEqual(so_line1.purchase_price, 70.0)
self.assertEqual(so_line1.margin, 300.0)
self.assertEqual(so_line2.purchase_price, 840.0)
self.assertEqual(so_line2.margin, 720)

def test_sale_margin_sync_unvalidated_move(self):
self.order.action_confirm()
so_line1 = self.order.order_line[:1]
move1 = so_line1.move_ids[:1]
move1.quantity_done = 10
move1.quantity = 10
move1.stock_valuation_layer_ids[:1].unit_cost = 80.0
so_line2 = self.order.order_line[1:2]
move2 = so_line2.move_ids[:1]
move2.quantity_done = 2
move2.quantity = 2
move2.stock_valuation_layer_ids[:1].unit_cost = 80.0
self.assertEqual(so_line1.purchase_price, 70.0)
self.assertEqual(so_line1.margin, 300.0)
Expand Down