Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
82f2ce4
Added Purchase Operating Unit module.
sudhir-serpentcs Dec 31, 2015
d53de72
Improved the unit test case for Purchase OU.
sudhir-serpentcs Jan 2, 2016
df79c4f
Improved the code of unit test cases and of constraint.
sudhir-serpentcs Jan 8, 2016
989e62a
Migrated the module with test cases.
sudhir-serpentcs Feb 22, 2016
4d24afc
create PO from procurement
JordiBForgeFlow Oct 6, 2016
080e65c
[MIG] purchase_operating_unit: Migrated to 10.0
AaronHForgeFlow Jan 31, 2017
c276181
[FIX] readonly on OU
serpentcs-dev1 Jul 4, 2017
e696df9
[FIX] when the procurement location is not internal the PO may belong…
AaronHForgeFlow Nov 22, 2017
e573c3d
[FIX]PYLINT mainly
AaronHForgeFlow Jun 11, 2018
9e6f2d5
[MIG] purchase_operating_unit: Migration to v12.0
bjeficent Dec 18, 2018
74e84d4
[UPD] Update purchase_operating_unit.pot
oca-travis Oct 30, 2019
06f003e
[UPD] README.rst
OCA-git-bot Oct 30, 2019
a80258e
[IMP] purchase_operating_unit: black, isort, prettier
BT-nstuder Jan 7, 2020
bf5e803
[MIG] purchase_operating_unit: Migration to 13.0
BT-nstuder Jan 8, 2020
6a4e022
[UPD] Update purchase_operating_unit.pot
oca-travis Apr 30, 2020
827caab
[UPD] README.rst
OCA-git-bot Apr 30, 2020
530bc90
[FIX] Fixed Issue #291
nikul-serpentcs Oct 1, 2020
3c27552
[UPD] README.rst
OCA-git-bot Oct 1, 2020
68fa28f
purchase_operating_unit 13.0.1.0.1
OCA-git-bot Oct 1, 2020
d5adb0f
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Oct 5, 2020
33dcf7e
[UPD] README.rst
OCA-git-bot Oct 5, 2020
cf518e2
[IMP] : black, isort, prettier
kittiu Dec 4, 2020
d7311f4
[14.0][MIG] purchase_operating_unit
kittiu Dec 4, 2020
2653fb2
[UPD] Update purchase_operating_unit.pot
oca-travis May 30, 2021
591e843
[UPD] README.rst
OCA-git-bot May 30, 2021
49b28a6
[14.0][FIX] purchase_operating_unit, add OU when create invoice
kittiu Jun 15, 2021
5beced0
purchase_operating_unit 14.0.1.0.1
OCA-git-bot Aug 3, 2021
306d344
[14.0][FIX] purchase_operating_unit
kittiu Oct 19, 2021
6f958ba
purchase_operating_unit 14.0.1.0.2
OCA-git-bot Oct 19, 2021
7263106
[IMP] purchase_operating_unit: black, isort, prettier
alan196 Jan 13, 2022
b1a9633
[MIG] purchase_operating_unit: Migration to 15.0
alan196 Jan 13, 2022
4cbce58
[UPD] Update purchase_operating_unit.pot
Mar 8, 2023
d36ffa9
[UPD] README.rst
OCA-git-bot Mar 8, 2023
8c7e137
[UPD] README.rst
OCA-git-bot Sep 3, 2023
21ff2c1
[ENH] purchase_operating_unit: add OU to Purchase Analysis Report
ps-tubtim Oct 10, 2023
c7a7a97
[UPD] Update purchase_operating_unit.pot
Oct 10, 2023
d89a610
[BOT] post-merge updates
OCA-git-bot Oct 10, 2023
7e36395
[FIX] purchase_operating_unit: Fix warning from an onchange function …
May 15, 2024
dcc2668
[UPD] Update purchase_operating_unit.pot
May 24, 2024
f9b83ad
[BOT] post-merge updates
OCA-git-bot May 24, 2024
d391f65
[IMP] purchase_operating_unit: pre-commit execution
May 29, 2024
dee0186
[MIG] purchase_operating_unit: Migration to 17.0
May 29, 2024
f49f3fc
[UPD] Update purchase_operating_unit.pot
Sep 30, 2024
21e2314
[BOT] post-merge updates
OCA-git-bot Sep 30, 2024
adafa47
Added translation using Weblate (Italian)
mymage Oct 3, 2024
e455737
Translated using Weblate (Italian)
mymage Oct 3, 2024
86eb692
[MIG] purchase_operating_unit: Migration to 18.0
BhaveshHeliconia Mar 11, 2025
dff136d
[UPD] Update purchase_operating_unit.pot
Jul 3, 2025
08063ef
[BOT] post-merge updates
OCA-git-bot Jul 3, 2025
5259cc1
[IMP] purchase_operating_unit: pre-commit auto fixes
solomonprabu Jul 3, 2026
0e2516b
[MIG] purchase_operating_unit: Migration to 19.0
solomonprabu Jul 3, 2026
0e232e8
[FIX] Incorrect import fix
solomonprabu Jul 6, 2026
b668288
[FIX] Product creation in tests
solomonprabu Jul 6, 2026
bcfd6b1
[FIX] wrong reference for groups field
solomonprabu Jul 6, 2026
e3ceda7
[FIX] partner usage in tests
solomonprabu Jul 6, 2026
7700f19
[FIX] product uom wrong reference of field in tests
solomonprabu Jul 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ docs/_build/

