diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 56860b7ad4f..5698b793357 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1,2 +1,3 @@ server-ux +stock-logistics-workflow product-attribute diff --git a/purchase_order_line_sequence/README.rst b/purchase_order_line_sequence/README.rst new file mode 100644 index 00000000000..02e3fc32857 --- /dev/null +++ b/purchase_order_line_sequence/README.rst @@ -0,0 +1,94 @@ +============================ +Purchase Order Line Sequence +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/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-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/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + + +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** + +.. contents:: + :local: + +Usage +===== + + +This module depends on the following module(s) : + * stock_picking_line_sequence (https://github.com/OCA/stock-logistics-workflow/) + +Known issues / Roadmap +====================== + + +In standard odoo is possible to sort the purchase order lines and those are propagated to the invoice lines + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp +* Eficent +* Serpent CS + +Contributors +~~~~~~~~~~~~ + + +* Cécile Jallais +* Damien Crier +* Eficent Business and IT Consulting Services S.L. +* Serpent Consulting Services Pvt. Ltd. + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_order_line_sequence/__init__.py b/purchase_order_line_sequence/__init__.py new file mode 100644 index 00000000000..e66fb1c2ee8 --- /dev/null +++ b/purchase_order_line_sequence/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models +from .hooks import post_init_hook diff --git a/purchase_order_line_sequence/__manifest__.py b/purchase_order_line_sequence/__manifest__.py new file mode 100644 index 00000000000..9ba4cb8eeea --- /dev/null +++ b/purchase_order_line_sequence/__manifest__.py @@ -0,0 +1,30 @@ +# 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). + +{ + "name": "Purchase Order Line Sequence", + "summary": "Adds sequence to PO lines and propagates it to" + "Invoice lines and Stock Moves", + "version": "14.0.1.0.0", + "category": "Purchase Management", + "author": "Camptocamp, " + "Eficent, " + "Serpent CS, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/purchase-workflow", + "depends": [ + "purchase_stock", + "stock_picking_line_sequence", + ], + "data": [ + "views/purchase_view.xml", + "views/report_purchaseorder.xml", + "views/report_purchasequotation.xml", + ], + "post_init_hook": "post_init_hook", + "installable": True, + "auto_install": False, + "license": "AGPL-3", +} diff --git a/purchase_order_line_sequence/hooks.py b/purchase_order_line_sequence/hooks.py new file mode 100644 index 00000000000..4234176c17a --- /dev/null +++ b/purchase_order_line_sequence/hooks.py @@ -0,0 +1,15 @@ +# 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 SUPERUSER_ID +from odoo.api import Environment + + +def post_init_hook(cr, pool): + """ + Fetches all the PO and resets the sequence of the purchase order lines. + """ + env = Environment(cr, SUPERUSER_ID, {}) + purchase = env["purchase.order"].search([]) + purchase._reset_sequence() diff --git a/purchase_order_line_sequence/i18n/fr.po b/purchase_order_line_sequence/i18n/fr.po new file mode 100644 index 00000000000..ad7b904d280 --- /dev/null +++ b/purchase_order_line_sequence/i18n/fr.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_reorder_lines +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-10 13:13+0000\n" +"PO-Revision-Date: 2020-08-28 17:00+0000\n" +"Last-Translator: Sandie FAVRE \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: purchase_order_line_sequence +#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_order_sequence_qweb +#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_quote_sequence_qweb +msgid "Sequence" +msgstr "Séquence" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence2 +msgid "Displays the sequence of the line in the purchase order." +msgstr "Affiche la séquence de la ligne dans l'ordre d'achat." + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence +msgid "Gives the sequence of the line when displaying the purchase order." +msgstr "Donne la séquence de la ligne lors de l'affichage du bon de commande." + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence +msgid "Hidden Sequence" +msgstr "Séquence masquée" + +#. module: purchase_order_line_sequence +#: model:ir.model,name:purchase_order_line_sequence.model_account_invoice_line +msgid "Invoice Line" +msgstr "Ligne de facture" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order__max_line_sequence +msgid "Max sequence in lines" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order +msgid "Purchase Order" +msgstr "Bon de commande" + +#. module: purchase_order_line_sequence +#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Ligne de bon de commande" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence2 +msgid "Sequence" +msgstr "Séquence" + +#~ msgid "Purchase Order Line Make Invoice" +#~ msgstr "Créer la facture des lignes de commande d'achat" diff --git a/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot b/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot new file mode 100644 index 00000000000..d32df210c1d --- /dev/null +++ b/purchase_order_line_sequence/i18n/purchase_order_line_sequence.pot @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_line_sequence +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: purchase_order_line_sequence +#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_order_sequence_qweb +#: model_terms:ir.ui.view,arch_db:purchase_order_line_sequence.report_purchase_quote_sequence_qweb +msgid "Sequence" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence2 +msgid "Displays the sequence of the line in the purchase order." +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,help:purchase_order_line_sequence.field_purchase_order_line__sequence +msgid "Gives the sequence of the line when displaying the purchase order." +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence +msgid "Hidden Sequence" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model,name:purchase_order_line_sequence.model_account_invoice_line +msgid "Invoice Line" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order__max_line_sequence +msgid "Max sequence in lines" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model,name:purchase_order_line_sequence.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" + +#. module: purchase_order_line_sequence +#: model:ir.model.fields,field_description:purchase_order_line_sequence.field_purchase_order_line__sequence2 +msgid "Sequence" +msgstr "" + diff --git a/purchase_order_line_sequence/models/__init__.py b/purchase_order_line_sequence/models/__init__.py new file mode 100644 index 00000000000..f51c18ab63e --- /dev/null +++ b/purchase_order_line_sequence/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import purchase +from . import purchase_line diff --git a/purchase_order_line_sequence/models/invoice.py b/purchase_order_line_sequence/models/invoice.py new file mode 100644 index 00000000000..f82761148e1 --- /dev/null +++ b/purchase_order_line_sequence/models/invoice.py @@ -0,0 +1,15 @@ +# 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 AccountInvoiceLine(models.Model): + _inherit = "account.invoice.line" + + def _set_additional_fields(self, invoice): + if self.purchase_line_id: + self.sequence = self.purchase_line_id.sequence + super(AccountInvoiceLine, self)._set_additional_fields(invoice) diff --git a/purchase_order_line_sequence/models/purchase.py b/purchase_order_line_sequence/models/purchase.py new file mode 100644 index 00000000000..76f30d35528 --- /dev/null +++ b/purchase_order_line_sequence/models/purchase.py @@ -0,0 +1,95 @@ +# 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 api, fields, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + @api.depends("order_line") + def _compute_max_line_sequence(self): + """Allow to know the highest sequence entered in purchase order lines. + Then we add 1 to this value for the next sequence which is given + to the context of the o2m field in the view. So when we create a new + purchase order line, the sequence is automatically max_sequence + 1 + """ + for purchase in self: + purchase.max_line_sequence = ( + max(purchase.mapped("order_line.sequence") or [0]) + 1 + ) + + max_line_sequence = fields.Integer( + string="Max sequence in lines", compute="_compute_max_line_sequence" + ) + + def _create_picking(self): + res = super(PurchaseOrder, self)._create_picking() + for order in self: + if any( + [ + ptype in ["product", "consu"] + for ptype in order.order_line.mapped("product_id.type") + ] + ): + pickings = order.picking_ids.filtered( + lambda x: x.state not in ("done", "cancel") + ) + if pickings: + picking = pickings[0] + for move, line in zip( + sorted(picking.move_lines, key=lambda m: m.id), order.order_line + ): + move.write({"sequence": line.sequence}) + return res + + def _reset_sequence(self): + for rec in self: + current_sequence = 1 + for line in rec.order_line: + line.sequence = current_sequence + current_sequence += 1 + + def write(self, line_values): + res = super(PurchaseOrder, self).write(line_values) + self._reset_sequence() + return res + + def copy(self, default=None): + return super(PurchaseOrder, self.with_context(keep_line_sequence=True)).copy( + default + ) + + +class PurchaseOrderLine(models.Model): + _inherit = "purchase.order.line" + _order = "sequence, id" + + sequence = fields.Integer( + "Hidden Sequence", + help="Gives the sequence of the line when " "displaying the purchase order.", + default=9999, + ) + + sequence2 = fields.Integer( + "Sequence", + help="Displays the sequence of the line in " "the purchase order.", + related="sequence", + readonly=True, + ) + + def _prepare_stock_moves(self, picking): + res = super(PurchaseOrderLine, self)._prepare_stock_moves(picking) + for move, line in zip(res, self): + move.update(sequence=line.sequence) + return res + + @api.model + def create(self, values): + line = super(PurchaseOrderLine, self).create(values) + # We do not reset the sequence when copying an entire purchase order + if not self.env.context.get("keep_line_sequence"): + line.order_id._reset_sequence() + return line 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 new file mode 100644 index 00000000000..6d9b78e0490 --- /dev/null +++ b/purchase_order_line_sequence/readme/CONTRIBUTORS.rst @@ -0,0 +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/readme/DESCRIPTION.rst b/purchase_order_line_sequence/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..ee248cdfc68 --- /dev/null +++ b/purchase_order_line_sequence/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ + +The sequence in PO line is propagated to the Stock moves. The sequence number +appears in the PO form view and in the report. diff --git a/purchase_order_line_sequence/readme/ROADMAP.rst b/purchase_order_line_sequence/readme/ROADMAP.rst new file mode 100644 index 00000000000..84ba43724a6 --- /dev/null +++ b/purchase_order_line_sequence/readme/ROADMAP.rst @@ -0,0 +1,2 @@ + +In standard odoo is possible to sort the purchase order lines and those are propagated to the invoice lines diff --git a/purchase_order_line_sequence/readme/USAGE.rst b/purchase_order_line_sequence/readme/USAGE.rst new file mode 100644 index 00000000000..1502b6c495c --- /dev/null +++ b/purchase_order_line_sequence/readme/USAGE.rst @@ -0,0 +1,3 @@ + +This module depends on the following module(s) : + * stock_picking_line_sequence (https://github.com/OCA/stock-logistics-workflow/) diff --git a/purchase_order_line_sequence/static/description/icon.png b/purchase_order_line_sequence/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_order_line_sequence/static/description/icon.png differ diff --git a/purchase_order_line_sequence/static/description/index.html b/purchase_order_line_sequence/static/description/index.html new file mode 100644 index 00000000000..154e18566de --- /dev/null +++ b/purchase_order_line_sequence/static/description/index.html @@ -0,0 +1,447 @@ + + + + + + +Purchase Order Line Sequence + + + +
+

Purchase Order Line Sequence

+ + +

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

+ +
+

Usage

+
+
This module depends on the following module(s) :
+
+
+
+
+
+

Known issues / Roadmap

+

In standard odoo is possible to sort the purchase order lines and those are propagated to the invoice lines

+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ArcheTI
  • +
  • Camptocamp
  • +
  • Eficent
  • +
  • Serpent CS
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/purchase_order_line_sequence/tests/__init__.py b/purchase_order_line_sequence/tests/__init__.py new file mode 100644 index 00000000000..117ebd64788 --- /dev/null +++ b/purchase_order_line_sequence/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_po_lines_sequence diff --git a/purchase_order_line_sequence/tests/test_po_lines_sequence.py b/purchase_order_line_sequence/tests/test_po_lines_sequence.py new file mode 100644 index 00000000000..6b80e3c9495 --- /dev/null +++ b/purchase_order_line_sequence/tests/test_po_lines_sequence.py @@ -0,0 +1,152 @@ +# 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 datetime import datetime + +from odoo.tests import common +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT + + +class TestPurchaseOrder(common.TransactionCase): + def setUp(self): + super(TestPurchaseOrder, self).setUp() + # Useful models + self.PurchaseOrder = self.env["purchase.order"] + self.PurchaseOrderLine = self.env["purchase.order.line"] + self.partner_id = self.env.ref("base.res_partner_1") + 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.move"] + self.AccountInvoiceLine = self.env["account.move.line"] + + self.category = self.env.ref("product.product_category_1").copy( + { + "name": "Test category", + "property_valuation": "real_time", + "property_cost_method": "fifo", + } + ) + + account_type = self.env["account.account.type"].create( + {"name": "RCV type", "type": "other", "internal_group": "expense"} + ) + self.account_expense = self.env["account.account"].create( + { + "name": "Expense", + "code": "EXP00", + "user_type_id": account_type.id, + "reconcile": True, + } + ) + self.account_payable = self.env["account.account"].create( + { + "name": "Payable", + "code": "PAY00", + "user_type_id": account_type.id, + "reconcile": True, + } + ) + + self.category.property_account_expense_categ_id = self.account_expense + + self.category.property_stock_journal = self.env["account.journal"].create( + {"name": "Stock journal", "type": "sale", "code": "STK00"} + ) + self.product_id_1.categ_id = self.category + self.product_id_2.categ_id = self.category + self.partner_id.property_account_payable_id = self.account_payable + + def _create_purchase_order(self): + po_vals = { + "partner_id": self.partner_id.id, + "order_line": [ + ( + 0, + 0, + { + "name": self.product_id_1.name, + "product_id": self.product_id_1.id, + "product_qty": 5.0, + "product_uom": self.product_id_1.uom_po_id.id, + "price_unit": 500.0, + "date_planned": datetime.today().strftime( + DEFAULT_SERVER_DATETIME_FORMAT + ), + }, + ), + ( + 0, + 0, + { + "name": self.product_id_2.name, + "product_id": self.product_id_2.id, + "product_qty": 5.0, + "product_uom": self.product_id_2.uom_po_id.id, + "price_unit": 250.0, + "date_planned": datetime.today().strftime( + DEFAULT_SERVER_DATETIME_FORMAT + ), + }, + ), + ], + } + + return self.PurchaseOrder.create(po_vals) + + def test_purchase_order_line_sequence(self): + + self.po = self._create_purchase_order() + self.po.button_confirm() + + move1 = self.env["stock.move"].search( + [("purchase_line_id", "=", self.po.order_line[0].id)] + ) + move2 = self.env["stock.move"].search( + [("purchase_line_id", "=", self.po.order_line[1].id)] + ) + + self.assertEqual( + self.po.order_line[0].sequence, + move1.sequence, + "The Sequence of the Purchase Order Lines does not " + "match to the Stock Moves", + ) + self.assertEqual( + self.po.order_line[1].sequence, + move2.sequence, + "The Sequence of the Purchase Order Lines does not " + "match to the Stock Moves", + ) + + self.po2 = self.po.copy() + self.assertEqual( + self.po.order_line[0].sequence, + self.po2.order_line[0].sequence, + "The Sequence is not copied properly", + ) + self.assertEqual( + self.po.order_line[1].sequence, + self.po2.order_line[1].sequence, + "The Sequence is not copied properly", + ) + + def test_invoice_sequence(self): + + po = self._create_purchase_order() + po.button_confirm() + 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.line_ids[0].sequence, + "The Sequence is not copied properly", + ) + self.assertEqual( + po.order_line[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 new file mode 100644 index 00000000000..745ac068d17 --- /dev/null +++ b/purchase_order_line_sequence/views/purchase_view.xml @@ -0,0 +1,37 @@ + + + + + purchase.order.line.form + purchase.order.line + + + + + + + + + + purchase.order.form + purchase.order + + 2 + + + + + + {'default_sequence': + max_line_sequence, 'default_state': 'draft'} + + + + + + + + diff --git a/purchase_order_line_sequence/views/report_purchaseorder.xml b/purchase_order_line_sequence/views/report_purchaseorder.xml new file mode 100644 index 00000000000..f6ea8f06ae2 --- /dev/null +++ b/purchase_order_line_sequence/views/report_purchaseorder.xml @@ -0,0 +1,17 @@ + + + + diff --git a/purchase_order_line_sequence/views/report_purchasequotation.xml b/purchase_order_line_sequence/views/report_purchasequotation.xml new file mode 100644 index 00000000000..7bcd28752e4 --- /dev/null +++ b/purchase_order_line_sequence/views/report_purchasequotation.xml @@ -0,0 +1,17 @@ + + + +