Skip to content

Commit 0d84b1b

Browse files
committed
[MIG] purchase_order_line_sequence: Migration to 14.0
1 parent c259180 commit 0d84b1b

File tree

10 files changed

+47
-36
lines changed

10 files changed

+47
-36
lines changed

oca_dependencies.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
server-ux
2+
stock-logistics-workflow

purchase_order_line_sequence/README.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ Purchase Order Line Sequence
1414
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1515
:alt: License: AGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
17-
:target: https://github.com/OCA/purchase-workflow/tree/12.0/purchase_order_line_sequence
17+
:target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence
1818
:alt: OCA/purchase-workflow
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-purchase_order_line_sequence
20+
:target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_order_line_sequence
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/142/12.0
23+
:target: https://runbot.odoo-community.org/runbot/142/14.0
2424
:alt: Try me on Runbot
2525

26-
|badge1| |badge2| |badge3| |badge4| |badge5|
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
2727

2828

2929
The sequence in PO line is propagated to the Stock moves. The sequence number
@@ -53,7 +53,7 @@ Bug Tracker
5353
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
5454
In case of trouble, please check there if your issue has already been reported.
5555
If you spotted it first, help us smashing it by providing a detailed and welcomed
56-
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_order_line_sequence%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
56+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_order_line_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5757

5858
Do not contact contributors directly about support or help with technical issues.
5959

@@ -71,6 +71,7 @@ Contributors
7171
~~~~~~~~~~~~
7272

7373

74+
* Cécile Jallais <[email protected]>
7475
* Damien Crier <[email protected]>
7576
* Eficent Business and IT Consulting Services S.L. <[email protected]>
7677
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
@@ -88,6 +89,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
8889
mission is to support the collaborative development of Odoo features and
8990
promote its widespread use.
9091

91-
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/12.0/purchase_order_line_sequence>`_ project on GitHub.
92+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence>`_ project on GitHub.
9293

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

purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 12.0\n"
7+
"Project-Id-Version: Odoo Server 14.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"Last-Translator: <>\n"
1010
"Language-Team: \n"
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
22

33
from . import purchase
4-
from . import invoice
4+
from . import purchase_line

purchase_order_line_sequence/models/purchase.py

-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
class PurchaseOrder(models.Model):
1010
_inherit = "purchase.order"
1111

