Skip to content

Commit fa9db05

Browse files
[MIG] account_move_line_sale_info: Migration to 19.0
1 parent 1dc5cbc commit fa9db05

File tree

9 files changed

+54
-61
lines changed

9 files changed

+54
-61
lines changed

account_move_line_sale_info/README.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
===========================
26
Account Move Line Sale Info
37
===========================
@@ -13,17 +17,17 @@ Account Move Line Sale Info
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
20-
:target: https://github.com/OCA/account-financial-tools/tree/18.0/account_move_line_sale_info
24+
:target: https://github.com/OCA/account-financial-tools/tree/19.0/account_move_line_sale_info
2125
:alt: OCA/account-financial-tools
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_move_line_sale_info
27+
:target: https://translation.odoo-community.org/projects/account-financial-tools-19-0/account-financial-tools-19-0-account_move_line_sale_info
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -54,7 +58,7 @@ Bug Tracker
5458
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
5559
In case of trouble, please check there if your issue has already been reported.
5660
If you spotted it first, help us to smash it by providing a detailed and welcomed
57-
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_line_sale_info%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
61+
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_line_sale_info%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5862

5963
Do not contact contributors directly about support or help with technical issues.
6064

@@ -74,6 +78,8 @@ Contributors
7478

7579
- Andrea Stirpe
7680

81+
- Jasmin Solanki <jasmin.solanki@forgeflow.com>
82+
7783
Maintainers
7884
-----------
7985

@@ -87,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
8793
mission is to support the collaborative development of Odoo features and
8894
promote its widespread use.
8995

90-
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/18.0/account_move_line_sale_info>`_ project on GitHub.
96+
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/19.0/account_move_line_sale_info>`_ project on GitHub.
9197

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

account_move_line_sale_info/__manifest__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
{
55
"name": "Account Move Line Sale Info",
66
"summary": "Introduces the purchase order line to the journal items",
7-
"version": "18.0.1.0.0",
7+
"version": "19.0.1.0.0",
88
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/account-financial-tools",
1010
"category": "Generic",
11-
"depends": [
12-
"account_move_line_stock_info",
13-
"sale_stock",
14-
],
11+
"depends": ["sale_stock", "stock_account"],
1512
"license": "AGPL-3",
1613
"data": ["security/account_security.xml", "views/account_move_view.xml"],
1714
"installable": True,
18-
"post_init_hook": "post_init_hook",
1915
}

