From 0d84b1b8fe2b6b81cfaa504e894613913f064230 Mon Sep 17 00:00:00 2001 From: Cecile Jallais Date: Thu, 7 Jan 2021 15:59:42 -0500 Subject: [PATCH] [MIG] purchase_order_line_sequence: Migration to 14.0 --- oca_dependencies.txt | 1 + purchase_order_line_sequence/README.rst | 13 +++++----- .../i18n/purchase_order_line_sequence.pot | 2 +- .../models/__init__.py | 2 +- .../models/purchase.py | 6 ----- .../models/purchase_line.py | 17 +++++++++++++ .../readme/CONTRIBUTORS.rst | 2 +- .../static/description/index.html | 13 +++++++--- .../tests/test_po_lines_sequence.py | 25 ++++++------------- .../views/purchase_view.xml | 2 +- 10 files changed, 47 insertions(+), 36 deletions(-) create mode 100644 purchase_order_line_sequence/models/purchase_line.py diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 9b5df92e930..cde79641545 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1 +1,2 @@ server-ux +stock-logistics-workflow diff --git a/purchase_order_line_sequence/README.rst b/purchase_order_line_sequence/README.rst index cb3d1cdbaea..02e3fc32857 100644 --- a/purchase_order_line_sequence/README.rst +++ b/purchase_order_line_sequence/README.rst @@ -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 @@ -53,7 +53,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -71,6 +71,7 @@ Contributors ~~~~~~~~~~~~ +* Cécile Jallais * Damien Crier * Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. @@ -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 `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot b/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot index 1529e0cf3dd..d32df210c1d 100644 --- a/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot +++ b/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot @@ -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" diff --git a/purchase_order_line_sequence/models/__init__.py b/purchase_order_line_sequence/models/__init__.py index f8fdab0f427..f51c18ab63e 100644 --- a/purchase_order_line_sequence/models/__init__.py +++ b/purchase_order_line_sequence/models/__init__.py @@ -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 diff --git a/purchase_order_line_sequence/models/purchase.py b/purchase_order_line_sequence/models/purchase.py index 42718bb071f..76f30d35528 100644 --- a/purchase_order_line_sequence/models/purchase.py +++ b/purchase_order_line_sequence/models/purchase.py @@ -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. @@ -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: @@ -47,7 +45,6 @@ def _create_picking(self): move.write({"sequence": line.sequence}) return res - @api.multi def _reset_sequence(self): for rec in self: current_sequence = 1 @@ -55,13 +52,11 @@ def _reset_sequence(self): 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 @@ -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): diff --git a/purchase_order_line_sequence/models/purchase_line.py b/purchase_order_line_sequence/models/purchase_line.py new file mode 100644 index 00000000000..feab1219a57 --- /dev/null +++ b/purchase_order_line_sequence/models/purchase_line.py @@ -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 diff --git a/purchase_order_line_sequence/readme/CONTRIBUTORS.rst b/purchase_order_line_sequence/readme/CONTRIBUTORS.rst index 7cdefa7f0cc..6d9b78e0490 100644 --- a/purchase_order_line_sequence/readme/CONTRIBUTORS.rst +++ b/purchase_order_line_sequence/readme/CONTRIBUTORS.rst @@ -1,4 +1,4 @@ - +* Cécile Jallais * Damien Crier * Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. diff --git a/purchase_order_line_sequence/static/description/index.html b/purchase_order_line_sequence/static/description/index.html index 0b0e80ca225..154e18566de 100644 --- a/purchase_order_line_sequence/static/description/index.html +++ b/purchase_order_line_sequence/static/description/index.html @@ -367,7 +367,10 @@

Purchase Order Line Sequence

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

The sequence in PO line is propagated to the Stock moves. The sequence number appears in the PO form view and in the report.

Table of contents

@@ -403,7 +406,8 @@

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -411,6 +415,7 @@

Credits

Authors

diff --git a/purchase_order_line_sequence/tests/test_po_lines_sequence.py b/purchase_order_line_sequence/tests/test_po_lines_sequence.py index 5c8302e49a2..6b80e3c9495 100644 --- a/purchase_order_line_sequence/tests/test_po_lines_sequence.py +++ b/purchase_order_line_sequence/tests/test_po_lines_sequence.py @@ -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( { @@ -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( { @@ -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"} ) @@ -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", ) diff --git a/purchase_order_line_sequence/views/purchase_view.xml b/purchase_order_line_sequence/views/purchase_view.xml index d93156e1113..745ac068d17 100644 --- a/purchase_order_line_sequence/views/purchase_view.xml +++ b/purchase_order_line_sequence/views/purchase_view.xml @@ -23,7 +23,7 @@ {'default_sequence': - max_line_sequence} + max_line_sequence, 'default_state': 'draft'}