12-
@api.multi
1312
@api.depends("order_line")
1413
def _compute_max_line_sequence(self):
1514
"""Allow to know the highest sequence entered in purchase order lines.
@@ -26,7 +25,6 @@ def _compute_max_line_sequence(self):
2625
string="Max sequence in lines", compute="_compute_max_line_sequence"
2726
)
2827

29-
@api.multi
3028
def _create_picking(self):
3129
res = super(PurchaseOrder, self)._create_picking()
3230
for order in self:
@@ -47,21 +45,18 @@ def _create_picking(self):
4745
move.write({"sequence": line.sequence})
4846
return res
4947

50-
@api.multi
5148
def _reset_sequence(self):
5249
for rec in self:
5350
current_sequence = 1
5451
for line in rec.order_line:
5552
line.sequence = current_sequence
5653
current_sequence += 1
5754

58-
@api.multi
5955
def write(self, line_values):
6056
res = super(PurchaseOrder, self).write(line_values)
6157
self._reset_sequence()
6258
return res
6359

64-
@api.multi
6560
def copy(self, default=None):
6661
return super(PurchaseOrder, self.with_context(keep_line_sequence=True)).copy(
6762
default
@@ -85,7 +80,6 @@ class PurchaseOrderLine(models.Model):
8580
readonly=True,
8681
)
8782

88-
@api.multi
8983
def _prepare_stock_moves(self, picking):
9084
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking)
9185
for move, line in zip(res, self):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2017 Camptocamp SA - Damien Crier, Alexandre Fayolle
2+
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
3+
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
4+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
5+
6+
from odoo import models
7+
8+
9+
class PurchaseOrderLine(models.Model):
10+
_inherit = "purchase.order.line"
11+
12+
def _prepare_account_move_line(self, move=False):
13+
self.ensure_one()
14+
res = super(PurchaseOrderLine, self)._prepare_account_move_line(move)
15+
res["sequence"] = self.sequence
16+
17+
return res
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
* Cécile Jallais <[email protected]>
22
* Damien Crier <[email protected]>
33
* Eficent Business and IT Consulting Services S.L. <[email protected]>
44
* Serpent Consulting Services Pvt. Ltd. <[email protected]>

purchase_order_line_sequence/static/description/index.html

+10-3
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ <h1 class="title">Purchase Order Line Sequence</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<p><a class="reference external" 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" 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" href="https://github.com/OCA/purchase-workflow/tree/12.0/purchase_order_line_sequence"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-purchase_order_line_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/142/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
370+
<p><a class="reference external"
371+
href="https://odoo-community.org/page/development-status"><img
372+
alt="Beta"
373+
src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" 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" href="https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_order_line_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/142/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
371374
<p>The sequence in PO line is propagated to the Stock moves. The sequence number
372375
appears in the PO form view and in the report.</p>
373376
<p><strong>Table of contents</strong></p>
@@ -403,14 +406,16 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
403406
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
404407
In case of trouble, please check there if your issue has already been reported.
405408
If you spotted it first, help us smashing it by providing a detailed and welcomed
406-
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_order_line_sequence%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
409+
<a class="reference external"
410+
href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_order_line_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
407411
<p>Do not contact contributors directly about support or help with technical issues.</p>
408412
</div>
409413
<div class="section" id="credits">
410414
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
411415
<div class="section" id="authors">
412416
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
413417
<ul class="simple">
418+
<li>ArcheTI</li>
414419
<li>Camptocamp</li>
415420
<li>Eficent</li>
416421
<li>Serpent CS</li>
@@ -419,6 +424,7 @@ <h2><a class="toc-backref" href="#id5">Authors</a></h2>
419424
<div class="section" id="contributors">
420425
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
421426
<ul class="simple">
427+
<li>Cécile Jallias &lt;<a class="reference external" href="mailto:cjallais&#64;archeti.com">cjallais&#64;archeti.com</a>&gt;</li>
422428
<li>Damien Crier &lt;<a class="reference external" href="mailto:damien.crier&#64;camptocamp.com">damien.crier&#64;camptocamp.com</a>&gt;</li>
423429
<li>Eficent Business and IT Consulting Services S.L. &lt;<a class="reference external" href="mailto:contact&#64;eficent.com">contact&#64;eficent.com</a>&gt;</li>
424430
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
@@ -431,7 +437,8 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
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/purchase-workflow/tree/12.0/purchase_order_line_sequence">OCA/purchase-workflow</a> project on GitHub.</p>
440+
<p>This module is part of the <a class="reference external"
441+
href="https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence">OCA/purchase-workflow</a> project on GitHub.</p>
435442
<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>
436443
</div>
437444
</div>

purchase_order_line_sequence/tests/test_po_lines_sequence.py

+8-17
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def setUp(self):
1919
self.product_id_1 = self.env.ref("product.product_product_8")
2020
self.product_id_2 = self.env.ref("product.product_product_11")
2121

22-
self.AccountInvoice = self.env["account.invoice"]
23-
self.AccountInvoiceLine = self.env["account.invoice.line"]
22+
self.AccountInvoice = self.env["account.move"]
23+
self.AccountInvoiceLine = self.env["account.move.line"]
2424

2525
self.category = self.env.ref("product.product_category_1").copy(
2626
{
@@ -31,7 +31,7 @@ def setUp(self):
3131
)
3232

3333
account_type = self.env["account.account.type"].create(
34-
{"name": "RCV type", "type": "other"}
34+
{"name": "RCV type", "type": "other", "internal_group": "expense"}
3535
)
3636
self.account_expense = self.env["account.account"].create(
3737
{
@@ -52,7 +52,6 @@ def setUp(self):
5252

5353
self.category.property_account_expense_categ_id = self.account_expense
5454

55-
self.category.property_stock_account_payable_id = self.account_payable
5655
self.category.property_stock_journal = self.env["account.journal"].create(
5756
{"name": "Stock journal", "type": "sale", "code": "STK00"}
5857
)
@@ -138,24 +137,16 @@ def test_invoice_sequence(self):
138137

139138
po = self._create_purchase_order()
140139
po.button_confirm()
141-
po.picking_ids.action_done()
142-
self.invoice = self.AccountInvoice.create(
143-
{
144-
"partner_id": self.partner_id.id,
145-
"purchase_id": po.id,
146-
"account_id": self.partner_id.property_account_payable_id.id,
147-
"type": "in_invoice",
148-
}
149-
)
150-
self.invoice.purchase_order_change()
151-
self.invoice.action_invoice_open()
140+
po.order_line.qty_received = 5
141+
result = po.action_create_invoice()
142+
self.invoice = self.AccountInvoice.browse(result["res_id"])
152143
self.assertEqual(
153144
po.order_line[0].sequence,
154-
self.invoice.invoice_line_ids[0].sequence,
145+
self.invoice.line_ids[0].sequence,
155146
"The Sequence is not copied properly",
156147
)
157148
self.assertEqual(
158149
po.order_line[1].sequence,
159-
self.invoice.invoice_line_ids[1].sequence,
150+
self.invoice.line_ids[1].sequence,
160151
"The Sequence is not copied properly",
161152
)

purchase_order_line_sequence/views/purchase_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</xpath>
2424
<xpath expr="//field[@name='order_line']" position="attributes">
2525
<attribute name="context">{'default_sequence':
26-
max_line_sequence}</attribute>
26+
max_line_sequence, 'default_state': 'draft'}</attribute>
2727
</xpath>
2828
<xpath
2929
expr="//field[@name='order_line']/tree/field[@name='product_id']"

0 commit comments

Comments
 (0)