Skip to content

Commit 8619bad

Browse files
[15.0][IMP] maintenance_account: Create equipment description from move line name
1 parent c7f19b9 commit 8619bad

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
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:67684d651aad4f717395cb7f97e2a9d365438bb7ae35f38e692b39cc05848999
10+
!! source digest: sha256:5984a0b0e7a48a82c05223b890a4f95a079864896373f2281b10e7260ec1aad4
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 :]
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">Maintenance Account</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:67684d651aad4f717395cb7f97e2a9d365438bb7ae35f38e692b39cc05848999
370+
!! source digest: sha256:5984a0b0e7a48a82c05223b890a4f95a079864896373f2281b10e7260ec1aad4
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<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/15.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-15-0/maintenance-15-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=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module automatically creates the equipment when validating the purchase invoices.</p>
@@ -417,6 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
417417
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
418418
<li>Víctor Martínez</li>
419419
<li>Pedro M. Baeza</li>
420+
<li>Carolina Fernandez</li>
420421
</ul>
421422
</li>
422423
</ul>

maintenance_account/tests/test_maintenance_account.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Copyright 2022-2023 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
8+
from odoo.tools import html2plaintext
79

810

911
class TestAccountMove(common.TransactionCase):
@@ -66,6 +68,7 @@ def _create_invoice(self, move_type="in_invoice"):
6668
move_form.invoice_date = fields.Date.from_string("2000-01-01")
6769
with move_form.invoice_line_ids.new() as line_form:
6870
line_form.product_id = self.product_a
71+
line_form.name = "Product A \nTest description product A"
6972
line_form.quantity = 2
7073
line_form.account_id = self.account_expense
7174
with move_form.invoice_line_ids.new() as line_form:
@@ -100,7 +103,9 @@ def test_invoice_action_post_equipment_1(self):
100103
self.assertEqual(len(line_a.equipment_ids), 2)
101104
self.assertEqual(len(line_b.equipment_ids), 0)
102105
equipment = fields.first(equipments)
103-
self.assertEqual(equipment.name, self.product_a.name)
106+
name_list = line_a.name.split("\n")
107+
self.assertEqual(equipment.name, name_list[0])
108+
self.assertEqual(html2plaintext(equipment.note), name_list[1])
104109
self.assertEqual(equipment.product_id, self.product_a)
105110
self.assertEqual(equipment.category_id.product_category_id, self.categ)
106111
self.assertEqual(equipment.assign_date, invoice.date)

0 commit comments

Comments
 (0)