From cf21b4387a2356b042ba1d1b70d66de77003e3ca Mon Sep 17 00:00:00 2001 From: Quoc - Pham Ngoc Date: Fri, 18 Oct 2024 17:49:02 +0700 Subject: [PATCH] [MIG] purchase_request: Migration to 18.0 --- purchase_request/README.rst | 44 ++++++------ purchase_request/__manifest__.py | 2 +- purchase_request/models/purchase_order.py | 43 ++++++------ .../models/purchase_request_allocation.py | 4 +- purchase_request/models/stock_move_line.py | 68 +++++++++---------- purchase_request/readme/CONTRIBUTORS.md | 2 + .../reports/report_purchase_request.xml | 4 +- .../static/description/index.html | 14 ++-- .../tests/test_purchase_request.py | 3 +- .../tests/test_purchase_request_allocation.py | 8 +-- .../test_purchase_request_procurement.py | 1 - .../tests/test_purchase_request_to_rfq.py | 4 +- .../views/purchase_order_view.xml | 6 +- .../views/purchase_request_line_view.xml | 30 ++++---- .../views/purchase_request_view.xml | 18 ++--- purchase_request/views/stock_move_views.xml | 4 +- ...rchase_request_line_make_purchase_order.py | 12 +++- ..._request_line_make_purchase_order_view.xml | 4 +- 18 files changed, 139 insertions(+), 132 deletions(-) diff --git a/purchase_request/README.rst b/purchase_request/README.rst index a701b4e39a5..a23e25d6c5f 100644 --- a/purchase_request/README.rst +++ b/purchase_request/README.rst @@ -17,13 +17,13 @@ Purchase Request :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/17.0/purchase_request + :target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_request :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-17-0/purchase-workflow-17-0-purchase_request + :target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_request :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -85,9 +85,9 @@ To configure the product follow this steps: Note that MTO route is archived by default, you should unarchive it first: -- Go to Inventory > Configuration > Routes, in the Search dropdown - menu, click *Archived* to show *Replenish on Order (MTO)* route and - *Unarchive* it. +- Go to Inventory > Configuration > Routes, in the Search dropdown menu, + click *Archived* to show *Replenish on Order (MTO)* route and + *Unarchive* it. With this configuration, whenever a procurement order is created and the supply rule selected is 'Buy' the application will create a Purchase @@ -110,7 +110,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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -125,27 +125,31 @@ Authors Contributors ------------ -- Jordi Ballester Alomar +- Jordi Ballester Alomar -- Jonathan Nemry +- Jonathan Nemry -- Aaron Henriquez +- Aaron Henriquez -- Adrien Peiffer +- Adrien Peiffer -- Lois Rilo +- Lois Rilo -- Héctor Villarreal +- Héctor Villarreal -- Ben Cai +- Ben Cai -- Rattapong Chokmasermkul +- Rattapong Chokmasermkul -- Stefan Rijnhart +- Stefan Rijnhart -- ``Trobz ``\ \_: +- ``Trobz ``\ \_: - - Son Ho sonhd@trobz.com + - Son Ho sonhd@trobz.com + +- `Komit Company Limited `__: + + - Quoc Pham Ngoc Other credits ------------- @@ -157,7 +161,7 @@ The development of this module has been financially supported by: Images ~~~~~~ -- Enric Tobella (logo) +- Enric Tobella (logo) .. |Aleph Objects, Inc| image:: https://upload.wikimedia.org/wikipedia/en/3/3b/Aleph_Objects_Logo.png :target: https://www.alephobjects.com @@ -175,6 +179,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_request/__manifest__.py b/purchase_request/__manifest__.py index 945f5ef2a6c..f9d36b5c0b4 100644 --- a/purchase_request/__manifest__.py +++ b/purchase_request/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Purchase Request", "author": "ForgeFlow, Odoo Community Association (OCA)", - "version": "17.0.1.2.2", + "version": "18.0.1.0.0", "summary": "Use this module to have notification of requirements of " "materials and/or external services and keep track of such " "requirements.", diff --git a/purchase_request/models/purchase_order.py b/purchase_request/models/purchase_order.py index 6bacd20d8d8..cd80832c911 100644 --- a/purchase_request/models/purchase_order.py +++ b/purchase_request/models/purchase_order.py @@ -1,6 +1,8 @@ # Copyright 2018-2019 ForgeFlow, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) +from markupsafe import Markup + from odoo import _, api, exceptions, fields, models @@ -15,14 +17,13 @@ def _purchase_request_confirm_message_content(self, request, request_dict=None): "po_name": self.name, "pr_name": request.name, } - message = "

