Skip to content

Commit

Permalink
[MIG] purchase_order_line_sequence: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cjallais committed Apr 23, 2021
1 parent c259180 commit 0d84b1b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 36 deletions.
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
server-ux
stock-logistics-workflow
13 changes: 7 additions & 6 deletions purchase_order_line_sequence/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Purchase Order Line Sequence
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/12.0/purchase_order_line_sequence
:target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-purchase_order_line_sequence
:target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_order_line_sequence
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/142/12.0
:target: https://runbot.odoo-community.org/runbot/142/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|


The sequence in PO line is propagated to the Stock moves. The sequence number
Expand Down Expand Up @@ -53,7 +53,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`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**>`_.
`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**>`_.

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

Expand All @@ -71,6 +71,7 @@ Contributors
~~~~~~~~~~~~


* Cécile Jallais <cjallais@archeti.com>
* Damien Crier <damien.crier@camptocamp.com>
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
Expand All @@ -88,6 +89,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

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.
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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion purchase_order_line_sequence/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import purchase
from . import invoice
from . import purchase_line
6 changes: 0 additions & 6 deletions purchase_order_line_sequence/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.multi
@api.depends("order_line")
def _compute_max_line_sequence(self):
"""Allow to know the highest sequence entered in purchase order lines.
Expand All @@ -26,7 +25,6 @@ def _compute_max_line_sequence(self):
string="Max sequence in lines", compute="_compute_max_line_sequence"
)

@api.multi
def _create_picking(self):
res = super(PurchaseOrder, self)._create_picking()
for order in self:
Expand All @@ -47,21 +45,18 @@ def _create_picking(self):
move.write({"sequence": line.sequence})
return res

@api.multi
def _reset_sequence(self):
for rec in self:
current_sequence = 1
for line in rec.order_line:
line.sequence = current_sequence
current_sequence += 1

@api.multi
def write(self, line_values):
res = super(PurchaseOrder, self).write(line_values)
self._reset_sequence()
return res

@api.multi
def copy(self, default=None):
return super(PurchaseOrder, self.with_context(keep_line_sequence=True)).copy(
default
Expand All @@ -85,7 +80,6 @@ class PurchaseOrderLine(models.Model):
readonly=True,
)

@api.multi
def _prepare_stock_moves(self, picking):
res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking)
for move, line in zip(res, self):
Expand Down
17 changes: 17 additions & 0 deletions purchase_order_line_sequence/models/purchase_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2017 Camptocamp SA - Damien Crier, Alexandre Fayolle
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

def _prepare_account_move_line(self, move=False):
self.ensure_one()
res = super(PurchaseOrderLine, self)._prepare_account_move_line(move)
res["sequence"] = self.sequence

return res
2 changes: 1 addition & 1 deletion purchase_order_line_sequence/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

* Cécile Jallais <cjallais@archeti.com>
* Damien Crier <damien.crier@camptocamp.com>
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
13 changes: 10 additions & 3 deletions purchase_order_line_sequence/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ <h1 class="title">Purchase Order Line Sequence</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<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/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>
<p>The sequence in PO line is propagated to the Stock moves. The sequence number
appears in the PO form view and in the report.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -403,14 +406,16 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<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>
<a class="reference external"
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>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>ArcheTI</li>
<li>Camptocamp</li>
<li>Eficent</li>
<li>Serpent CS</li>
Expand All @@ -419,6 +424,7 @@ <h2><a class="toc-backref" href="#id5">Authors</a></h2>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Cécile Jallias &lt;<a class="reference external" href="mailto:cjallais&#64;archeti.com">cjallais&#64;archeti.com</a>&gt;</li>
<li>Damien Crier &lt;<a class="reference external" href="mailto:damien.crier&#64;camptocamp.com">damien.crier&#64;camptocamp.com</a>&gt;</li>
<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>
<li>Serpent Consulting Services Pvt. Ltd. &lt;<a class="reference external" href="mailto:support&#64;serpentcs.com">support&#64;serpentcs.com</a>&gt;</li>
Expand All @@ -431,7 +437,8 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<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>
<p>This module is part of the <a class="reference external"
href="https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_line_sequence">OCA/purchase-workflow</a> project on GitHub.</p>
<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>
</div>
</div>
Expand Down
25 changes: 8 additions & 17 deletions purchase_order_line_sequence/tests/test_po_lines_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def setUp(self):
self.product_id_1 = self.env.ref("product.product_product_8")
self.product_id_2 = self.env.ref("product.product_product_11")

self.AccountInvoice = self.env["account.invoice"]
self.AccountInvoiceLine = self.env["account.invoice.line"]
self.AccountInvoice = self.env["account.move"]
self.AccountInvoiceLine = self.env["account.move.line"]

self.category = self.env.ref("product.product_category_1").copy(
{
Expand All @@ -31,7 +31,7 @@ def setUp(self):
)

account_type = self.env["account.account.type"].create(
{"name": "RCV type", "type": "other"}
{"name": "RCV type", "type": "other", "internal_group": "expense"}
)
self.account_expense = self.env["account.account"].create(
{
Expand All @@ -52,7 +52,6 @@ def setUp(self):

self.category.property_account_expense_categ_id = self.account_expense

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

po = self._create_purchase_order()
po.button_confirm()
po.picking_ids.action_done()
self.invoice = self.AccountInvoice.create(
{
"partner_id": self.partner_id.id,
"purchase_id": po.id,
"account_id": self.partner_id.property_account_payable_id.id,
"type": "in_invoice",
}
)
self.invoice.purchase_order_change()
self.invoice.action_invoice_open()
po.order_line.qty_received = 5
result = po.action_create_invoice()
self.invoice = self.AccountInvoice.browse(result["res_id"])
self.assertEqual(
po.order_line[0].sequence,
self.invoice.invoice_line_ids[0].sequence,
self.invoice.line_ids[0].sequence,
"The Sequence is not copied properly",
)
self.assertEqual(
po.order_line[1].sequence,
self.invoice.invoice_line_ids[1].sequence,
self.invoice.line_ids[1].sequence,
"The Sequence is not copied properly",
)
2 changes: 1 addition & 1 deletion purchase_order_line_sequence/views/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</xpath>
<xpath expr="//field[@name='order_line']" position="attributes">
<attribute name="context">{'default_sequence':
max_line_sequence}</attribute>
max_line_sequence, 'default_state': 'draft'}</attribute>
</xpath>
<xpath
expr="//field[@name='order_line']/tree/field[@name='product_id']"
Expand Down

0 comments on commit 0d84b1b

Please sign in to comment.