Skip to content

Commit a560da9

Browse files
author
Laurent Stukkens
committed
MIG maintenance_purchase: Migration to 16.0
1 parent d5ddc2b commit a560da9

File tree

5 files changed

+218
-11
lines changed

5 files changed

+218
-11
lines changed

maintenance_purchase/README.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Maintenance Purchase
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:cdeeb0ad0917faf1ff03b0dcd189f588338ba8d0549d0c821152dece33ea8a8c
10+
!! source digest: sha256:4614dc2e45e62ef9fe6cc7642a3e69534c8756793100861c5a08764dde37eee0
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Maintenance Purchase
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github
20-
:target: https://github.com/OCA/maintenance/tree/14.0/maintenance_purchase
20+
:target: https://github.com/OCA/maintenance/tree/16.0/maintenance_purchase
2121
:alt: OCA/maintenance
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase
23+
:target: https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_purchase
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/maintenance&target_branch=14.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/maintenance&target_branch=16.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -41,7 +41,7 @@ Bug Tracker
4141
Bugs are tracked on `GitHub Issues <https://github.com/OCA/maintenance/issues>`_.
4242
In case of trouble, please check there if your issue has already been reported.
4343
If you spotted it first, help us to smash it by providing a detailed and welcomed
44-
`feedback <https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_purchase%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
44+
`feedback <https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_purchase%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
4545

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

@@ -71,6 +71,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
7171
mission is to support the collaborative development of Odoo features and
7272
promote its widespread use.
7373

74-
This module is part of the `OCA/maintenance <https://github.com/OCA/maintenance/tree/14.0/maintenance_purchase>`_ project on GitHub.
74+
This module is part of the `OCA/maintenance <https://github.com/OCA/maintenance/tree/16.0/maintenance_purchase>`_ project on GitHub.
7575

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

maintenance_purchase/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Maintenance Purchase",
66
"summary": """
77
Create Equipments with purchases""",
8-
"version": "14.0.1.0.2",
8+
"version": "16.0.1.0.2",
99
"license": "AGPL-3",
1010
"author": "CreuBlanca,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/maintenance",

