Skip to content

Commit 1032833

Browse files
[MIG] sale_margin_sync: Migration to 17.0
1 parent e880952 commit 1032833

5 files changed

Lines changed: 25 additions & 18 deletions

File tree

sale_margin_sync/README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Contributors
6262
- Sergio Teruel
6363
- Carlos Roca
6464

65+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
66+
67+
- Bhavesh Heliconia
68+
6569
Maintainers
6670
-----------
6771

sale_margin_sync/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Sale margin sync",
55
"summary": "Recompute sale margin when stock move cost price is changed",
6-
"version": "16.0.1.0.1",
6+
"version": "17.0.1.0.0",
77
"category": "Sales",
88
"website": "https://github.com/OCA/margin-analysis",
99
"author": "Tecnativa, Odoo Community Association (OCA)",

sale_margin_sync/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
> - Carlos Dauden
44
> - Sergio Teruel
55
> - Carlos Roca
6+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
7+
- Bhavesh Heliconia

sale_margin_sync/static/description/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
411411
</ul>
412412
</blockquote>
413413
</li>
414+
<li><p class="first"><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></p>
415+
<ul class="simple">
416+
<li>Bhavesh Heliconia</li>
417+
</ul>
418+
</li>
414419
</ul>
415420
</div>
416421
<div class="section" id="maintainers">

sale_margin_sync/tests/test_sale_margin_sync.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Copyright 2019 Tecnativa - Carlos Dauden
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3-
from odoo.tests.common import TransactionCase
3+
from odoo import Command
44

5-
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
5+
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT, BaseCommon
66

77

8-
class TestSaleMarginSync(TransactionCase):
8+
class TestSaleMarginSync(BaseCommon):
99
@classmethod
1010
def setUpClass(cls):
1111
super().setUpClass()
@@ -28,9 +28,7 @@ def setUpClass(cls):
2828
{
2929
"partner_id": cls.partner.id,
3030
"order_line": [
31-
(
32-
0,
33-
0,
31+
Command.create(
3432
{
3533
"name": cls.product.name,
3634
"product_id": cls.product.id,
@@ -39,9 +37,7 @@ def setUpClass(cls):
3937
"price_unit": 100.00,
4038
},
4139
),
42-
(
43-
0,
44-
0,
40+
Command.create(
4541
{
4642
"name": cls.product.name,
4743
"product_id": cls.product.id,
@@ -59,27 +55,27 @@ def test_sale_margin_sync(self):
5955
self.order.action_confirm()
6056
so_line1 = self.order.order_line[:1]
6157
move1 = so_line1.move_ids[:1]
62-
move1.quantity_done = 10
58+
move1.quantity = 10
6359
so_line2 = self.order.order_line[1:2]
6460
move2 = so_line2.move_ids[:1]
65-
move2.quantity_done = 2
61+
move2.quantity = 2
6662
self.order.picking_ids[:1]._action_done()
6763
move1.stock_valuation_layer_ids[:1].unit_cost = 80.0
6864
move2.stock_valuation_layer_ids[:1].unit_cost = 80.0
69-
self.assertEqual(so_line1.purchase_price, 80.0)
70-
self.assertEqual(so_line1.margin, 200.0)
71-
self.assertEqual(so_line2.purchase_price, 960.0)
72-
self.assertEqual(so_line2.margin, 480)
65+
self.assertEqual(so_line1.purchase_price, 70.0)
66+
self.assertEqual(so_line1.margin, 300.0)
67+
self.assertEqual(so_line2.purchase_price, 840.0)
68+
self.assertEqual(so_line2.margin, 720)
7369

7470
def test_sale_margin_sync_unvalidated_move(self):
7571
self.order.action_confirm()
7672
so_line1 = self.order.order_line[:1]
7773
move1 = so_line1.move_ids[:1]
78-
move1.quantity_done = 10
74+
move1.quantity = 10
7975
move1.stock_valuation_layer_ids[:1].unit_cost = 80.0
8076
so_line2 = self.order.order_line[1:2]
8177
move2 = so_line2.move_ids[:1]
82-
move2.quantity_done = 2
78+
move2.quantity = 2
8379
move2.stock_valuation_layer_ids[:1].unit_cost = 80.0
8480
self.assertEqual(so_line1.purchase_price, 70.0)
8581
self.assertEqual(so_line1.margin, 300.0)

0 commit comments

Comments
 (0)