diff --git a/purchase_order_date_approve_editable/README.rst b/purchase_order_date_approve_editable/README.rst new file mode 100644 index 00000000000..8303dc4ac64 --- /dev/null +++ b/purchase_order_date_approve_editable/README.rst @@ -0,0 +1,71 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +==================================== +Purchase Order Date Approve Editable +==================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:665d312e92c5c5457af3e99c4af167aaf1f000c0873e2b050b6269db220a4357 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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-solvosci%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/solvosci/purchase-workflow/tree/17.0/purchase_order_date_approve_editable + :alt: solvosci/purchase-workflow + +|badge1| |badge2| |badge3| + +Extends the standard Purchase Order functionality to allow users to +manually edit the Approval Date ('date_approve') after a purchase order +has been confirmed. + +By default, Odoo sets this field as readonly. This module makes it +editable until the order is locked (state 'done'). + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Solvos + +Contributors +------------ + +- `Solvos `__: + + - Carlos García + +Maintainers +----------- + +This module is part of the `solvosci/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. diff --git a/purchase_order_date_approve_editable/__init__.py b/purchase_order_date_approve_editable/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_order_date_approve_editable/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_order_date_approve_editable/__manifest__.py b/purchase_order_date_approve_editable/__manifest__.py new file mode 100644 index 00000000000..6e3721426b8 --- /dev/null +++ b/purchase_order_date_approve_editable/__manifest__.py @@ -0,0 +1,20 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Purchase Order Date Approve Editable", + "summary": """ + Allows editing the Approval Date on Purchase Orders + """, + "author": "Solvos," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "version": "17.0.1.0.0", + "category": "Purchase", + "website": "https://github.com/OCA/purchase-workflow", + "depends": [ + "purchase", + ], + "data": [ + "views/purchase_views.xml", + ], + "installable": True, +} diff --git a/purchase_order_date_approve_editable/models/__init__.py b/purchase_order_date_approve_editable/models/__init__.py new file mode 100644 index 00000000000..9f03530643d --- /dev/null +++ b/purchase_order_date_approve_editable/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_order_date_approve_editable/models/purchase_order.py b/purchase_order_date_approve_editable/models/purchase_order.py new file mode 100644 index 00000000000..79a747d7e75 --- /dev/null +++ b/purchase_order_date_approve_editable/models/purchase_order.py @@ -0,0 +1,10 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import fields, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + date_approve = fields.Datetime(tracking=True, readonly=False) diff --git a/purchase_order_date_approve_editable/pyproject.toml b/purchase_order_date_approve_editable/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_order_date_approve_editable/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_order_date_approve_editable/readme/CONTRIBUTORS.md b/purchase_order_date_approve_editable/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..a6fdccacf16 --- /dev/null +++ b/purchase_order_date_approve_editable/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Solvos](https://www.solvos.es): + - Carlos García \ diff --git a/purchase_order_date_approve_editable/readme/DESCRIPTION.md b/purchase_order_date_approve_editable/readme/DESCRIPTION.md new file mode 100644 index 00000000000..d4bc740a40d --- /dev/null +++ b/purchase_order_date_approve_editable/readme/DESCRIPTION.md @@ -0,0 +1,6 @@ +Extends the standard Purchase Order functionality to allow users +to manually edit the Approval Date ('date_approve') after a purchase order +has been confirmed. + +By default, Odoo sets this field as readonly. +This module makes it editable until the order is locked (state 'done'). diff --git a/purchase_order_date_approve_editable/static/description/icon.png b/purchase_order_date_approve_editable/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_order_date_approve_editable/static/description/icon.png differ diff --git a/purchase_order_date_approve_editable/static/description/index.html b/purchase_order_date_approve_editable/static/description/index.html new file mode 100644 index 00000000000..3a562099950 --- /dev/null +++ b/purchase_order_date_approve_editable/static/description/index.html @@ -0,0 +1,429 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Purchase Order Date Approve Editable

+ +

Beta License: AGPL-3 solvosci/purchase-workflow

+

Extends the standard Purchase Order functionality to allow users to +manually edit the Approval Date (‘date_approve’) after a purchase order +has been confirmed.

+

By default, Odoo sets this field as readonly. This module makes it +editable until the order is locked (state ‘done’).

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Solvos
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the solvosci/purchase-workflow project on GitHub.

+

You are welcome to contribute.

+
+
+
+
+ + diff --git a/purchase_order_date_approve_editable/tests/__init__.py b/purchase_order_date_approve_editable/tests/__init__.py new file mode 100644 index 00000000000..11727158392 --- /dev/null +++ b/purchase_order_date_approve_editable/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_order_date_approve_editable diff --git a/purchase_order_date_approve_editable/tests/test_purchase_order_date_approve_editable.py b/purchase_order_date_approve_editable/tests/test_purchase_order_date_approve_editable.py new file mode 100644 index 00000000000..eff309c7333 --- /dev/null +++ b/purchase_order_date_approve_editable/tests/test_purchase_order_date_approve_editable.py @@ -0,0 +1,149 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from datetime import timedelta + +from odoo import Command, fields +from odoo.tests import TransactionCase, tagged +from odoo.tests.common import Form + + +@tagged("post_install", "-at_install") +class TestPurchaseDateApprove(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + # Safety fallback for optional 'order_type' field in Form() tests + field = cls.env["purchase.order"]._fields.get("order_type") + comodel_name = getattr(field, "comodel_name", "ir.model") + cls.order_type_default = cls.env[comodel_name].search([], limit=1).id + + cls.partner = cls.env["res.partner"].create( + { + "name": "Partner Test", + "email": "partner@test.com", + } + ) + + cls.product = ( + cls.env["product.product"] + .with_context(mail_create_nosubscribe=True, tracking_disable=True) + .create( + { + "name": "Product Test", + "detailed_type": "consu", + "standard_price": 100.0, + } + ) + ) + + def _create_po(self, vals): + return ( + self.env["purchase.order"] + .with_context(default_order_type=self.order_type_default) + .create(vals) + ) + + def test_edit_date_approve_orm(self): + purchase_order = self._create_po( + { + "partner_id": self.partner.id, + "order_line": [ + Command.create( + { + "product_id": self.product.id, + "product_qty": 1.0, + "price_unit": 100.0, + "date_planned": fields.Datetime.now(), + } + ) + ], + } + ) + + purchase_order.button_confirm() + self.assertEqual(purchase_order.state, "purchase") + self.assertTrue(purchase_order.date_approve) + + new_date = fields.Datetime.now() - timedelta(days=2) + purchase_order.write({"date_approve": new_date}) + + self.assertEqual(purchase_order.date_approve, new_date) + + def test_edit_date_approve_view(self): + purchase_order = self._create_po( + { + "partner_id": self.partner.id, + "order_line": [ + Command.create( + { + "product_id": self.product.id, + "product_qty": 5.0, + "price_unit": 50.0, + "date_planned": fields.Datetime.now(), + } + ) + ], + } + ) + purchase_order.button_confirm() + + test_date = fields.Datetime.now().replace(microsecond=0) - timedelta(hours=5) + + with Form(purchase_order) as po_form: + po_form.date_approve = test_date + po_form.save() + + self.assertEqual(purchase_order.partner_id.id, self.partner.id) + self.assertEqual(purchase_order.date_approve, test_date) + + def test_readonly_when_done(self): + purchase_order = self._create_po( + { + "partner_id": self.partner.id, + "order_line": [ + Command.create( + { + "product_id": self.product.id, + "product_qty": 1.0, + "date_planned": fields.Datetime.now(), + } + ) + ], + } + ) + purchase_order.button_confirm() + + purchase_order.button_done() + self.assertEqual(purchase_order.state, "done") + + with self.assertRaises(AssertionError): + with Form(purchase_order) as po_form: + po_form.date_approve = fields.Datetime.now() + + def test_date_approve_required_in_purchase_view(self): + purchase_order = self._create_po( + { + "partner_id": self.partner.id, + "order_line": [ + Command.create( + { + "product_id": self.product.id, + "product_qty": 1.0, + "price_unit": 100.0, + "date_planned": fields.Datetime.now(), + } + ) + ], + } + ) + + purchase_order.button_confirm() + self.assertEqual(purchase_order.state, "purchase") + self.assertTrue(purchase_order.date_approve) + + with self.assertRaises(AssertionError): + with Form(purchase_order) as po_form: + po_form.date_approve = False + po_form.save() diff --git a/purchase_order_date_approve_editable/views/purchase_views.xml b/purchase_order_date_approve_editable/views/purchase_views.xml new file mode 100644 index 00000000000..b1f2c03ecdc --- /dev/null +++ b/purchase_order_date_approve_editable/views/purchase_views.xml @@ -0,0 +1,17 @@ + + + + purchase.order.form (in purchase_order_date_approve_editable) + purchase.order + + + + state == 'done' + state == 'purchase' + + + + +