diff --git a/purchase_operating_unit/README.rst b/purchase_operating_unit/README.rst new file mode 100644 index 0000000000..b693a9deaa --- /dev/null +++ b/purchase_operating_unit/README.rst @@ -0,0 +1,93 @@ +================================= +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/15.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-15-0/operating-unit-15-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/15.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. +- 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 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. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow +* Serpent Consulting Services Pvt. Ltd. + +Contributors +~~~~~~~~~~~~ + +* Jordi Ballester Alomar +* Aaron Henriquez +* Sudhir Arya +* Nicola Studer +* Nikul Chaudhary +* Kitti U. +* Alan Ramos + +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 `_ 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/__init__.py b/purchase_operating_unit/__init__.py new file mode 100644 index 0000000000..133f68732d --- /dev/null +++ b/purchase_operating_unit/__init__.py @@ -0,0 +1,2 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import models diff --git a/purchase_operating_unit/__manifest__.py b/purchase_operating_unit/__manifest__.py new file mode 100644 index 0000000000..a63030d8dc --- /dev/null +++ b/purchase_operating_unit/__manifest__.py @@ -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": "16.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", + "views/purchase_order_view.xml", + "views/purchase_order_line_view.xml", + ], + "demo": ["demo/purchase_order_demo.xml"], + "installable": True, +} diff --git a/purchase_operating_unit/demo/purchase_order_demo.xml b/purchase_operating_unit/demo/purchase_order_demo.xml new file mode 100644 index 0000000000..af80cc9aac --- /dev/null +++ b/purchase_operating_unit/demo/purchase_order_demo.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/purchase_operating_unit/i18n/purchase_operating_unit.pot b/purchase_operating_unit/i18n/purchase_operating_unit.pot new file mode 100644 index 0000000000..54c0e4539a --- /dev/null +++ b/purchase_operating_unit/i18n/purchase_operating_unit.pot @@ -0,0 +1,63 @@ +# 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_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_move.py:0 +#, python-format +msgid "" +"The operating unit of the purchase order must be the same as in the " +"associated invoices." +msgstr "" diff --git a/purchase_operating_unit/models/__init__.py b/purchase_operating_unit/models/__init__.py new file mode 100644 index 0000000000..105a10e6f7 --- /dev/null +++ b/purchase_operating_unit/models/__init__.py @@ -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 diff --git a/purchase_operating_unit/models/account_move.py b/purchase_operating_unit/models/account_move.py new file mode 100644 index 0000000000..821be7e559 --- /dev/null +++ b/purchase_operating_unit/models/account_move.py @@ -0,0 +1,53 @@ +# 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 + 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 ValidationError( + _( + "The operating unit of the purchase order must " + "be the same as in the associated invoices." + ) + ) diff --git a/purchase_operating_unit/models/purchase_order.py b/purchase_operating_unit/models/purchase_order.py new file mode 100644 index 0000000000..07810dfe0a --- /dev/null +++ b/purchase_operating_unit/models/purchase_order.py @@ -0,0 +1,62 @@ +# 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" + + READONLY_STATES = { + "purchase": [("readonly", True)], + "done": [("readonly", True)], + "cancel": [("readonly", True)], + } + + operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + string="Operating Unit", + states=READONLY_STATES, + default=lambda self: ( + self.env["res.users"].operating_unit_default_get(self.env.uid) + ), + ) + + requesting_operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + string="Requesting Operating Unit", + states=READONLY_STATES, + default=lambda self: ( + self.env["res.users"].operating_unit_default_get(self.env.uid) + ), + ) + + @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" + ) diff --git a/purchase_operating_unit/readme/CONTRIBUTORS.rst b/purchase_operating_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..9f02e3f0b7 --- /dev/null +++ b/purchase_operating_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* Jordi Ballester Alomar +* Aaron Henriquez +* Sudhir Arya +* Nicola Studer +* Nikul Chaudhary +* Kitti U. +* Alan Ramos diff --git a/purchase_operating_unit/readme/DESCRIPTION.rst b/purchase_operating_unit/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..10d7911fa2 --- /dev/null +++ b/purchase_operating_unit/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +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. diff --git a/purchase_operating_unit/readme/USAGE.rst b/purchase_operating_unit/readme/USAGE.rst new file mode 100644 index 0000000000..fb2deacb52 --- /dev/null +++ b/purchase_operating_unit/readme/USAGE.rst @@ -0,0 +1,5 @@ +#. 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 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. diff --git a/purchase_operating_unit/security/purchase_security.xml b/purchase_operating_unit/security/purchase_security.xml new file mode 100644 index 0000000000..970d195ac3 --- /dev/null +++ b/purchase_operating_unit/security/purchase_security.xml @@ -0,0 +1,31 @@ + + + + + + + + + ['|',('operating_unit_id','=',False),('operating_unit_id','in', user.operating_unit_ids.ids)] + PO's from allowed operating units + + + + + + + + + ['|',('operating_unit_id','=',False),('operating_unit_id','in', user.operating_unit_ids.ids)] + PO lines from allowed operating units + + + + + + + diff --git a/purchase_operating_unit/static/description/icon.png b/purchase_operating_unit/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/purchase_operating_unit/static/description/icon.png differ diff --git a/purchase_operating_unit/static/description/index.html b/purchase_operating_unit/static/description/index.html new file mode 100644 index 0000000000..a9b0660348 --- /dev/null +++ b/purchase_operating_unit/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +Operating Unit in Purchase Orders + + + +
+

Operating Unit in Purchase Orders

+ + +

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

+

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

+ +
+

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

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+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.

+

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/__init__.py b/purchase_operating_unit/tests/__init__.py new file mode 100644 index 0000000000..9c86acd517 --- /dev/null +++ b/purchase_operating_unit/tests/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import test_purchase_operating_unit +from . import test_po_security diff --git a/purchase_operating_unit/tests/test_po_security.py b/purchase_operating_unit/tests/test_po_security.py new file mode 100644 index 0000000000..ae0a82f5e8 --- /dev/null +++ b/purchase_operating_unit/tests/test_po_security.py @@ -0,0 +1,40 @@ +# 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 . import test_purchase_operating_unit as test_po_ou # noqa + + +class TestPoSecurity(test_po_ou.TestPurchaseOperatingUnit): + def test_po_ou_security(self): + """Test Security of Purchase Operating Unit""" + # User 2 is only assigned to Operating Unit 2, and cannot list + # purchase orders from Operating Unit 1. + po_ids = ( + self.PurchaseOrder.with_user(self.user2_id) + .search([("operating_unit_id", "=", self.ou1.id)]) + .ids + ) + self.assertEqual(po_ids, []) + # User 2 cannot list the invoice that was created from PO 1 + invoice_ids = ( + 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.with_user(self.user1_id) + .search([("operating_unit_id", "=", self.ou1.id)]) + .ids + ) + self.assertNotEqual(po_ids, []) + # User 1 can list the invoice that was created from PO 2 + invoice_ids = ( + 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 new file mode 100644 index 0000000000..291b75f17f --- /dev/null +++ b/purchase_operating_unit/tests/test_purchase_operating_unit.py @@ -0,0 +1,168 @@ +# 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). +import time + +from odoo.exceptions import AccessError, ValidationError +from odoo.tests import Form, common +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT + + +class TestPurchaseOperatingUnit(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.ResUsers = cls.env["res.users"] + cls.PurchaseOrder = cls.env["purchase.order"] + cls.AccountInvoice = cls.env["account.move"] + cls.AccountAccount = cls.env["account.account"] + # company + cls.company = cls.env.ref("base.main_company") + # groups + cls.group_purchase_user = cls.env.ref("purchase.group_purchase_user") + cls.group_operating_unit = cls.env.ref( + "operating_unit.group_multi_operating_unit" + ) + # Main Operating Unit + cls.ou1 = cls.env.ref("operating_unit.main_operating_unit") + # B2B Operating Unit + cls.b2b = cls.env.ref("operating_unit.b2b_operating_unit") + # Partner + cls.partner1 = cls.env.ref("base.res_partner_1") + # Products + cls.product1 = cls.env.ref("product.product_product_7") + cls.product2 = cls.env.ref("product.product_product_9") + cls.product3 = cls.env.ref("product.product_product_11") + # Account + # payable_acc_type = cls.env.ref("account.data_account_type_payable").id + cls.account = cls.AccountAccount.search( + [("account_type", "=", "liability_payable")], limit=1 + ) + # Create users + cls.user1_id = cls._create_user( + "user_1", + [cls.group_purchase_user, cls.group_operating_unit], + cls.company, + [cls.ou1], + ) + cls.user2_id = cls._create_user( + "user_2", + [cls.group_purchase_user], + cls.company, + [cls.b2b], + ) + cls.purchase1 = cls._create_purchase( + cls.user1_id, + [(cls.product1, 1000), (cls.product2, 500), (cls.product3, 800)], + ) + cls.purchase1.with_user(cls.user1_id).button_confirm() + cls.purchase1.order_line[0].qty_received = cls.purchase1.order_line[ + 0 + ].product_qty + cls.purchase1.with_user(cls.user1_id).action_create_invoice() + # cls.invoice = cls._create_invoice(cls.purchase1, cls.partner1, cls.account) + cls.invoice = cls.purchase1.invoice_ids[0] + + @classmethod + def _create_user(cls, login, groups, company, operating_units): + """Create a user.""" + group_ids = [group.id for group in groups] + user = cls.ResUsers.with_context(**{"no_reset_password": True}).create( + { + "name": "Chicago Purchase User", + "login": login, + "password": "demo", + "email": "chicago@yourcompany.com", + "company_id": company.id, + "company_ids": [(4, company.id)], + "operating_unit_ids": [(4, ou.id) for ou in operating_units], + "groups_id": [(6, 0, group_ids)], + } + ) + return user.id + + @classmethod + def _create_purchase(cls, user_id, line_products): + """Create a purchase order. + ``line_products`` is a list of tuple [(product, qty)] + """ + lines = [] + for product, qty in line_products: + line_values = { + "name": product.name, + "product_id": product.id, + "product_qty": qty, + "product_uom": product.uom_id.id, + "price_unit": 50, + "date_planned": time.strftime(DEFAULT_SERVER_DATETIME_FORMAT), + } + lines.append((0, 0, line_values)) + purchase = cls.PurchaseOrder.with_user(user_id).create( + { + "operating_unit_id": cls.ou1.id, + "requesting_operating_unit_id": cls.ou1.id, + "partner_id": cls.partner1.id, + "order_line": lines, + "company_id": cls.company.id, + } + ) + return purchase + + @classmethod + def _create_invoice(cls, purchase, partner, account): + """Create a vendor invoice for the purchase order.""" + invoice_vals = { + "purchase_id": purchase.id, + "partner_id": partner.id, + "move_type": "in_invoice", + } + purchase_context = { + "active_id": purchase.id, + "active_ids": purchase.ids, + "active_model": "purchase.order", + } + res = ( + cls.env["account.move"] + .with_context(**purchase_context) + .create(invoice_vals) + ) + return res + + def test_01_purchase_operating_unit(self): + self.purchase1.button_cancel() + self.purchase1.button_draft() + # Check change operating unit in purchase + with self.assertRaises(ValidationError): + self.b2b.company_id = False + # The user_1 is used here so he's able to see the field operating_unit + with Form(self.purchase1.with_user(self.user1_id)) as po: + po.operating_unit_id = self.b2b + # This has been changed to follow the standard flow of creating a + # purchase order and then billing + self.purchase1.with_user(self.user1_id).button_confirm() + # self.purchase1.order_line[0].qty_received = self.purchase1.order_line[0].product_qty + # self.purchase1.with_user(self.user1_id).action_create_invoice() + # Create Vendor Bill + # The user_1 is used here so he's able to see the field purchase_id + # f = Form(self.env["account.move"].with_context( + # default_move_type="in_invoice").with_user(self.user1_id)) + # f.partner_id = self.purchase1.partner_id + # f.purchase_id = self.purchase1 + # invoice = f.save() + + self.assertEqual( + self.purchase1.invoice_ids[0].operating_unit_id, + self.purchase1.operating_unit_id, + ) + self.assertEqual( + self.purchase1.invoice_ids[0].invoice_line_ids[0].operating_unit_id, + self.purchase1.invoice_ids[0] + .invoice_line_ids[0] + .purchase_line_id.operating_unit_id, + ) + # Check change operating unit in invoice line != purchase line, + # it should error. + with self.assertRaises(AccessError): + with Form(self.purchase1.invoice_ids[0].invoice_line_ids[0]) as line: + line.operating_unit_id = self.b2b diff --git a/purchase_operating_unit/views/purchase_order_line_view.xml b/purchase_operating_unit/views/purchase_order_line_view.xml new file mode 100644 index 0000000000..32c4b0b2d3 --- /dev/null +++ b/purchase_operating_unit/views/purchase_order_line_view.xml @@ -0,0 +1,50 @@ + + + + purchase_order_line_tree + purchase.order.line + + + + + + + + + purchase_order_line_form + purchase.order.line + + + + + + + + + purchase_order_line_search + purchase.order.line + + + + + + + + + + + diff --git a/purchase_operating_unit/views/purchase_order_view.xml b/purchase_operating_unit/views/purchase_order_view.xml new file mode 100644 index 0000000000..8228a67d05 --- /dev/null +++ b/purchase_operating_unit/views/purchase_order_view.xml @@ -0,0 +1,63 @@ + + + + purchase_order_tree + purchase.order + + + + + + + + + purchase_order_form + purchase.order + + + + + + + + + + + + {'default_state': 'draft', 'operating_unit_id': operating_unit_id} + + + + + view_purchase_order_filter + purchase.order + + + + + + + + + + + diff --git a/setup/purchase_operating_unit/odoo/addons/purchase_operating_unit b/setup/purchase_operating_unit/odoo/addons/purchase_operating_unit new file mode 120000 index 0000000000..4695973c4e --- /dev/null +++ b/setup/purchase_operating_unit/odoo/addons/purchase_operating_unit @@ -0,0 +1 @@ +../../../../purchase_operating_unit \ No newline at end of file diff --git a/setup/purchase_operating_unit/setup.py b/setup/purchase_operating_unit/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/purchase_operating_unit/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)