diff --git a/purchase_operating_unit/README.rst b/purchase_operating_unit/README.rst
index 53cc27fdbd..621ff8d321 100644
--- a/purchase_operating_unit/README.rst
+++ b/purchase_operating_unit/README.rst
@@ -14,13 +14,13 @@ Operating Unit in Purchase Orders
: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/12.0/purchase_operating_unit
+ :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-12-0/operating-unit-12-0-purchase_operating_unit
+ :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/12.0
+ :target: https://runbot.odoo-community.org/runbot/213/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -60,7 +60,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 smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -79,6 +79,7 @@ Contributors
* Jordi Ballester Alomar
* Aaron Henriquez
* Sudhir Arya
+* Nicola Studer
Maintainers
~~~~~~~~~~~
@@ -93,6 +94,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/operating-unit `_ project on GitHub.
+This module is part of the `OCA/operating-unit `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/purchase_operating_unit/__manifest__.py b/purchase_operating_unit/__manifest__.py
index aa8c1da7d5..8f1be2e99f 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": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"author": "Eficent, "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",
diff --git a/purchase_operating_unit/i18n/purchase_operating_unit.pot b/purchase_operating_unit/i18n/purchase_operating_unit.pot
index 1f1bb85df3..801a2787d9 100644
--- a/purchase_operating_unit/i18n/purchase_operating_unit.pot
+++ b/purchase_operating_unit/i18n/purchase_operating_unit.pot
@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * purchase_operating_unit
+# * purchase_operating_unit
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -14,15 +14,19 @@ msgstr ""
"Plural-Forms: \n"
#. module: purchase_operating_unit
-#: code:addons/purchase_operating_unit/models/purchase_order.py:82
+#: 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."
+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:71
+#: 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."
+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
@@ -31,19 +35,20 @@ msgid "Deliver To"
msgstr ""
#. module: purchase_operating_unit
-#: model:ir.model,name:purchase_operating_unit.model_account_invoice
-msgid "Invoice"
+#: 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_invoice_line
-msgid "Invoice Line"
+#: 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:97
+#: 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"
+msgid ""
+"No Warehouse found with the Operating Unit indicated in the Purchase Order"
msgstr ""
#. module: purchase_operating_unit
@@ -70,13 +75,14 @@ msgid "Requesting Operating Unit"
msgstr ""
#. module: purchase_operating_unit
-#: code:addons/purchase_operating_unit/models/account_invoice.py:43
+#: 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."
+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 picking type of incoming shipment"
+msgid "This will determine operation type of incoming shipment"
msgstr ""
-
diff --git a/purchase_operating_unit/models/account_invoice.py b/purchase_operating_unit/models/account_invoice.py
index 267c79f60c..c3bea48b5b 100644
--- a/purchase_operating_unit/models/account_invoice.py
+++ b/purchase_operating_unit/models/account_invoice.py
@@ -5,35 +5,37 @@
from odoo import _, api, exceptions, models
-class AccountInvoice(models.Model):
- _inherit = "account.invoice"
+class AccountMove(models.Model):
+ _inherit = "account.move"
# Load all unsold PO lines
- @api.onchange("purchase_id")
- def purchase_order_change(self):
+ @api.onchange("purchase_vendor_bill_id", "purchase_id")
+ def _onchange_purchase_auto_complete(self):
"""
Override to add Operating Unit from Purchase Order to Invoice.
"""
- if self.purchase_id and self.purchase_id.operating_unit_id:
+ 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 = self.purchase_id.operating_unit_id.id
- return super(AccountInvoice, self).purchase_order_change()
+ self.operating_unit_id = purchase_id.operating_unit_id.id
+ return super()._onchange_purchase_auto_complete()
@api.onchange("operating_unit_id")
- def _onchange_allowed_purchase_ids(self):
+ def _onchange_operating_unit_id(self):
"""
Show only the purchase orders that have the same operating unit
"""
- result = super(AccountInvoice, self)._onchange_allowed_purchase_ids()
+ return {
+ "domain": {
+ "purchase_id": [("operating_unit_id", "=", self.operating_unit_id.id)]
+ }
+ }
- result["domain"]["purchase_id"] += [
- ("operating_unit_id", "=", self.operating_unit_id.id)
- ]
- return result
-
-class AccountInvoiceLines(models.Model):
- _inherit = "account.invoice.line"
+class AccountMoveLine(models.Model):
+ _inherit = "account.move.line"
@api.constrains("operating_unit_id", "purchase_line_id")
def _check_invoice_ou(self):
diff --git a/purchase_operating_unit/models/purchase_order.py b/purchase_operating_unit/models/purchase_order.py
index 70dd184a43..cf259d8323 100644
--- a/purchase_operating_unit/models/purchase_order.py
+++ b/purchase_operating_unit/models/purchase_order.py
@@ -49,16 +49,12 @@ def _default_picking_type(self):
)
picking_type_id = fields.Many2one(
- comodel_name="stock.picking.type",
- string="Deliver To",
- help="This will determine picking type of incoming shipment",
- required=True,
states={
"confirmed": [("readonly", True)],
"approved": [("readonly", True)],
"done": [("readonly", True)],
},
- default=lambda self: self._default_picking_type(),
+ default=_default_picking_type,
)
@api.constrains("operating_unit_id", "picking_type_id")
diff --git a/purchase_operating_unit/readme/CONTRIBUTORS.rst b/purchase_operating_unit/readme/CONTRIBUTORS.rst
index 4244f4e535..d5625161d4 100644
--- a/purchase_operating_unit/readme/CONTRIBUTORS.rst
+++ b/purchase_operating_unit/readme/CONTRIBUTORS.rst
@@ -1,3 +1,4 @@
* Jordi Ballester Alomar
* Aaron Henriquez
* Sudhir Arya
+* Nicola Studer
diff --git a/purchase_operating_unit/static/description/index.html b/purchase_operating_unit/static/description/index.html
index 7457d289d2..928586103d 100644
--- a/purchase_operating_unit/static/description/index.html
+++ b/purchase_operating_unit/static/description/index.html
@@ -367,7 +367,7 @@ Operating Unit in Purchase Orders
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
+
This module introduces the following features:
- It introduces the operating unit to the purchase order.
@@ -411,7 +411,7 @@
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 smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -438,7 +439,7 @@
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 project on GitHub.
+
This module is part of the OCA/operating-unit project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/purchase_operating_unit/tests/test_po_security.py b/purchase_operating_unit/tests/test_po_security.py
index 2b5fcc6cdd..48119c4167 100644
--- a/purchase_operating_unit/tests/test_po_security.py
+++ b/purchase_operating_unit/tests/test_po_security.py
@@ -11,44 +11,44 @@ def test_po_ou_security(self):
# User 2 is only assigned to Operating Unit 2, and cannot list
# purchase orders from Operating Unit 1.
po_ids = (
- self.PurchaseOrder.sudo(self.user2_id)
+ self.PurchaseOrder.with_user(self.user2_id)
.search([("operating_unit_id", "=", self.ou1.id)])
.ids
)
self.assertEqual(po_ids, [])
# User 2 cannot list the picking that was created from PO 1
picking_ids = (
- self.StockPicking.sudo(self.user2_id)
+ self.StockPicking.with_user(self.user2_id)
.search([("id", "in", self.purchase1.picking_ids.ids)])
.ids
)
self.assertEqual(picking_ids, [])
# User 2 cannot list the invoice that was created from PO 1
invoice_ids = (
- self.AccountInvoice.sudo(self.user2_id)
- .search([("purchase_id", "=", self.purchase1.id)])
+ self.AccountInvoice.with_user(self.user2_id)
+ .search([("id", "=", self.invoice.id)])
.ids
)
self.assertEqual(invoice_ids, [])
# User 1 is assigned to Operating Unit 1, and can list
# the purchase order 1 from Operating Unit 1.
po_ids = (
- self.PurchaseOrder.sudo(self.user1_id)
+ self.PurchaseOrder.with_user(self.user1_id)
.search([("operating_unit_id", "=", self.ou1.id)])
.ids
)
self.assertNotEqual(po_ids, [])
# User 1 can list the picking that was created from PO 1
picking_ids = (
- self.StockPicking.sudo(self.user1_id)
+ self.StockPicking.with_user(self.user1_id)
.search([("id", "in", self.purchase1.picking_ids.ids)])
.ids
)
self.assertNotEqual(picking_ids, [])
- # # User 1 can list the invoice that was created from PO 2
+ # User 1 can list the invoice that was created from PO 2
invoice_ids = (
- self.AccountInvoice.sudo(self.user1_id)
- .search([("purchase_id", "=", self.purchase1.id)])
+ self.AccountInvoice.with_user(self.user1_id)
+ .search([("id", "=", self.invoice.id)])
.ids
)
self.assertNotEqual(invoice_ids, [])
diff --git a/purchase_operating_unit/tests/test_purchase_operating_unit.py b/purchase_operating_unit/tests/test_purchase_operating_unit.py
index ef6ab00912..327e659711 100644
--- a/purchase_operating_unit/tests/test_purchase_operating_unit.py
+++ b/purchase_operating_unit/tests/test_purchase_operating_unit.py
@@ -14,7 +14,7 @@ def setUp(self):
self.ResUsers = self.env["res.users"]
self.StockPicking = self.env["stock.picking"]
self.PurchaseOrder = self.env["purchase.order"]
- self.AccountInvoice = self.env["account.invoice"]
+ self.AccountInvoice = self.env["account.move"]
# company
self.company1 = self.env.ref("base.main_company")
self.company2 = self.env.ref("stock.res_company_1")
@@ -32,7 +32,7 @@ def setUp(self):
self.product2 = self.env.ref("product.product_product_9")
self.product3 = self.env.ref("product.product_product_11")
# Account
- self.account = self.env.ref("l10n_generic_coa.conf_a_pay")
+ self.account = self.env.ref("l10n_generic_coa.payable")
# Create users
self.user1_id = self._create_user(
"user_1",
@@ -50,8 +50,8 @@ def setUp(self):
self.user1_id,
[(self.product1, 1000), (self.product2, 500), (self.product3, 800)],
)
- self.purchase1.sudo(self.user1_id).button_confirm()
- self._create_invoice(self.purchase1, self.partner1, self.account)
+ self.purchase1.with_user(self.user1_id).button_confirm()
+ self.invoice = self._create_invoice(self.purchase1, self.partner1, self.account)
def _create_user(self, login, groups, company, operating_units):
""" Create a user."""
@@ -85,7 +85,7 @@ def _create_purchase(self, user_id, line_products):
"date_planned": time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
}
lines.append((0, 0, line_values))
- purchase = self.PurchaseOrder.sudo(user_id).create(
+ purchase = self.PurchaseOrder.with_user(user_id).create(
{
"operating_unit_id": self.ou1.id,
"requesting_operating_unit_id": self.ou1.id,
@@ -101,7 +101,7 @@ def _create_invoice(self, purchase, partner, account):
invoice_vals = {
"purchase_id": purchase.id,
"partner_id": partner.id,
- "account_id": account.id,
+ # "account_id": account.id,
"type": "in_invoice",
}
purchase_context = {
@@ -109,5 +109,7 @@ def _create_invoice(self, purchase, partner, account):
"active_ids": purchase.ids,
"active_model": "purchase.order",
}
- self.env["account.invoice"].with_context(purchase_context).create(invoice_vals)
- return True
+ res = (
+ self.env["account.move"].with_context(purchase_context).create(invoice_vals)
+ )
+ return res