diff --git a/README.md b/README.md index 3934742795..d44b5f2280 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ addon | version | maintainers | summary [pos_operating_unit](pos_operating_unit/) | 14.0.1.0.0 | | POS Operating Unit Access [product_operating_unit](product_operating_unit/) | 14.0.1.0.3 | | Adds the concept of operating unit (OU) in products [project_operating_unit](project_operating_unit/) | 14.0.1.0.0 | max3903 | This module adds operating unit information to projects and tasks. -[purchase_operating_unit](purchase_operating_unit/) | 14.0.2.0.0 | | Adds the concecpt of operating unit (OU) in purchase order management +[purchase_operating_unit](purchase_operating_unit/) | 14.0.2.0.1 | | Adds the concecpt of operating unit (OU) in purchase order management [purchase_operating_unit_access_all](purchase_operating_unit_access_all/) | 14.0.1.0.0 | kittiu | Access all OUs' Purchase Orders [purchase_request_operating_unit](purchase_request_operating_unit/) | 14.0.1.0.0 | | Operating Unit in Purchase Requests [purchase_request_operating_unit_access_all](purchase_request_operating_unit_access_all/) | 14.0.1.0.0 | kittiu | Access all OUs' Purchase Requests diff --git a/purchase_operating_unit/README.rst b/purchase_operating_unit/README.rst index b9dc6464aa..8dd73bec70 100644 --- a/purchase_operating_unit/README.rst +++ b/purchase_operating_unit/README.rst @@ -1,3 +1,7 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + ================================= Operating Unit in Purchase Orders ================================= @@ -7,13 +11,13 @@ Operating Unit in Purchase Orders !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:e55a5e02f3bf5c1506a46e825cdaa355b74a8ecbad1aefc092dead7702a36d09 + !! source digest: sha256:63641e999c084c008514c20a1f7524f89227c1c629f0a8264c951f886780117f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |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-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github diff --git a/purchase_operating_unit/__manifest__.py b/purchase_operating_unit/__manifest__.py index f5aca7d82e..597ddaa4d1 100644 --- a/purchase_operating_unit/__manifest__.py +++ b/purchase_operating_unit/__manifest__.py @@ -7,7 +7,7 @@ "name": "Operating Unit in Purchase Orders", "summary": "Adds the concecpt of operating unit (OU) in purchase order " "management", - "version": "14.0.2.0.0", + "version": "14.0.2.0.1", "author": "ForgeFlow, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", diff --git a/purchase_operating_unit/models/purchase_order.py b/purchase_operating_unit/models/purchase_order.py index 20da03e87f..9886f08e3f 100644 --- a/purchase_operating_unit/models/purchase_order.py +++ b/purchase_operating_unit/models/purchase_order.py @@ -101,11 +101,18 @@ def _onchange_operating_unit_id(self): types = type_obj.search( [ ("code", "=", "incoming"), - ("warehouse_id.operating_unit_id", "=", self.operating_unit_id.id), - ] + ( + "warehouse_id.operating_unit_id", + "in", + [self.operating_unit_id.id, False], + ), + ], ) if types: - self.picking_type_id = types[:1] + # Prefer types with an operating unit, if multiple are available + self.picking_type_id = types.sorted( + lambda x: x.warehouse_id.operating_unit_id + )[:1] else: raise UserError( _( diff --git a/purchase_operating_unit/static/description/index.html b/purchase_operating_unit/static/description/index.html index d3f9afcbcb..4dd810de21 100644 --- a/purchase_operating_unit/static/description/index.html +++ b/purchase_operating_unit/static/description/index.html @@ -3,15 +3,16 @@ -Operating Unit in Purchase Orders +README.rst -
-

Operating Unit in Purchase Orders

+
+ + +Odoo Community Association + +
+

Operating Unit in Purchase Orders

-

Beta License: LGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runboat

This module introduces the following features:

  • It introduces the operating unit to the purchase order.
  • @@ -391,7 +397,7 @@

    Operating Unit in Purchase Orders

-

Usage

+

Usage

  1. Create a PO: the Default Operating Unit is assigned to the PO. If you want, you can change to another Operating Unit.
  2. @@ -402,13 +408,13 @@

    Usage

-

Known issues / Roadmap

+

Known issues / Roadmap

Procurement Orders were removed. Procurement Operating Unit module is deprecated. Stock Operating Unit ensures consistency between the operating unit from different models.

-

Bug Tracker

+

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 @@ -416,16 +422,16 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • ForgeFlow
  • Serpent Consulting Services Pvt. Ltd.
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +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.

@@ -451,5 +459,6 @@

Maintainers

+
diff --git a/purchase_operating_unit/tests/test_po_security.py b/purchase_operating_unit/tests/test_po_security.py index a4cf8c28b3..8344e089c5 100644 --- a/purchase_operating_unit/tests/test_po_security.py +++ b/purchase_operating_unit/tests/test_po_security.py @@ -2,6 +2,8 @@ # - Jordi Ballester Alomar # © 2015-17 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo.tests.common import Form + from . import test_purchase_operating_unit as test_po_ou # noqa @@ -52,3 +54,17 @@ def test_po_ou_security(self): .ids ) self.assertNotEqual(invoice_ids, []) + + def test_create_po_warehouse_ou(self): + # create a PO with warehouse with OU + warehouse = self.env.ref("stock.warehouse0") + self.assertEqual(warehouse.operating_unit_id, self.ou1) + with Form(self.PurchaseOrder.with_user(self.user1_id)) as f: + f.partner_id = self.partner1 + self.assertEqual(f.picking_type_id.warehouse_id, warehouse) + + # create a PO with warehouse without OU + warehouse.operating_unit_id = False + with Form(self.PurchaseOrder.with_user(self.user1_id)) as f: + f.partner_id = self.partner1 + self.assertEqual(f.picking_type_id.warehouse_id, warehouse)