# OCA rules
!static/lib/
odoo.conf
coverage_report.txt
103 changes: 103 additions & 0 deletions purchase_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.. 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
=================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:21d7222687f368a65b0a1ac162b9e04e3a51ce6fa7cc912aff062a4bb6a7f595
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-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
:target: https://github.com/OCA/operating-unit/tree/19.0/purchase_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-19-0/operating-unit-19-0-purchase_operating_unit
: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/operating-unit&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module introduces the following features:

- It introduces the operating unit to the purchase order.
- The operating unit is copied to the invoice.
- It implements user's security rules.

**Table of contents**

.. contents::
:local:

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. Validate the PO: the Operating Unit is propagated to the Invoices.
3. From the invoice, it is not possible to change the Operating Unit, it
has to be the same as the one of the PO.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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 <https://github.com/OCA/operating-unit/issues/new?body=module:%20purchase_operating_unit%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* ForgeFlow
* Serpent Consulting Services Pvt. Ltd.

Contributors
------------

- Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
- Aaron Henriquez <ahforgeflow@forgeflow.com>
- Sudhir Arya <sudhir.arya@serpentcs.com>
- Nicola Studer <nicola.studer@braintec-group.com>
- Nikul Chaudhary <nikul.chaudhary.serpentcs@gmail.com>
- Kitti U. <kittiu@ecosoft.co.th>
- Alan Ramos <alan.ramos@jarsa.com>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

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/operating-unit <https://github.com/OCA/operating-unit/tree/19.0/purchase_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions purchase_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
from . import report
27 changes: 27 additions & 0 deletions purchase_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# © 2015-17 ForgeFlow S.L.
# - Jordi Ballester Alomar
# © 2015-17 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# © 2026-27 CIT Services - Solomon Prabu
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Operating Unit in Purchase Orders",
"summary": "Adds the concecpt of operating unit (OU) in purchase order management",
"version": "19.0.1.0.0",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/operating-unit",
"category": "Purchase Management",
"depends": ["purchase", "account_operating_unit"],
"license": "LGPL-3",
"data": [
"security/purchase_security.xml",
"report/purchase_report_view.xml",
"views/purchase_order_view.xml",
"views/purchase_order_line_view.xml",
"views/account_move_view.xml",
],
"demo": ["demo/purchase_order_demo.xml"],
"installable": True,
}
28 changes: 28 additions & 0 deletions purchase_operating_unit/demo/purchase_order_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--Copyright 2015-17 ForgeFlow S.L.-->
<!-- - Jordi Ballester Alomar-->
<!--Copyright 2015-17 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya-->
<!--License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>
<record id="purchase.purchase_order_1" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
<record id="purchase.purchase_order_2" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
<record id="purchase.purchase_order_3" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
<record id="purchase.purchase_order_4" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
<record id="purchase.purchase_order_5" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
<record id="purchase.purchase_order_6" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
<record id="purchase.purchase_order_7" model="purchase.order">
<field name="operating_unit_id" ref="operating_unit.main_operating_unit" />
</record>
</odoo>
79 changes: 79 additions & 0 deletions purchase_operating_unit/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-10-03 09:06+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\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 5.6.2\n"

