Skip to content

Commit 8eaa93a

Browse files
[16.0][IMP] maintenance_account: Create equipment description from move line name
TT47802
1 parent 802ab72 commit 8eaa93a

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

maintenance_account/README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Maintenance Account
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:dcc1add7dc957ff122be4ff4e3777cad68abf215cc992e2909610be94ef0842a
10+
!! source digest: sha256:396551f06fa48974314ca308f3634616f2e12383244bac71f9f432904463ae8f
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -72,6 +72,7 @@ Contributors
7272

7373
* Víctor Martínez
7474
* Pedro M. Baeza
75+
* Carolina Fernandez
7576

7677
Maintainers
7778
~~~~~~~~~~~

maintenance_account/models/account_move.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2022 Tecnativa - Víctor Martínez
2+
# Copyright 2024 Tecnativa - Carolina Fernandez
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
from odoo import api, fields, models
45

@@ -113,13 +114,20 @@ def _set_equipment_category(self):
113114
self.equipment_category_id = category.id
114115

115116
def _prepare_equipment_vals(self):
117+
equipment_name = self.name
118+
description = False
119+
if "\n" in self.name:
120+
lf_index = self.name.index("\n")
121+
equipment_name = self.name[:lf_index]
122+
description = self.name[lf_index + 1 :].replace("\n", "<br>")
116123
return {
117124
"move_line_id": self.id,
118-
"name": self.product_id.name,
125+
"name": equipment_name,
119126
"product_id": self.product_id.id,
120127
"category_id": self.equipment_category_id.id,
121128
"assign_date": self.move_id.date,
122129
"effective_date": self.move_id.date,
123130
"partner_id": self.move_id.partner_id.id,
124131
"partner_ref": self.move_id.ref,
132+
"note": description,
125133
}

maintenance_account/readme/CONTRIBUTORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
* Víctor Martínez
66
* Pedro M. Baeza
7+
* Carolina Fernandez

maintenance_account/static/description/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
34
<head>
@@ -366,7 +367,7 @@ <h1 class="title">Maintenance Account</h1>
366367
!! This file is generated by oca-gen-addon-readme !!
367368
!! changes will be overwritten. !!
368369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
369-
!! source digest: sha256:dcc1add7dc957ff122be4ff4e3777cad68abf215cc992e2909610be94ef0842a
370+
!! source digest: sha256:396551f06fa48974314ca308f3634616f2e12383244bac71f9f432904463ae8f
370371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
371372
<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_account"><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_account"><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>
372373
<p>This module automatically creates the equipment when validating the purchase invoices.</p>
@@ -416,6 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
416417
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
417418
<li>Víctor Martínez</li>
418419
<li>Pedro M. Baeza</li>
420+
<li>Carolina Fernandez</li>
419421
</ul>
420422
</li>
421423
</ul>

maintenance_account/tests/test_maintenance_account.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# Copyright 2022-2024 Tecnativa - Víctor Martínez
2+
# Copyright 2024 Tecnativa - Carolina Fernandez
23
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
34

45
from odoo import fields
56
from odoo.tests import Form, common, new_test_user
67
from odoo.tests.common import users
78

8-
from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
9-
109

1110
class TestAccountMove(common.TransactionCase):
1211
@classmethod
1312
def setUpClass(cls):
1413
super().setUpClass()
14+
DISABLED_MAIL_CONTEXT = {
15+
"tracking_disable": True,
16+
"mail_create_nolog": True,
17+
"mail_create_nosubscribe": True,
18+
"mail_notrack": True,
19+
"no_reset_password": True,
20+
}
1521
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))
1622
new_test_user(
1723
cls.env, login="test-account-user", groups="account.group_account_invoice"
@@ -27,15 +33,17 @@ def setUpClass(cls):
2733
{
2834
"name": "Test Account",
2935
"code": "TEST",
30-
"account_type": "liability_payable",
36+
"user_type_id": cls.env.ref(
37+
"account.data_account_type_current_liabilities"
38+
).id,
3139
"reconcile": True,
3240
}
3341
)
3442
cls.account_expense = cls.env["account.account"].create(
3543
{
3644
"name": "Test Account",
3745
"code": "ACC",
38-
"account_type": "expense",
46+
"user_type_id": cls.env.ref("account.data_account_type_expenses").id,
3947
}
4048
)
4149
cls.journal = cls.env["account.journal"].create(
@@ -60,6 +68,7 @@ def _create_invoice(self, move_type="in_invoice"):
6068
move_form.invoice_date = fields.Date.from_string("2000-01-01")
6169
with move_form.invoice_line_ids.new() as line_form:
6270
line_form.product_id = self.product_a
71+
line_form.name = "Product A\nTest description product A\n<b>B</b>"
6372
line_form.quantity = 2
6473
with move_form.invoice_line_ids.new() as line_form:
6574
line_form.product_id = self.product_b
@@ -92,8 +101,10 @@ def test_invoice_action_post_equipment_1(self):
92101
self.assertEqual(len(line_a.equipment_ids), 2)
93102
self.assertEqual(len(line_b.equipment_ids), 0)
94103
equipment = fields.first(equipments)
95-
self.assertEqual(equipment.name, self.product_a.name)
96-
self.assertEqual(equipment.product_id, self.product_a)
104+
self.assertEqual(equipment.name, "Product A")
105+
self.assertEqual(
106+
equipment.note, "<p>Test description product A<br><b>B</b></p>"
107+
)
97108
self.assertEqual(equipment.category_id.product_category_id, self.categ)
98109
self.assertEqual(equipment.assign_date, invoice.date)
99110
self.assertEqual(equipment.effective_date, invoice.date)

0 commit comments

Comments
 (0)