%s

    " % title + message = f"

    {title}

      " message += _( "The following requested items from Purchase Request %(pr_name)s " - "have now been confirmed in Purchase Order %(po_name)s:" - ) % { - "po_name": self.name, - "pr_name": request.name, - } + "have now been confirmed in Purchase Order %(po_name)s:", + po_name=self.name, + pr_name=request.name, + ) for line in request_dict.values(): message += _( @@ -46,7 +47,7 @@ def _purchase_request_confirm_message(self): request_id = request_line.request_id.id if request_id not in requests_dict: requests_dict[request_id] = {} - date_planned = "%s" % line.date_planned + date_planned = line.date_planned data = { "name": request_line.name, "product_qty": line.product_qty, @@ -60,7 +61,7 @@ def _purchase_request_confirm_message(self): request, requests_dict[request_id] ) request.message_post( - body=message, + body=Markup(message), subtype_id=self.env.ref("mail.mt_comment").id, body_is_html=True, ) @@ -132,7 +133,7 @@ def action_open_request_line_tree_view(self): "name": _("Purchase Request Lines"), "type": "ir.actions.act_window", "res_model": "purchase.request.line", - "view_mode": "tree,form", + "view_mode": "list,form", "domain": domain, } @@ -182,7 +183,7 @@ def update_service_allocations(self, prev_qty_received): message_data ) alloc.purchase_request_line_id.request_id.message_post( - body=message, + body=Markup(message), subtype_id=self.env.ref("mail.mt_comment").id, body_is_html=True, ) @@ -195,24 +196,22 @@ def _purchase_request_confirm_done_message_content(self, message_data): title = ( _("Service confirmation for Request %s") % (message_data["request_name"]) ) - message = "

      %s

      " % title + message = f"

      {title}

      " message += _( "The following requested services from Purchase" " Request %(request_name)s requested by %(requestor)s " - "have now been received:" - ) % { - "request_name": message_data["request_name"], - "requestor": message_data["requestor"], - } + "have now been received:", + request_name=message_data["request_name"], + requestor=message_data["requestor"], + ) message += "
        " message += _( "
      • %(product_name)s: " - "Received quantity %(product_qty)s %(product_uom)s
      • " - ) % { - "product_name": message_data["product_name"], - "product_qty": message_data["product_qty"], - "product_uom": message_data["product_uom"], - } + "Received quantity %(product_qty)s %(product_uom)s", + product_name=message_data["product_name"], + product_qty=message_data["product_qty"], + product_uom=message_data["product_uom"], + ) message += "
      " return message diff --git a/purchase_request/models/purchase_request_allocation.py b/purchase_request/models/purchase_request_allocation.py index 45350427f5d..bc91dc6f17d 100644 --- a/purchase_request/models/purchase_request_allocation.py +++ b/purchase_request/models/purchase_request_allocation.py @@ -1,6 +1,8 @@ # Copyright 2019 ForgeFlow, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) +from markupsafe import Markup + from odoo import _, api, fields, models @@ -128,7 +130,7 @@ def _notify_allocation(self, allocated_qty): message_data = self._prepare_message_data(po_line, request, allocated_qty) message = self._purchase_request_confirm_done_message_content(message_data) request.message_post( - body=message, + body=Markup(message), subtype_id=self.env.ref("mail.mt_comment").id, body_is_html=True, ) diff --git a/purchase_request/models/stock_move_line.py b/purchase_request/models/stock_move_line.py index bbfa5b1d10f..409ef40f6d3 100644 --- a/purchase_request/models/stock_move_line.py +++ b/purchase_request/models/stock_move_line.py @@ -1,6 +1,8 @@ # Copyright 2017 ForgeFlow, S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) +from markupsafe import Markup + from odoo import _, api, models @@ -10,57 +12,53 @@ class StockMoveLine(models.Model): @api.model def _purchase_request_confirm_done_message_content(self, message_data): title = _( - "Receipt confirmation %(picking_name)s for your Request %(request_name)s" - ) % { - "picking_name": message_data["picking_name"], - "request_name": message_data["request_name"], - } - message = "

      %s

      " % title + "Receipt confirmation %(picking_name)s for your Request %(request_name)s", + picking_name=message_data["picking_name"], + request_name=message_data["request_name"], + ) + message = f"

      {title}

      " message += _( "The following requested items from Purchase Request %(request_name)s " "have now been received in %(location_name)s using Picking " - "%(picking_name)s:" - ) % { - "request_name": message_data["request_name"], - "location_name": message_data["location_name"], - "picking_name": message_data["picking_name"], - } + "%(picking_name)s:", + request_name=message_data["request_name"], + location_name=message_data["location_name"], + picking_name=message_data["picking_name"], + ) message += "
        " message += _( "
      • %(product_name)s: " - "Transferred quantity %(product_qty)s %(product_uom)s
      • " - ) % { - "product_name": message_data["product_name"], - "product_qty": message_data["product_qty"], - "product_uom": message_data["product_uom"], - } + "Transferred quantity %(product_qty)s %(product_uom)s", + product_name=message_data["product_name"], + product_qty=message_data["product_qty"], + product_uom=message_data["product_uom"], + ) message += "
      " return message @api.model def _picking_confirm_done_message_content(self, message_data): - title = ( - _("Receipt confirmation for Request %s") % (message_data["request_name"]) + title = _( + "Receipt confirmation for Request %(name)s", + name=message_data["request_name"], ) - message = "

      %s

      " % title + message = f"

      {title}

      " message += _( "The following requested items from Purchase Request %(request_name)s " "requested by %(requestor)s " - "have now been received in %(location_name)s:" - ) % { - "request_name": message_data["request_name"], - "requestor": message_data["requestor"], - "location_name": message_data["location_name"], - } + "have now been received in %(location_name)s:", + request_name=message_data["request_name"], + requestor=message_data["requestor"], + location_name=message_data["location_name"], + ) message += "
        " message += _( "
      • %(product_name)s: " - "Transferred quantity %(product_qty)s %(product_uom)s
      • " - ) % { - "product_name": message_data["product_name"], - "product_qty": message_data["product_qty"], - "product_uom": message_data["product_uom"], - } + "Transferred quantity %(product_qty)s %(product_uom)s", + product_name=message_data["product_name"], + product_qty=message_data["product_qty"], + product_uom=message_data["product_uom"], + ) message += "
      " return message @@ -107,7 +105,7 @@ def allocate(self): message_data ) request.message_post( - body=message, + body=Markup(message), subtype_id=self.env.ref("mail.mt_comment").id, body_is_html=True, ) @@ -116,7 +114,7 @@ def allocate(self): message_data ) ml.move_id.picking_id.message_post( - body=picking_message, + body=Markup(picking_message), subtype_id=self.env.ref("mail.mt_comment").id, body_is_html=True, ) diff --git a/purchase_request/readme/CONTRIBUTORS.md b/purchase_request/readme/CONTRIBUTORS.md index bd9cfbdde2c..29df4d62475 100644 --- a/purchase_request/readme/CONTRIBUTORS.md +++ b/purchase_request/readme/CONTRIBUTORS.md @@ -10,3 +10,5 @@ - `Trobz `_: * Son Ho +- [Komit Company Limited](https://komit-consulting.com/): + - Quoc Pham Ngoc \<\> \ No newline at end of file diff --git a/purchase_request/reports/report_purchase_request.xml b/purchase_request/reports/report_purchase_request.xml index 253260a2e0d..652bb51d61e 100644 --- a/purchase_request/reports/report_purchase_request.xml +++ b/purchase_request/reports/report_purchase_request.xml @@ -7,7 +7,7 @@
      -
      +

      Purchase Request @@ -115,7 +115,7 @@ -
      +
      diff --git a/purchase_request/static/description/index.html b/purchase_request/static/description/index.html index 59aa1133b15..3d36e9600fd 100644 --- a/purchase_request/static/description/index.html +++ b/purchase_request/static/description/index.html @@ -369,7 +369,7 @@

      Purchase Request

      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:904ae9c17e3f91166fd0feae50a01480c2cc4a223f55ddb0101c97e061eba454 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

      Beta License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

      +

      Beta License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

      You use this module if you wish to give notification of requirements of materials and/or external services and keep track of such requirements.

      Requests can be created either directly or indirectly. “Directly” means @@ -428,8 +428,8 @@

      Configuration

      Note that MTO route is archived by default, you should unarchive it first:

        -
      • Go to Inventory > Configuration > Routes, in the Search dropdown -menu, click Archived to show Replenish on Order (MTO) route and +
      • Go to Inventory > Configuration > Routes, in the Search dropdown menu, +click Archived to show Replenish on Order (MTO) route and Unarchive it.

      With this configuration, whenever a procurement order is created and the @@ -449,7 +449,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 to smash it by providing a detailed and welcomed -feedback.

      +feedback.

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

      @@ -476,6 +476,10 @@

      Contributors

    • Son Ho sonhd@trobz.com
    +
  • Komit Company Limited: +
