Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] purchase_operating_unit: Migration to 17.0 #674

Open
wants to merge 42 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
11e06f5
Added Purchase Operating Unit module.
sudhir-serpentcs Dec 31, 2015
d5eb3ee
Improved the unit test case for Purchase OU.
sudhir-serpentcs Jan 2, 2016
4da776f
Improved the code of unit test cases and of constraint.
sudhir-serpentcs Jan 8, 2016
486f2f2
Migrated the module with test cases.
sudhir-serpentcs Feb 22, 2016
cc344e5
create PO from procurement
JordiBForgeFlow Oct 6, 2016
0c0a4b4
[MIG] purchase_operating_unit: Migrated to 10.0
AaronHForgeFlow Jan 31, 2017
4785260
[FIX] readonly on OU
serpentcs-dev1 Jul 4, 2017
d1582de
[FIX] when the procurement location is not internal the PO may belong…
AaronHForgeFlow Nov 22, 2017
debe8e6
[FIX]PYLINT mainly
AaronHForgeFlow Jun 11, 2018
40d4f86
[MIG] purchase_operating_unit: Migration to v12.0
bjeficent Dec 18, 2018
3e18790
[UPD] Update purchase_operating_unit.pot
oca-travis Oct 30, 2019
3d9c23c
[UPD] README.rst
OCA-git-bot Oct 30, 2019
8f7cc75
[IMP] purchase_operating_unit: black, isort, prettier
BT-nstuder Jan 7, 2020
a3aaadb
[MIG] purchase_operating_unit: Migration to 13.0
BT-nstuder Jan 8, 2020
ba9fd5b
[UPD] Update purchase_operating_unit.pot
oca-travis Apr 30, 2020
8eda195
[UPD] README.rst
OCA-git-bot Apr 30, 2020
3fae060
[FIX] Fixed Issue #291
nikul-serpentcs Oct 1, 2020
994a56a
[UPD] README.rst
OCA-git-bot Oct 1, 2020
1c38303
purchase_operating_unit 13.0.1.0.1
OCA-git-bot Oct 1, 2020
a9865a5
[UPD] Eficent -> ForgeFlow
MiquelRForgeFlow Oct 5, 2020
4b79666
[UPD] README.rst
OCA-git-bot Oct 5, 2020
291419b
[IMP] : black, isort, prettier
kittiu Dec 4, 2020
13d6782
[14.0][MIG] purchase_operating_unit
kittiu Dec 4, 2020
47d3078
[UPD] Update purchase_operating_unit.pot
oca-travis May 30, 2021
819176b
[UPD] README.rst
OCA-git-bot May 30, 2021
19e3985
[14.0][FIX] purchase_operating_unit, add OU when create invoice
kittiu Jun 15, 2021
a0357ba
purchase_operating_unit 14.0.1.0.1
OCA-git-bot Aug 3, 2021
e0e9390
[14.0][FIX] purchase_operating_unit
kittiu Oct 19, 2021
d3f4579
purchase_operating_unit 14.0.1.0.2
OCA-git-bot Oct 19, 2021
f38d4c1
[IMP] purchase_operating_unit: black, isort, prettier
alan196 Jan 13, 2022
bb81ac2
[MIG] purchase_operating_unit: Migration to 15.0
alan196 Jan 13, 2022
df2cb3f
[UPD] Update purchase_operating_unit.pot
Mar 8, 2023
5422bf3
[UPD] README.rst
OCA-git-bot Mar 8, 2023
35a9114
[UPD] README.rst
OCA-git-bot Sep 3, 2023
917ed75
[ENH] purchase_operating_unit: add OU to Purchase Analysis Report
ps-tubtim Oct 10, 2023
ae79fb6
[UPD] Update purchase_operating_unit.pot
Oct 10, 2023
7fb4168
[BOT] post-merge updates
OCA-git-bot Oct 10, 2023
4a854a5
[FIX] purchase_operating_unit: Fix warning from an onchange function …
May 15, 2024
d379ca0
[UPD] Update purchase_operating_unit.pot
May 24, 2024
d54a5b4
[BOT] post-merge updates
OCA-git-bot May 24, 2024
c0c69a2
[IMP] purchase_operating_unit: pre-commit execution
jdidderen-nsi May 29, 2024
beda0bf
[MIG] purchase_operating_unit: Migration to 17.0
jdidderen-nsi May 29, 2024
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
11 changes: 7 additions & 4 deletions operating_unit/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -441,7 +442,9 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
96 changes: 96 additions & 0 deletions purchase_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
=================================
Operating Unit in Purchase Orders
=================================

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

.. |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
: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/17.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-17-0/operating-unit-17-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=17.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:%2017.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 <[email protected]>
- Aaron Henriquez <[email protected]>
- Sudhir Arya <[email protected]>
- Nicola Studer <[email protected]>
- Nikul Chaudhary <[email protected]>
- Kitti U. <[email protected]>
- Alan Ramos <[email protected]>

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/17.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
# 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": "17.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>
77 changes: 77 additions & 0 deletions purchase_operating_unit/i18n/purchase_operating_unit.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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
#: 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 ""

#. 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.fields,field_description:purchase_operating_unit.field_account_bank_statement_line__purchase_ou_domain
#: model:ir.model.fields,field_description:purchase_operating_unit.field_account_move__purchase_ou_domain
#: model:ir.model.fields,field_description:purchase_operating_unit.field_account_payment__purchase_ou_domain
msgid "Purchase Ou Domain"
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
#: 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 ""
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
42 changes: 42 additions & 0 deletions purchase_operating_unit/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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).
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

Check warning on line 20 in purchase_operating_unit/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

purchase_operating_unit/models/account_move.py#L20

Added line #L20 was not covered by tests
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

Check warning on line 23 in purchase_operating_unit/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

purchase_operating_unit/models/account_move.py#L23

Added line #L23 was not covered by tests
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(
_(
"The operating unit of the purchase order must "
"be the same as in the associated invoices."
)
)
58 changes: 58 additions & 0 deletions purchase_operating_unit/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
default=lambda self: (
self.env["res.users"]._get_default_operating_unit(self.env.uid)
),
check_company=True,
)

requesting_operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Requesting Operating Unit",
default=lambda self: (
self.env["res.users"]._get_default_operating_unit(self.env.uid)
),
check_company=True,
)

@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for record in self:
if (
record.company_id
and record.operating_unit_id
and record.company_id != record.operating_unit_id.company_id
):
raise ValidationError(
_(
"Configuration error. The Company in the Purchase Order "
"and in the Operating Unit must be the same."
)
)

def _prepare_invoice(self):
invoice_vals = super()._prepare_invoice()
invoice_vals["operating_unit_id"] = self.operating_unit_id.id
return invoice_vals


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

operating_unit_id = fields.Many2one(
related="order_id.operating_unit_id",
string="Operating Unit",
check_company=True,
)
3 changes: 3 additions & 0 deletions purchase_operating_unit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
7 changes: 7 additions & 0 deletions purchase_operating_unit/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Jordi Ballester Alomar \<<[email protected]>\>
- Aaron Henriquez \<<[email protected]>\>
- Sudhir Arya \<<[email protected]>\>
- Nicola Studer \<<[email protected]>\>
- Nikul Chaudhary \<<[email protected]>\>
- Kitti U. \<<[email protected]>\>
- Alan Ramos \<<[email protected]>\>
Loading
Loading