-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by kittiu
- Loading branch information
Showing
22 changed files
with
1,225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
================================= | ||
Operating Unit in Purchase Orders | ||
================================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/13.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-13-0/operating-unit-13-0-purchase_operating_unit | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/213/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|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. | ||
- The operating unit is copied to the stock picking. | ||
- It implements user's security rules. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
#. Create a PO: the Default Operating Unit is assigned to the PO. If you want, | ||
you can change to another Operating Unit. | ||
#. Validate the PO: the Operating Unit is propagated to the Pickings and | ||
Invoices. | ||
#. From the invoice, it is not possible to change the Operating Unit, it has to | ||
be the same as the one of the PO. | ||
|
||
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 | ||
=========== | ||
|
||
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 smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20purchase_operating_unit%0Aversion:%2013.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> | ||
|
||
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/13.0/purchase_operating_unit>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# © 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": "14.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": ["stock_operating_unit", "purchase_stock"], | ||
"license": "LGPL-3", | ||
"data": [ | ||
"security/purchase_security.xml", | ||
"views/purchase_order_view.xml", | ||
"views/purchase_order_line_view.xml", | ||
], | ||
"demo": ["demo/purchase_order_demo.xml"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!--© 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).--> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_operating_unit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.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 | ||
#: code:addons/purchase_operating_unit/models/purchase_order.py:0 | ||
#, python-format | ||
msgid "" | ||
"Configuration error. The Quotation / Purchase Order and the Warehouse of " | ||
"picking type must belong to the same Operating Unit." | ||
msgstr "" | ||
|
||
#. module: purchase_operating_unit | ||
#: model:ir.model.fields,field_description:purchase_operating_unit.field_purchase_order__picking_type_id | ||
msgid "Deliver To" | ||
msgstr "" | ||
|
||
#. module: purchase_operating_unit | ||
#: model:ir.model,name:purchase_operating_unit.model_account_move | ||
msgid "Journal Entries" | ||
msgstr "" | ||
|
||
#. module: purchase_operating_unit | ||
#: model:ir.model,name:purchase_operating_unit.model_account_move_line | ||
msgid "Journal Item" | ||
msgstr "" | ||
|
||
#. module: purchase_operating_unit | ||
#: code:addons/purchase_operating_unit/models/purchase_order.py:0 | ||
#, python-format | ||
msgid "" | ||
"No Warehouse found with the Operating Unit indicated in the Purchase Order" | ||
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_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 | ||
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_purchase_order__requesting_operating_unit_id | ||
msgid "Requesting Operating Unit" | ||
msgstr "" | ||
|
||
#. module: purchase_operating_unit | ||
#: code:addons/purchase_operating_unit/models/account_invoice.py:0 | ||
#, python-format | ||
msgid "" | ||
"The operating unit of the purchase order must be the same as in the " | ||
"associated invoices." | ||
msgstr "" | ||
|
||
#. module: purchase_operating_unit | ||
#: model:ir.model.fields,help:purchase_operating_unit.field_purchase_order__picking_type_id | ||
msgid "This will determine operation type of incoming shipment" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_invoice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# © 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). | ||
from odoo import _, api, exceptions, models | ||
|
||
|
||
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() | ||
|
||
@api.onchange("operating_unit_id") | ||
def _onchange_operating_unit_id(self): | ||
""" | ||
Show only the purchase orders that have the same operating unit | ||
""" | ||
return { | ||
"domain": { | ||
"purchase_id": [("operating_unit_id", "=", self.operating_unit_id.id)] | ||
} | ||
} | ||
|
||
|
||
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 exceptions.ValidationError( | ||
_( | ||
"The operating unit of the purchase order must " | ||
"be the same as in the associated invoices." | ||
) | ||
) |
Oops, something went wrong.