@@ -498,7 +502,7 @@

Maintainers

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_request/tests/test_purchase_request.py b/purchase_request/tests/test_purchase_request.py index 42015fbab1e..097c352f87f 100644 --- a/purchase_request/tests/test_purchase_request.py +++ b/purchase_request/tests/test_purchase_request.py @@ -3,7 +3,7 @@ from odoo import SUPERUSER_ID, exceptions from odoo.exceptions import UserError -from odoo.tests.common import Form, TransactionCase +from odoo.tests import Form, TransactionCase class TestPurchaseRequest(TransactionCase): @@ -207,7 +207,6 @@ def test_empty_purchase_request(self): def test_default_picking_type(self): with Form(self.purchase_request_obj) as f: - f.name = "Test Purchase" f.requested_by = self.env.user f.save() diff --git a/purchase_request/tests/test_purchase_request_allocation.py b/purchase_request/tests/test_purchase_request_allocation.py index c0b45b56de3..905ed371068 100644 --- a/purchase_request/tests/test_purchase_request_allocation.py +++ b/purchase_request/tests/test_purchase_request_allocation.py @@ -2,7 +2,7 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) from odoo import SUPERUSER_ID -from odoo.tests import common +from odoo.tests import Form, common class TestPurchaseRequestToRfq(common.TransactionCase): @@ -19,7 +19,7 @@ def setUp(self): self.product_product = self.env["product.product"].create( { "name": "Product Product Test", - "type": "product", + "type": "consu", "description_purchase": "Test Description", } ) @@ -112,7 +112,7 @@ def test_purchase_request_allocation(self): picking.move_line_ids[0].write({"quantity": 2.0}) backorder_wiz_id = picking.button_validate() - common.Form( + Form( self.env[backorder_wiz_id["res_model"]].with_context( **backorder_wiz_id["context"] ) @@ -123,7 +123,7 @@ def test_purchase_request_allocation(self): backorder_picking = purchase.picking_ids.filtered(lambda p: p.id != picking.id) backorder_picking.move_line_ids[0].write({"quantity": 1.0}) backorder_wiz_id2 = backorder_picking.button_validate() - common.Form( + Form( self.env[backorder_wiz_id2["res_model"]].with_context( **backorder_wiz_id2["context"] ) diff --git a/purchase_request/tests/test_purchase_request_procurement.py b/purchase_request/tests/test_purchase_request_procurement.py index 3b2d4f0e623..c98f43f445c 100644 --- a/purchase_request/tests/test_purchase_request_procurement.py +++ b/purchase_request/tests/test_purchase_request_procurement.py @@ -104,7 +104,6 @@ def test_procure_purchase_request(self): self.env["mail.activity"].search( [("activity_type_id", "=", activity.id)] ).unlink() - activity.unlink() self.assertFalse(move.created_purchase_request_line_id.request_id.activity_ids) move._action_cancel() self.assertTrue(move.created_purchase_request_line_id.request_id.activity_ids) diff --git a/purchase_request/tests/test_purchase_request_to_rfq.py b/purchase_request/tests/test_purchase_request_to_rfq.py index de55884e922..5438c3710aa 100644 --- a/purchase_request/tests/test_purchase_request_to_rfq.py +++ b/purchase_request/tests/test_purchase_request_to_rfq.py @@ -27,7 +27,7 @@ def setUp(self): self.product_product = self.env["product.product"].create( { "name": "Product Product Test", - "type": "product", + "type": "consu", "description_purchase": "Test Description", } ) @@ -307,7 +307,7 @@ def test_purchase_request_to_rfq_minimum_order_qty_existing_po(self): product = self.env["product.product"].create( { "name": "Widget", - "type": "product", + "type": "consu", "seller_ids": [ (0, 0, {"partner_id": supplier.id, "delay": 10, "min_qty": 5}) ], diff --git a/purchase_request/views/purchase_order_view.xml b/purchase_request/views/purchase_order_view.xml index 35c5610f771..88600239c2c 100644 --- a/purchase_request/views/purchase_order_view.xml +++ b/purchase_request/views/purchase_order_view.xml @@ -7,7 +7,7 @@ purchase.order - +