#. module: purchase_operating_unit
#. odoo-python
#: code:addons/purchase_operating_unit/models/purchase_order.py:0
#, python-format
msgid ""
"Configuration error. The Company in the Purchase Order and in the Operating "
"Unit must be the same."
msgstr ""
"Errore di configurazione. L'azienda nell'ordine di acquisto e nell'unità "
"operativa deve essere la stessa."

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_account_move
msgid "Journal Entry"
msgstr "Registrazione contabile"

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_account_move_line
msgid "Journal Item"
msgstr "Movimento contabile"

#. module: purchase_operating_unit
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order__operating_unit_id
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order_line__operating_unit_id
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_report__operating_unit_id
#: model_terms:ir.ui.view,arch_db:purchase_operating_unit.purchase_order_line_search
#: model_terms:ir.ui.view,arch_db:purchase_operating_unit.view_purchase_order_filter
#: model_terms:ir.ui.view,arch_db:purchase_operating_unit.view_purchase_order_search
msgid "Operating Unit"
msgstr "Unità operativa"

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_purchase_order
msgid "Purchase Order"
msgstr "Ordine di acquisto"

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Riga ordine di acquisto"

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_purchase_report
msgid "Purchase Report"
msgstr "Resoconto di acquisto"

#. module: purchase_operating_unit
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order__requesting_operating_unit_id
msgid "Requesting Operating Unit"
msgstr "Unità operativa richiedente"

#. module: purchase_operating_unit
#. odoo-python
#: code:addons/purchase_operating_unit/models/account_move.py:0
#, python-format
msgid ""
"The operating unit of the purchase order must be the same as in the "
"associated invoices."
msgstr ""
"L'unità operativa dell'ordine di acquisto deve essere la stessa delle "
"fatture associate."
70 changes: 70 additions & 0 deletions purchase_operating_unit/i18n/purchase_operating_unit.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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_operating_unit
#. odoo-python
#: code:addons/purchase_operating_unit/models/purchase_order.py:0
msgid ""
"Configuration error. The Company in the Purchase Order and in the Operating "
"Unit must be the same."
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_account_move
msgid "Journal Entry"
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_account_move_line
msgid "Journal Item"
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order__operating_unit_id
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order_line__operating_unit_id
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_report__operating_unit_id
#: model_terms:ir.ui.view,arch_db:purchase_operating_unit.purchase_order_line_search
#: model_terms:ir.ui.view,arch_db:purchase_operating_unit.view_purchase_order_filter
#: model_terms:ir.ui.view,arch_db:purchase_operating_unit.view_purchase_order_search
msgid "Operating Unit"
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model,name:purchase_operating_unit.model_purchase_report
msgid "Purchase Report"
msgstr ""

#. module: purchase_operating_unit
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order__requesting_operating_unit_id
msgid "Requesting Operating Unit"
msgstr ""

#. module: purchase_operating_unit
#. odoo-python
#: code:addons/purchase_operating_unit/models/account_move.py:0
msgid ""
"The operating unit of the purchase order must be the same as in the "
"associated invoices."
msgstr ""
3 changes: 3 additions & 0 deletions purchase_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import purchase_order
from . import account_move
43 changes: 43 additions & 0 deletions purchase_operating_unit/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2015-17 ForgeFlow S.L.
# - Jordi Ballester Alomar
# Copyright 2015-17 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# © 2026-27 CIT Services - Solomon Prabu
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, models
from odoo.exceptions import ValidationError


class AccountMove(models.Model):
_inherit = "account.move"

# Load all unsold PO lines
@api.onchange("purchase_vendor_bill_id", "purchase_id")
def _onchange_purchase_auto_complete(self):
"""
Override to add Operating Unit from Purchase Order to Invoice.
"""
purchase_id = self.purchase_id
if self.purchase_vendor_bill_id.purchase_order_id:
purchase_id = self.purchase_vendor_bill_id.purchase_order_id
if purchase_id and purchase_id.operating_unit_id:
# Assign OU from PO to Invoice
self.operating_unit_id = purchase_id.operating_unit_id.id
return super()._onchange_purchase_auto_complete()


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

@api.constrains("operating_unit_id", "purchase_line_id")
def _check_invoice_ou(self):
for line in self:
if (
line.purchase_line_id
and line.operating_unit_id != line.purchase_line_id.operating_unit_id
):
raise ValidationError(
self.env._(
"The operating unit of the purchase order must "
"be the same as in the associated invoices."
)
)
Loading
Loading