account_move_line_sale_info/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def post_init_hook(env):
1010
UPDATE account_move_line aml SET sale_line_id = sm.sale_line_id
1111
FROM account_move_line aml2
1212
INNER JOIN stock_move sm ON
13-
aml2.stock_move_id = sm.id
13+
aml2.id = sm.account_move_id
1414
WHERE aml.id = aml2.id;
1515
"""
1616
)

account_move_line_sale_info/models/account_move.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
class AccountMove(models.Model):
88
_inherit = "account.move"
99

10-
def _stock_account_prepare_anglo_saxon_out_lines_vals(self):
11-
res = super()._stock_account_prepare_anglo_saxon_out_lines_vals()
10+
def _stock_account_prepare_realtime_out_lines_vals(self):
11+
res = super()._stock_account_prepare_realtime_out_lines_vals()
1212
for i, vals in enumerate(res):
1313
am = self.env["account.move"].browse(vals["move_id"])
1414
sale_line_id = am.invoice_line_ids.filtered(
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
# Copyright 2020-23 ForgeFlow S.L.
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
3-
from odoo import api, models
3+
from odoo import models
44

55

66
class StockMove(models.Model):
77
_inherit = "stock.move"
88

9-
@api.model
10-
def _prepare_account_move_line(
11-
self, qty, cost, credit_account_id, debit_account_id, svl_id, description
12-
):
13-
res = super()._prepare_account_move_line(
14-
qty, cost, credit_account_id, debit_account_id, svl_id, description
15-
)
16-
for line in res:
17-
line[2]["sale_line_id"] = self.sale_line_id.id
9+
def _get_account_move_line_vals(self):
10+
res = super()._get_account_move_line_vals()
11+
res[0]["sale_line_id"] = self.sale_line_id.id
1812
return res
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- Aaron Henriquez \<<ahenriquez@forgeflow.com>\>
22
- [360ERP](https://www.360erp.com):
33
- Andrea Stirpe
4+
- Jasmin Solanki \<<jasmin.solanki@forgeflow.com>\>

account_move_line_sale_info/security/account_security.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<odoo>
33
<record id="group_account_move_sale_info" model="res.groups">
44
<field name="name">Sale info in Journal Items</field>
5-
<field name="category_id" ref="base.module_category_hidden" />
6-
<field name="users" eval="[Command.link(ref('base.user_admin'))]" />
5+
<field name="user_ids" eval="[Command.link(ref('base.user_admin'))]" />
76
</record>
87
</odoo>

account_move_line_sale_info/static/description/index.html

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Account Move Line Sale Info</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="account-move-line-sale-info">
364-
<h1 class="title">Account Move Line Sale Info</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="account-move-line-sale-info">
370+
<h1>Account Move Line Sale Info</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:872056df634908873cea158d9d251ce4fd6e5290e02a5f69af1c45a703b4fb01
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
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/account-financial-tools/tree/18.0/account_move_line_sale_info"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_move_line_sale_info"><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/account-financial-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/19.0/account_move_line_sale_info"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-19-0/account-financial-tools-19-0-account_move_line_sale_info"><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/account-financial-tools&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This module will add the sale order line to journal items.</p>
374379
<p>The ultimate goal is to establish the sale order line as one of the key
375380
fields to reconcile the Goods Delivered Not Invoiced accrual account.</p>
@@ -387,7 +392,7 @@ <h1 class="title">Account Move Line Sale Info</h1>
387392
</ul>
388393
</div>
389394
<div class="section" id="usage">
390-
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
395+
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
391396
<p>The sale order line will be automatically copied to the journal items.</p>
392397
<ul class="simple">
393398
<li>When a customer invoice is created referencing sales orders, the sale
@@ -397,44 +402,46 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
397402
</ul>
398403
</div>
399404
<div class="section" id="bug-tracker">
400-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
405+
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
401406
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
402407
In case of trouble, please check there if your issue has already been reported.
403408
If you spotted it first, help us to smash it by providing a detailed and welcomed
404-
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_line_sale_info%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
409+
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_line_sale_info%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
405410
<p>Do not contact contributors directly about support or help with technical issues.</p>
406411
</div>
407412
<div class="section" id="credits">
408-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
413+
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
409414
<div class="section" id="authors">
410-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
415+
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
411416
<ul class="simple">
412417
<li>ForgeFlow S.L.</li>
413418
</ul>
414419
</div>
415420
<div class="section" id="contributors">
416-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
421+
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
417422
<ul class="simple">
418423
<li>Aaron Henriquez &lt;<a class="reference external" href="mailto:ahenriquez&#64;forgeflow.com">ahenriquez&#64;forgeflow.com</a>&gt;</li>
419424
<li><a class="reference external" href="https://www.360erp.com">360ERP</a>:<ul>
420425
<li>Andrea Stirpe</li>
421426
</ul>
422427
</li>
428+
<li>Jasmin Solanki &lt;<a class="reference external" href="mailto:jasmin.solanki&#64;forgeflow.com">jasmin.solanki&#64;forgeflow.com</a>&gt;</li>
423429
</ul>
424430
</div>
425431
<div class="section" id="maintainers">
426-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
432+
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
427433
<p>This module is maintained by the OCA.</p>
428434
<a class="reference external image-reference" href="https://odoo-community.org">
429435
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
430436
</a>
431437
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
432438
mission is to support the collaborative development of Odoo features and
433439
promote its widespread use.</p>
434-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/18.0/account_move_line_sale_info">OCA/account-financial-tools</a> project on GitHub.</p>
440+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/19.0/account_move_line_sale_info">OCA/account-financial-tools</a> project on GitHub.</p>
435441
<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>
436442
</div>
437443
</div>
438444
</div>
445+
</div>
439446
</body>
440447
</html>

account_move_line_sale_info/tests/test_account_move_line_sale_info.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,15 @@ def setUpClass(cls):
1616
cls.aml_model = cls.env["account.move.line"]
1717
cls.res_users_model = cls.env["res.users"]
1818

19-
cls.partner1 = cls.env.ref("base.res_partner_1")
19+
cls.partner1 = cls.env["res.partner"].create(
20+
{"name": "Partner 1", "customer_rank": 1}
21+
)
2022
cls.location_stock = cls.env.ref("stock.stock_location_stock")
2123
cls.company = cls.env.ref("base.main_company")
2224
cls.group_sale_user = cls.env.ref("sales_team.group_sale_salesman")
2325
cls.group_account_invoice = cls.env.ref("account.group_account_invoice")
2426
cls.group_account_manager = cls.env.ref("account.group_account_manager")
2527

26-
# Create account for Goods Received Not Invoiced
27-
acc_type = "equity"
28-
name = "Goods Received Not Invoiced"
29-
code = "grni"
30-
cls.account_grni = cls._create_account(acc_type, name, code, cls.company)
31-
32-
# Create account for Cost of Goods Sold
33-
acc_type = "expense"
34-
name = "Cost of Goods Sold"
35-
code = "cogs"
36-
cls.account_cogs = cls._create_account(acc_type, name, code, cls.company)
3728
# Create account for Inventory
3829
acc_type = "asset_fixed"
3930
name = "Inventory"
@@ -76,7 +67,7 @@ def _create_user(self, login, groups, company):
7667
"email": "test@yourcompany.com",
7768
"company_id": company.id,
7869
"company_ids": [(4, company.id)],
79-
"groups_id": [(6, 0, group_ids)],
70+
"group_ids": [(6, 0, group_ids)],
8071
}
8172
)
8273
return user.id
@@ -97,21 +88,17 @@ def _create_account(self, acc_type, name, code, company):
9788
@classmethod
9889
def _create_product(self):
9990
"""Create a Product."""
100-
# group_ids = [group.id for group in groups]
10191
product_ctg = self.product_ctg_model.create(
10292
{
10393
"name": "test_product_ctg",
10494
"property_stock_valuation_account_id": self.account_inventory.id,
10595
"property_valuation": "real_time",
106-
"property_stock_account_input_categ_id": self.account_grni.id,
107-
"property_stock_account_output_categ_id": self.account_cogs.id,
10896
}
10997
)
11098
product = self.product_model.create(
11199
{
112100
"name": "test_product",
113101
"categ_id": product_ctg.id,
114-
"type": "consu",
115102
"standard_price": 1.0,
116103
"list_price": 1.0,
117104
"is_storable": True,
@@ -130,7 +117,7 @@ def _create_sale(self, line_products):
130117
"name": product.name,
131118
"product_id": product.id,
132119
"product_uom_qty": qty,
133-
"product_uom": product.uom_id.id,
120+
"product_uom_id": product.uom_id.id,
134121
"price_unit": 500,
135122
}
136123
lines.append((0, 0, line_values))
@@ -140,13 +127,15 @@ def _create_sale(self, line_products):
140127

141128
def _get_balance(self, domain):
142129
"""
143-
Call read_group method and return the balance of particular account.
130+
Call _read_group method and return the balance of particular account.
144131
"""
145-
aml_rec = self.aml_model.read_group(
146-
domain, ["debit", "credit", "account_id"], ["account_id"]
132+
aml_rec = self.aml_model._read_group(
133+
domain, groupby=["account_id"], aggregates=["debit:sum", "credit:sum"]
147134
)
148135
if aml_rec:
149-
return aml_rec[0].get("debit", 0) - aml_rec[0].get("credit", 0)
136+
debit = aml_rec[0][1] or 0
137+
credit = aml_rec[0][2] or 0
138+
return debit - credit
150139
else:
151140
return 0.0
152141

@@ -186,6 +175,7 @@ def test_01_sale_invoice(self):
186175
break
187176
sale.action_confirm()
188177
picking = sale.picking_ids[0]
178+
picking.location_id.valuation_account_id = self.account_inventory
189179
picking.move_ids.write({"quantity": 1.0, "picked": True})
190180
picking.button_validate()
191181

0 commit comments

Comments
 (0)