maintenance_purchase/static/description/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ <h1 class="title">Maintenance Purchase</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:cdeeb0ad0917faf1ff03b0dcd189f588338ba8d0549d0c821152dece33ea8a8c
370+
!! source digest: sha256:4614dc2e45e62ef9fe6cc7642a3e69534c8756793100861c5a08764dde37eee0
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/maintenance/tree/14.0/maintenance_purchase"><img alt="OCA/maintenance" src="https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/maintenance&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/maintenance/tree/16.0/maintenance_purchase"><img alt="OCA/maintenance" src="https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_purchase"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/maintenance&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>Create Equipments when the purchase is validated.</p>
374374
<p><strong>Table of contents</strong></p>
375375
<div class="contents local topic" id="contents">
@@ -388,7 +388,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
388388
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/maintenance/issues">GitHub Issues</a>.
389389
In case of trouble, please check there if your issue has already been reported.
390390
If you spotted it first, help us to smash it by providing a detailed and welcomed
391-
<a class="reference external" href="https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_purchase%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
391+
<a class="reference external" href="https://github.com/OCA/maintenance/issues/new?body=module:%20maintenance_purchase%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
392392
<p>Do not contact contributors directly about support or help with technical issues.</p>
393393
</div>
394394
<div class="section" id="credits">
@@ -412,7 +412,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
412412
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
413413
mission is to support the collaborative development of Odoo features and
414414
promote its widespread use.</p>
415-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/maintenance/tree/14.0/maintenance_purchase">OCA/maintenance</a> project on GitHub.</p>
415+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/maintenance/tree/16.0/maintenance_purchase">OCA/maintenance</a> project on GitHub.</p>
416416
<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>
417417
</div>
418418
</div>
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_purchase_order
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import Command
5+
from odoo.tests.common import TransactionCase
6+
7+
8+
class TestMaintenanceProject(TransactionCase):
9+
@classmethod
10+
def setUpClass(cls):
11+
super().setUpClass()
12+
13+
cls.Equipment = cls.env["maintenance.equipment"]
14+
cls.EquipmentCategory = cls.env["maintenance.equipment.category"]
15+
cls.MaintenanceEquipmentCategory = cls.env["maintenance.equipment.category"]
16+
cls.PurchaseOrder = cls.env["purchase.order"]
17+
cls.PurchaseOrderLine = cls.env["purchase.order.line"]
18+
cls.ProductCategory = cls.env["product.category"]
19+
cls.ProductProduct = cls.env["product.product"]
20+
cls.ProductTemplate = cls.env["product.template"]
21+
cls.ResPartner = cls.env["res.partner"]
22+
23+
cls.partner = cls.ResPartner.create(
24+
{
25+
"name": "partner",
26+
}
27+
)
28+
uom_unit = cls.env.ref("uom.product_uom_unit")
29+
cls.maintenance_equipment_category1 = cls.MaintenanceEquipmentCategory.create(
30+
{"name": "My Maintenance Equipment Category 1"}
31+
)
32+
cls.maintenance_equipment_category2 = cls.MaintenanceEquipmentCategory.create(
33+
{"name": "My Maintenance Equipment Category 2"}
34+
)
35+
cls.product_category01 = cls.ProductCategory.create(
36+
{
37+
"name": "My Product Category 1",
38+
"equipment_category_ids": [
39+
Command.set(
40+
[
41+
cls.maintenance_equipment_category1.id,
42+
cls.maintenance_equipment_category2.id,
43+
]
44+
)
45+
],
46+
}
47+
)
48+
cls.product_category02 = cls.ProductCategory.create(
49+
{
50+
"name": "My Product Category 2",
51+
"equipment_category_ids": [
52+
Command.set([cls.maintenance_equipment_category2.id])
53+
],
54+
}
55+
)
56+
cls.product_order_maintenance = cls.ProductProduct.create(
57+
{
58+
"name": "My Product",
59+
"standard_price": 235.0,
60+
"list_price": 280.0,
61+
"type": "consu",
62+
"uom_id": uom_unit.id,
63+
"uom_po_id": uom_unit.id,
64+
"purchase_method": "purchase",
65+
"default_code": "PROD_ORDER",
66+
"taxes_id": False,
67+
"maintenance_ok": True,
68+
"categ_id": cls.product_category01.id,
69+
}
70+
)
71+
cls.product_order_no_maintenance = cls.ProductProduct.create(
72+
{
73+
"name": "My Product",
74+
"standard_price": 235.0,
75+
"list_price": 280.0,
76+
"type": "consu",
77+
"uom_id": uom_unit.id,
78+
"uom_po_id": uom_unit.id,
79+
"purchase_method": "purchase",
80+
"default_code": "PROD_ORDER",
81+
"taxes_id": False,
82+
"categ_id": cls.product_category02.id,
83+
}
84+
)
85+
cls.purchase_order = cls.PurchaseOrder.with_context(
86+
tracking_disable=True
87+
).create(
88+
{
89+
"partner_id": cls.partner.id,
90+
}
91+
)
92+
PurchaseOrderLine = cls.PurchaseOrderLine.with_context(tracking_disable=True)
93+
cls.purchase_line_order01 = PurchaseOrderLine.create(
94+
{
95+
"name": cls.product_order_maintenance.name,
96+
"product_id": cls.product_order_maintenance.id,
97+
"product_qty": 10.0,
98+
"product_uom": cls.product_order_maintenance.uom_id.id,
99+
"price_unit": cls.product_order_maintenance.list_price,
100+
"order_id": cls.purchase_order.id,
101+
"taxes_id": False,
102+
}
103+
)
104+
cls.purchase_line_order02 = PurchaseOrderLine.create(
105+
{
106+
"name": cls.product_order_no_maintenance.name,
107+
"product_id": cls.product_order_no_maintenance.id,
108+
"product_qty": 10.0,
109+
"product_uom": cls.product_order_no_maintenance.uom_id.id,
110+
"price_unit": cls.product_order_no_maintenance.list_price,
111+
"order_id": cls.purchase_order.id,
112+
"taxes_id": False,
113+
}
114+
)
115+
116+
def test_equipment_count(self):
117+
self.purchase_order.button_approve()
118+
self.assertEqual(self.purchase_order.equipment_count, 10)
119+
self.assertEqual(self.purchase_line_order01.equipment_count, 10)
120+
self.assertEqual(self.purchase_line_order02.equipment_count, 0)
121+
self.purchase_order.button_draft()
122+
self.purchase_line_order01.product_qty = 1
123+
self.purchase_order.button_approve()
124+
self.assertEqual(self.purchase_order.equipment_count, 10)
125+
self.purchase_order.button_draft()
126+
self.purchase_line_order01.equipment_ids.unlink()
127+
self.purchase_order.button_approve()
128+
self.assertEqual(self.purchase_order.equipment_count, 1)
129+
130+
def test_unlink_purchase_oder(self):
131+
self.purchase_order.button_approve()
132+
equipments = self.purchase_order.order_line.equipment_ids
133+
self.assertEqual(equipments.purchase_id, self.purchase_order)
134+
self.assertEqual(equipments.purchase_line_id, self.purchase_line_order01)
135+
self.purchase_order.button_cancel()
136+
self.assertEqual(equipments.purchase_id, self.purchase_order)
137+
self.assertEqual(equipments.purchase_line_id, self.purchase_line_order01)
138+
self.purchase_order.unlink()
139+
self.assertFalse(equipments.purchase_id)
140+
self.assertFalse(equipments.purchase_line_id)
141+
142+
def test_equipment_category_id(self):
143+
self.assertEqual(
144+
self.purchase_line_order01.equipment_category_id,
145+
self.maintenance_equipment_category1,
146+
)
147+
self.assertFalse(self.purchase_line_order02.equipment_category_id)
148+
self.product_order_no_maintenance.product_tmpl_id.maintenance_ok = True
149+
self.assertFalse(self.purchase_line_order02.equipment_category_id)
150+
self.purchase_line_order02.product_id = self.product_order_maintenance
151+
self.purchase_line_order02.product_id = self.product_order_no_maintenance
152+
self.assertEqual(
153+
self.purchase_line_order02.equipment_category_id,
154+
self.maintenance_equipment_category2,
155+
)
156+
self.purchase_line_order01.equipment_ids.unlink()
157+
self.purchase_line_order01.equipment_category_id = False
158+
self.purchase_order.button_approve()
159+
self.assertEqual(
160+
self.purchase_line_order01.equipment_category_id,
161+
self.maintenance_equipment_category1,
162+
)
163+
self.purchase_line_order01.equipment_ids.unlink()
164+
self.purchase_line_order01.equipment_category_id = False
165+
product_category_withouth_equipement_category = self.ProductCategory.create(
166+
{
167+
"name": "My Product Category 2",
168+
}
169+
)
170+
self.purchase_line_order01.product_id.product_tmpl_id.categ_id = (
171+
product_category_withouth_equipement_category.id
172+
)
173+
self.purchase_order.button_approve()
174+
self.assertTrue(self.purchase_line_order01.equipment_category_id)
175+
self.assertNotEqual(
176+
self.purchase_line_order01.equipment_category_id,
177+
self.maintenance_equipment_category1,
178+
)
179+
180+
def test_account_move_line(self):
181+
self.purchase_order.button_approve()
182+
self.purchase_order.action_create_invoice()
183+
self.assertEqual(
184+
self.purchase_order.order_line.equipment_ids,
185+
self.purchase_order.invoice_ids.line_ids.equipment_ids,
186+
)
187+
188+
def test_action_view_equipments(self):
189+
action = self.purchase_order.action_view_equipments()
190+
self.assertEqual(action, {"type": "ir.actions.act_window_close"})
191+
self.purchase_line_order01.product_qty = 1
192+
self.purchase_order.button_approve()
193+
view = self.env.ref("maintenance.hr_equipment_view_form", False)
194+
action = self.purchase_order.action_view_equipments()
195+
self.assertEqual(action["views"], [(view and view.id or False, "form")])
196+
self.assertEqual(
197+
action["res_id"], self.purchase_line_order01.equipment_ids[0:].id
198+
)
199+
self.purchase_order.button_draft()
200+
self.purchase_line_order01.equipment_ids.unlink()
201+
self.purchase_line_order01.product_qty = 2
202+
self.purchase_order.button_approve()
203+
action = self.purchase_order.action_view_equipments()
204+
self.assertEqual(
205+
action["domain"], [("purchase_id", "=", self.purchase_order.id)]
206+
)

0 commit comments

Comments
 (0)