From ede865db2c932f96221ad9f95545395d36626599 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 17 Feb 2016 15:49:35 +0100 Subject: [PATCH 01/16] [ADD] purchase request operating unit [FIX] remove reference to warehouse [ENH] purchase_request_operating_unit, purchase_rquest_procurement_operating_unit 9.0 purchase request operating unit - fixed travis (#81) * [FIX] travis --- purchase_request_operating_unit/README.rst | 58 ++++++++++++ purchase_request_operating_unit/__init__.py | 7 ++ .../__openerp__.py | 22 +++++ .../model/__init__.py | 6 ++ .../model/purchase_request.py | 53 +++++++++++ .../security/purchase_security.xml | 30 ++++++ .../tests/__init__.py | 6 ++ .../test_purchase_request_operating_unit.py | 92 +++++++++++++++++++ .../view/purchase_request_view.xml | 87 ++++++++++++++++++ 9 files changed, 361 insertions(+) create mode 100644 purchase_request_operating_unit/README.rst create mode 100644 purchase_request_operating_unit/__init__.py create mode 100644 purchase_request_operating_unit/__openerp__.py create mode 100644 purchase_request_operating_unit/model/__init__.py create mode 100644 purchase_request_operating_unit/model/purchase_request.py create mode 100644 purchase_request_operating_unit/security/purchase_security.xml create mode 100644 purchase_request_operating_unit/tests/__init__.py create mode 100644 purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py create mode 100644 purchase_request_operating_unit/view/purchase_request_view.xml diff --git a/purchase_request_operating_unit/README.rst b/purchase_request_operating_unit/README.rst new file mode 100644 index 0000000000..f935945a30 --- /dev/null +++ b/purchase_request_operating_unit/README.rst @@ -0,0 +1,58 @@ +.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg + :target: https://www.gnu.org/licenses/lgpl.html + :alt: License: LGPL-3 + +===================================== +Purchase Request with Operating Units +===================================== + +This module introduces the following features: + +* Adds the Operating Unit (OU) to the Purchase Request. +* The user’s default Operating Unit (OU) is proposed at the time of creating the Purchase Request. +* Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/213/9.0 + +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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Jordi Ballester Alomar +* Aaron Henriquez +* Serpent Consulting Services Pvt. Ltd. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/purchase_request_operating_unit/__init__.py b/purchase_request_operating_unit/__init__.py new file mode 100644 index 0000000000..6396f46584 --- /dev/null +++ b/purchase_request_operating_unit/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import model +from . import tests diff --git a/purchase_request_operating_unit/__openerp__.py b/purchase_request_operating_unit/__openerp__.py new file mode 100644 index 0000000000..5fbccf3600 --- /dev/null +++ b/purchase_request_operating_unit/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +{ + "name": "Operating Unit in Purchase Requests", + "version": "9.0.1.0.0", + "author": "Eficent" + "Serpent Consulting Services Pvt. Ltd.," + "Odoo Community Association (OCA)", + "license": "LGPL-3", + "website": "http://www.eficent.com", + "category": "Purchase Management", + "depends": ["purchase_request", + "purchase_operating_unit"], + "data": [ + "view/purchase_request_view.xml", + "security/purchase_security.xml", + ], + 'installable': True, +} diff --git a/purchase_request_operating_unit/model/__init__.py b/purchase_request_operating_unit/model/__init__.py new file mode 100644 index 0000000000..b091c29d62 --- /dev/null +++ b/purchase_request_operating_unit/model/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import purchase_request diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py new file mode 100644 index 0000000000..fd23b6e721 --- /dev/null +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from openerp import api, fields, models, _ + + +class PurchaseRequest(models.Model): + _inherit = 'purchase.request' + + operating_unit_id = fields.Many2one( + 'operating.unit', + string='Operating Unit', + default=lambda self: + self.env['res.users']. + operating_unit_default_get(self._uid), + ) + + @api.multi + @api.constrains('operating_unit_id', 'company_id') + def _check_company_operating_unit(self): + for rec in self: + if rec.company_id and rec.operating_unit_id and \ + rec.company_id != rec.operating_unit_id.company_id: + raise Warning(_("The Company in the Purchase Request and in " + "the Operating Unit must be the same.")) + + @api.multi + @api.constrains('operating_unit_id', 'picking_type_id') + def _check_warehouse_operating_unit(self): + for rec in self: + picking_type = rec.picking_type_id + if picking_type: + if picking_type.warehouse_id and\ + picking_type.warehouse_id.operating_unit_id\ + and rec.operating_unit_id and\ + picking_type.warehouse_id.operating_unit_id !=\ + rec.operating_unit_id: + raise Warning(_("Configuration error! The Purchase Request" + " and the Warehouse of picking type must" + " belong to the same Operating Unit.")) + + +class PurchaseRequestLine(models.Model): + _inherit = 'purchase.request.line' + + operating_unit_id = fields.Many2one( + 'operating.unit', + related='request_id.operating_unit_id', + string='Operating Unit', readonly=True, + store=True, + ) diff --git a/purchase_request_operating_unit/security/purchase_security.xml b/purchase_request_operating_unit/security/purchase_security.xml new file mode 100644 index 0000000000..29b86ea6a4 --- /dev/null +++ b/purchase_request_operating_unit/security/purchase_security.xml @@ -0,0 +1,30 @@ + + + + + + + ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Purchase Requests from allowed operating units + + + + + + + + + + ['|',('request_id.operating_unit_id','=',False),('request_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Purchase Requests lines from allowed operating units + + + + + + + + + diff --git a/purchase_request_operating_unit/tests/__init__.py b/purchase_request_operating_unit/tests/__init__.py new file mode 100644 index 0000000000..51e4ae06f7 --- /dev/null +++ b/purchase_request_operating_unit/tests/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from . import test_purchase_request_operating_unit diff --git a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py new file mode 100644 index 0000000000..94d75b85fe --- /dev/null +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +# © 2016 Eficent Business and IT Consulting Services S.L. +# © 2016 Serpent Consulting Services Pvt. Ltd. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from openerp.tests import common + + +class TestPurchaseRequestOperatingUnit(common.TransactionCase): + + def setUp(self): + super(TestPurchaseRequestOperatingUnit, self).setUp() + # Models + self.res_users_model = self.env['res.users'] + self.purchase_request = self.env['purchase.request'] + self.purchase_request_line = self.env['purchase.request.line'] + # Company + self.company = self.env.ref('base.main_company') + # Main Operating Unit + self.ou1 = self.env.ref('operating_unit.main_operating_unit') + # B2C Operating Unit + self.b2c = self.env.ref('operating_unit.b2c_operating_unit') + # Product + self.product1 = self.env.ref('product.product_product_7') + self.product_uom = self.env.ref('product.product_uom_unit') + # User + self.user_root = self.env.ref('base.user_root') + # Groups + self.grp_pr_mngr = self.env.\ + ref('purchase_request.group_purchase_request_manager') + # Picking Type + b2c_wh = self.env.ref('stock_operating_unit.stock_warehouse_b2c') + self.b2c_type_in_id = b2c_wh.in_type_id.id + self.picking_type = self.env.ref('stock.picking_type_in') + + # Creates Users and Purchase request + self.user1 = self._create_user( + 'user_1', [], self.company, [self.ou1]) + self.user2 = self._create_user( + 'user_2', self.grp_pr_mngr, self.company, [self.b2c]) + self.request1 = self._create_purchase_request(self.ou1) + self._purchase_line(self.request1) + self.request2 = self._create_purchase_request(self.b2c, + self.b2c_type_in_id) + self._purchase_line(self.request2) + + def _create_user(self, login, groups, company, operating_units, + context=None): + """ Create a user. """ + group_ids = [group.id for group in groups] + user = self.res_users_model.create({ + 'name': 'Test Purchase Request User', + 'login': login, + 'password': 'demo', + 'email': 'example@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 + + def _purchase_line(self, request): + line = self.purchase_request_line.create({ + 'request_id': request.id, + 'product_id': self.product1.id, + 'product_uom_id': self.product_uom.id, + 'product_qty': 5.0, + }) + return line + + def _create_purchase_request(self, operating_unit, picking_type=False): + if picking_type: + purchase_request = self.purchase_request.create({ + 'assigned_to': self.user_root.id, + 'picking_type_id': self.b2c_type_in_id, + 'operating_unit_id': operating_unit.id, + }) + else: + purchase_request = self.purchase_request.create({ + 'assigned_to': self.user_root.id, + 'picking_type_id': self.picking_type.id, + 'operating_unit_id': operating_unit.id, + }) + return purchase_request + + def test_purchase_request(self): + record = self.purchase_request.sudo(self.user2.id).\ + search([('id', '=', self.request1.id), + ('operating_unit_id', '=', self.ou1.id)]) + self.assertEqual(record.ids, [], 'User 2 should not have access to ' + 'OU %s' % self.ou1.name) diff --git a/purchase_request_operating_unit/view/purchase_request_view.xml b/purchase_request_operating_unit/view/purchase_request_view.xml new file mode 100644 index 0000000000..3edc97095e --- /dev/null +++ b/purchase_request_operating_unit/view/purchase_request_view.xml @@ -0,0 +1,87 @@ + + + + + + purchase.request.tree + purchase.request + + + + + + + + + + purchase.request.form + purchase.request + + + + + + + {'operating_unit_id': operating_unit_id} + + + + + + purchase.request.list.select + purchase.request + + + + + + + + + + + + + purchase.request.line.tree + purchase.request.line + + + + + + + + + + purchase.request.line.form + purchase.request.line + + + + + + + + + + purchase.request.line.search + purchase.request.line + + + + + + + + + + + + + From 78393a3dc4794e1251e2feb40a2c493f5a303378 Mon Sep 17 00:00:00 2001 From: Darshan Patel Date: Wed, 5 Jul 2017 15:56:08 +0530 Subject: [PATCH 02/16] [ADD] purchase_request_operating_unit v10 --- purchase_request_operating_unit/README.rst | 10 +- purchase_request_operating_unit/__init__.py | 6 +- .../{__openerp__.py => __manifest__.py} | 16 +- .../model/__init__.py | 6 +- .../model/purchase_request.py | 20 ++- .../security/purchase_security.xml | 53 +++--- .../tests/__init__.py | 6 +- .../test_purchase_request_operating_unit.py | 19 ++- .../view/purchase_request_view.xml | 151 +++++++++--------- 9 files changed, 155 insertions(+), 132 deletions(-) rename purchase_request_operating_unit/{__openerp__.py => __manifest__.py} (65%) diff --git a/purchase_request_operating_unit/README.rst b/purchase_request_operating_unit/README.rst index f935945a30..32a855bc6f 100644 --- a/purchase_request_operating_unit/README.rst +++ b/purchase_request_operating_unit/README.rst @@ -9,24 +9,29 @@ Purchase Request with Operating Units This module introduces the following features: * Adds the Operating Unit (OU) to the Purchase Request. + * The user’s default Operating Unit (OU) is proposed at the time of creating the Purchase Request. + * Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to. + Usage ===== .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/9.0 + :target: https://runbot.odoo-community.org/runbot/213/10.0 + Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case of trouble, please +`_. 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. + Credits ======= @@ -39,7 +44,6 @@ Contributors ------------ * Jordi Ballester Alomar -* Aaron Henriquez * Serpent Consulting Services Pvt. Ltd. Maintainer diff --git a/purchase_request_operating_unit/__init__.py b/purchase_request_operating_unit/__init__.py index 6396f46584..5ddc8fa5c3 100644 --- a/purchase_request_operating_unit/__init__.py +++ b/purchase_request_operating_unit/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import model diff --git a/purchase_request_operating_unit/__openerp__.py b/purchase_request_operating_unit/__manifest__.py similarity index 65% rename from purchase_request_operating_unit/__openerp__.py rename to purchase_request_operating_unit/__manifest__.py index 5fbccf3600..39a632e65d 100644 --- a/purchase_request_operating_unit/__openerp__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -1,22 +1,24 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent -# © 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Operating Unit in Purchase Requests", - "version": "9.0.1.0.0", - "author": "Eficent" - "Serpent Consulting Services Pvt. Ltd.," + "version": "10.0.1.0.0", + "author": "Eficent, " + "SerpentCS, " "Odoo Community Association (OCA)", - "license": "LGPL-3", "website": "http://www.eficent.com", + "license": "LGPL-3", "category": "Purchase Management", "depends": ["purchase_request", "purchase_operating_unit"], "data": [ - "view/purchase_request_view.xml", "security/purchase_security.xml", + "view/purchase_request_view.xml", ], 'installable': True, } diff --git a/purchase_request_operating_unit/model/__init__.py b/purchase_request_operating_unit/model/__init__.py index b091c29d62..b34e3625f7 100644 --- a/purchase_request_operating_unit/model/__init__.py +++ b/purchase_request_operating_unit/model/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import purchase_request diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py index fd23b6e721..f352bcc783 100644 --- a/purchase_request_operating_unit/model/purchase_request.py +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -1,9 +1,12 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models, _ +from odoo import fields, models, api, _ +from odoo.exceptions import ValidationError class PurchaseRequest(models.Model): @@ -23,8 +26,9 @@ def _check_company_operating_unit(self): for rec in self: if rec.company_id and rec.operating_unit_id and \ rec.company_id != rec.operating_unit_id.company_id: - raise Warning(_("The Company in the Purchase Request and in " - "the Operating Unit must be the same.")) + raise ValidationError(_('The Company in the Purchase Request ' + 'and in the Operating Unit must be' + 'the same.')) @api.multi @api.constrains('operating_unit_id', 'picking_type_id') @@ -37,9 +41,9 @@ def _check_warehouse_operating_unit(self): and rec.operating_unit_id and\ picking_type.warehouse_id.operating_unit_id !=\ rec.operating_unit_id: - raise Warning(_("Configuration error! The Purchase Request" - " and the Warehouse of picking type must" - " belong to the same Operating Unit.")) + raise ValidationError(_('Configuration error!\nThe\ + Purchase Request and the Warehouse of picking type\ + must belong to the same Operating Unit.')) class PurchaseRequestLine(models.Model): diff --git a/purchase_request_operating_unit/security/purchase_security.xml b/purchase_request_operating_unit/security/purchase_security.xml index 29b86ea6a4..309642053e 100644 --- a/purchase_request_operating_unit/security/purchase_security.xml +++ b/purchase_request_operating_unit/security/purchase_security.xml @@ -1,30 +1,31 @@ - - + + - - - ['|',('operating_unit_id','=',False),('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Purchase Requests from allowed operating units - - - - - - + + + ['|',('operating_unit_id','=',False), + ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Purchase Requests from allowed operating units + + + + + + - - - ['|',('request_id.operating_unit_id','=',False),('request_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])] - Purchase Requests lines from allowed operating units - - - - - - + + + ['|',('request_id.operating_unit_id','=',False), + ('request_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])] + Purchase Requests lines from allowed operating units + + + + + + - - + diff --git a/purchase_request_operating_unit/tests/__init__.py b/purchase_request_operating_unit/tests/__init__.py index 51e4ae06f7..2db7e3eb2e 100644 --- a/purchase_request_operating_unit/tests/__init__.py +++ b/purchase_request_operating_unit/tests/__init__.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_purchase_request_operating_unit diff --git a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py index 94d75b85fe..5fad5e8f3b 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- -# © 2016 Eficent Business and IT Consulting Services S.L. -# © 2016 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp.tests import common +from odoo.tests import common class TestPurchaseRequestOperatingUnit(common.TransactionCase): @@ -34,10 +36,13 @@ def setUp(self): self.picking_type = self.env.ref('stock.picking_type_in') # Creates Users and Purchase request - self.user1 = self._create_user( - 'user_1', [], self.company, [self.ou1]) - self.user2 = self._create_user( - 'user_2', self.grp_pr_mngr, self.company, [self.b2c]) + self.user1 = self._create_user('user_1', [], + self.company, + [self.ou1]) + self.user2 = self._create_user('user_2', + self.grp_pr_mngr, + self.company, + [self.b2c]) self.request1 = self._create_purchase_request(self.ou1) self._purchase_line(self.request1) self.request2 = self._create_purchase_request(self.b2c, diff --git a/purchase_request_operating_unit/view/purchase_request_view.xml b/purchase_request_operating_unit/view/purchase_request_view.xml index 3edc97095e..a4e1c0b8e3 100644 --- a/purchase_request_operating_unit/view/purchase_request_view.xml +++ b/purchase_request_operating_unit/view/purchase_request_view.xml @@ -1,87 +1,88 @@ - - - + + + - - purchase.request.tree - purchase.request - - - - - + + purchase.request.tree + purchase.request + + + + - + + - - purchase.request.form - purchase.request - - - - - - - {'operating_unit_id': operating_unit_id} - + + purchase.request.form + purchase.request + + + + - + + {'operating_unit_id': operating_unit_id} + + + - - purchase.request.list.select - purchase.request - - - - - - - - - - + + purchase.request.list.select + purchase.request + + + + + + + + + + - - purchase.request.line.tree - purchase.request.line - - - - - + + purchase.request.line.tree + purchase.request.line + + + + - + + - - purchase.request.line.form - purchase.request.line - - - - - + + purchase.request.line.form + purchase.request.line + + + + - + + - - purchase.request.line.search - purchase.request.line - - - - - - - - + + purchase.request.line.search + purchase.request.line + + + + - + + + + + - - + From fd72befb0f3ab2e54199151615e24fd2f53e989f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Be=C3=B1at=20Jimenez?= Date: Wed, 13 Feb 2019 12:10:54 +0100 Subject: [PATCH 03/16] [MIG] purchase_request_operating_unit: Migration to v12 merge with purchase_request_to_rfq_operating_unit --- purchase_request_operating_unit/README.rst | 78 +++- purchase_request_operating_unit/__init__.py | 6 +- .../__manifest__.py | 10 +- .../i18n/purchase_request_operating_unit.pot | 63 +++ .../model/__init__.py | 5 - .../model/purchase_request.py | 22 +- .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 7 + .../readme/USAGE.rst | 9 + .../security/purchase_security.xml | 10 +- .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 440 ++++++++++++++++++ .../tests/__init__.py | 6 +- .../test_purchase_request_operating_unit.py | 7 +- ..._purchase_request_to_rfq_operating_unit.py | 54 +++ .../view/purchase_request_view.xml | 38 +- .../wizard/__init__.py | 3 + ...rchase_request_line_make_purchase_order.py | 50 ++ ..._request_line_make_purchase_order_view.xml | 25 + 19 files changed, 766 insertions(+), 69 deletions(-) create mode 100644 purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot create mode 100644 purchase_request_operating_unit/readme/CONTRIBUTORS.rst create mode 100644 purchase_request_operating_unit/readme/DESCRIPTION.rst create mode 100644 purchase_request_operating_unit/readme/USAGE.rst create mode 100644 purchase_request_operating_unit/static/description/icon.png create mode 100644 purchase_request_operating_unit/static/description/index.html create mode 100644 purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py create mode 100644 purchase_request_operating_unit/wizard/__init__.py create mode 100644 purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py create mode 100644 purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml diff --git a/purchase_request_operating_unit/README.rst b/purchase_request_operating_unit/README.rst index 32a855bc6f..a5bacb2704 100644 --- a/purchase_request_operating_unit/README.rst +++ b/purchase_request_operating_unit/README.rst @@ -1,10 +1,29 @@ -.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg - :target: https://www.gnu.org/licenses/lgpl.html - :alt: License: LGPL-3 - -===================================== -Purchase Request with Operating Units -===================================== +=================================== +Operating Unit in Purchase Requests +=================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/12.0/purchase_request_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_request_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 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| This module introduces the following features: @@ -14,49 +33,62 @@ This module introduces the following features: * Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to. +**Table of contents** + +.. contents:: + :local: Usage ===== -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/10.0 +Follow these steps: +#. Create or use an existing Operating Unit (OU) in Settings -> + Users & Configuration -> Operating Unit. +#. Change the configuration of the Users. In Application Accesses, put an User + as Request manager and another one as Request User. +#. Create a Purchase Request Order. By default, if there is no Approver, any + Manager with the same OU can accept the PO. If you specify an Approver, he + must be in the same Operating Unit as the Purchase Request. 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. +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 ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Eficent +* SerpentCS Contributors ------------- +~~~~~~~~~~~~ * Jordi Ballester Alomar * Serpent Consulting Services Pvt. Ltd. -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit https://odoo-community.org. +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_request_operating_unit/__init__.py b/purchase_request_operating_unit/__init__.py index 5ddc8fa5c3..14550192e2 100644 --- a/purchase_request_operating_unit/__init__.py +++ b/purchase_request_operating_unit/__init__.py @@ -1,9 +1,5 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. -# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import model from . import tests +from . import wizard diff --git a/purchase_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index 39a632e65d..5d628f1aa8 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -1,17 +1,16 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) -# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Operating Unit in Purchase Requests", - "version": "10.0.1.0.0", + "version": "12.0.1.0.0", "author": "Eficent, " "SerpentCS, " "Odoo Community Association (OCA)", - "website": "http://www.eficent.com", + "website": "https://www.github.com/OCA/operating-unit", "license": "LGPL-3", "category": "Purchase Management", "depends": ["purchase_request", @@ -19,6 +18,7 @@ "data": [ "security/purchase_security.xml", "view/purchase_request_view.xml", + "wizard/purchase_request_line_make_purchase_order_view.xml" ], 'installable': True, } diff --git a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot new file mode 100644 index 0000000000..48817300b6 --- /dev/null +++ b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:46 +#, python-format +msgid "Configuration error. The Purchase Request and the Warehouse of picking type must belong to the same Operating Unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:56 +#, python-format +msgid "Configuration error. The approver has not the indicated Operating Unit" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:32 +#, python-format +msgid "Could not process !You have to select linesfrom the same operating unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__operating_unit_id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__operating_unit_id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__operating_unit_id +#: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.purchase_request_line_search +#: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.view_purchase_request_search +msgid "Operating Unit" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request +msgid "Purchase Request" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line +msgid "Purchase Request Line" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line_make_purchase_order +msgid "Purchase Request Line Make Purchase Order" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:31 +#, python-format +msgid "The Company in the Purchase Request and in the Operating Unit must bethe same." +msgstr "" + diff --git a/purchase_request_operating_unit/model/__init__.py b/purchase_request_operating_unit/model/__init__.py index b34e3625f7..639be8329b 100644 --- a/purchase_request_operating_unit/model/__init__.py +++ b/purchase_request_operating_unit/model/__init__.py @@ -1,8 +1,3 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. -# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import purchase_request diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py index f352bcc783..03ec4edac0 100644 --- a/purchase_request_operating_unit/model/purchase_request.py +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) -# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -15,6 +14,9 @@ class PurchaseRequest(models.Model): operating_unit_id = fields.Many2one( 'operating.unit', string='Operating Unit', + states={'to_approve': [('readonly', True)], + 'approved': [('readonly', True)], + 'done': [('readonly', True)]}, default=lambda self: self.env['res.users']. operating_unit_default_get(self._uid), @@ -41,10 +43,20 @@ def _check_warehouse_operating_unit(self): and rec.operating_unit_id and\ picking_type.warehouse_id.operating_unit_id !=\ rec.operating_unit_id: - raise ValidationError(_('Configuration error!\nThe\ + raise ValidationError(_('Configuration error. The\ Purchase Request and the Warehouse of picking type\ must belong to the same Operating Unit.')) + @api.constrains('operating_unit_id') + def _check_approver_operating_unit(self): + for rec in self: + if rec.assigned_to and rec.operating_unit_id and \ + rec.operating_unit_id not in \ + rec.assigned_to.operating_unit_ids: + raise ValidationError(_('Configuration error. The ' + 'approver has not the indicated ' + 'Operating Unit')) + class PurchaseRequestLine(models.Model): _inherit = 'purchase.request.line' @@ -52,6 +64,6 @@ class PurchaseRequestLine(models.Model): operating_unit_id = fields.Many2one( 'operating.unit', related='request_id.operating_unit_id', - string='Operating Unit', readonly=True, + string='Operating Unit', store=True, ) diff --git a/purchase_request_operating_unit/readme/CONTRIBUTORS.rst b/purchase_request_operating_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..03b3be1734 --- /dev/null +++ b/purchase_request_operating_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Jordi Ballester Alomar +* Serpent Consulting Services Pvt. Ltd. diff --git a/purchase_request_operating_unit/readme/DESCRIPTION.rst b/purchase_request_operating_unit/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..b24fb80c0a --- /dev/null +++ b/purchase_request_operating_unit/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +This module introduces the following features: + +* Adds the Operating Unit (OU) to the Purchase Request. + +* The user’s default Operating Unit (OU) is proposed at the time of creating the Purchase Request. + +* Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to. diff --git a/purchase_request_operating_unit/readme/USAGE.rst b/purchase_request_operating_unit/readme/USAGE.rst new file mode 100644 index 0000000000..96966e237f --- /dev/null +++ b/purchase_request_operating_unit/readme/USAGE.rst @@ -0,0 +1,9 @@ +Follow these steps: + +#. Create or use an existing Operating Unit (OU) in Settings -> + Users & Configuration -> Operating Unit. +#. Change the configuration of the Users. In Application Accesses, put an User + as Request manager and another one as Request User. +#. Create a Purchase Request Order. By default, if there is no Approver, any + Manager with the same OU can accept the PO. If you specify an Approver, he + must be in the same Operating Unit as the Purchase Request. \ No newline at end of file diff --git a/purchase_request_operating_unit/security/purchase_security.xml b/purchase_request_operating_unit/security/purchase_security.xml index 309642053e..70d1b5a965 100644 --- a/purchase_request_operating_unit/security/purchase_security.xml +++ b/purchase_request_operating_unit/security/purchase_security.xml @@ -1,8 +1,10 @@ - - + + + + + + diff --git a/purchase_request_operating_unit/static/description/icon.png b/purchase_request_operating_unit/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 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 z 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 Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/purchase_request_operating_unit/static/description/index.html b/purchase_request_operating_unit/static/description/index.html new file mode 100644 index 0000000000..5d2827fb1f --- /dev/null +++ b/purchase_request_operating_unit/static/description/index.html @@ -0,0 +1,440 @@ + + + + + + +Operating Unit in Purchase Requests + + + +
+

Operating Unit in Purchase Requests

+ + +

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

+

This module introduces the following features:

+
    +
  • Adds the Operating Unit (OU) to the Purchase Request.
  • +
  • The user’s default Operating Unit (OU) is proposed at the time of creating the Purchase Request.
  • +
  • Security rules are defined to ensure that users can only see the Purchase Request of that Operating Units in which they are allowed access to.
  • +
+

Table of contents

+ +
+

Usage

+

Follow these steps:

+
    +
  1. Create or use an existing Operating Unit (OU) in Settings -> +Users & Configuration -> Operating Unit.
  2. +
  3. Change the configuration of the Users. In Application Accesses, put an User +as Request manager and another one as Request User.
  4. +
  5. Create a Purchase Request Order. By default, if there is no Approver, any +Manager with the same OU can accept the PO. If you specify an Approver, he +must be in the same Operating Unit as the Purchase Request.
  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

+
    +
  • Eficent
  • +
  • SerpentCS
  • +
+
+
+

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_request_operating_unit/tests/__init__.py b/purchase_request_operating_unit/tests/__init__.py index 2db7e3eb2e..5c730c69af 100644 --- a/purchase_request_operating_unit/tests/__init__.py +++ b/purchase_request_operating_unit/tests/__init__.py @@ -1,8 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. -# () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import test_purchase_request_operating_unit +from . import test_purchase_request_to_rfq_operating_unit diff --git a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py index 5fad5e8f3b..2179a03092 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# Copyright 2016-17 Eficent Business and IT Consulting Services S.L. +# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) -# Copyright 2016-17 Serpent Consulting Services Pvt. Ltd. +# Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -24,7 +23,7 @@ def setUp(self): self.b2c = self.env.ref('operating_unit.b2c_operating_unit') # Product self.product1 = self.env.ref('product.product_product_7') - self.product_uom = self.env.ref('product.product_uom_unit') + self.product_uom = self.env.ref('uom.product_uom_unit') # User self.user_root = self.env.ref('base.user_root') # Groups diff --git a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py new file mode 100644 index 0000000000..5dd8a569ba --- /dev/null +++ b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py @@ -0,0 +1,54 @@ +# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. +# () +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo.tests import common +from odoo.tools import SUPERUSER_ID + + +class TestPurchaseRequestToRfq(common.TransactionCase): + + def setUp(self): + super(TestPurchaseRequestToRfq, self).setUp() + self.purchase_request = self.env['purchase.request'] + self.purchase_request_line = self.env['purchase.request.line'] + self.wiz =\ + self.env['purchase.request.line.make.purchase.order'] + self.purchase_order = self.env['purchase.order'] + # Main Operating Unit + self.ou1 = self.env.ref('operating_unit.main_operating_unit') + # Products + self.product1 = self.env.ref('product.product_product_9') + self._create_purchase_request() + + def _create_purchase_request(self): + vals = { + 'picking_type_id': self.env.ref('stock.picking_type_in').id, + 'requested_by': SUPERUSER_ID, + 'operating_unit_id': self.ou1.id + } + purchase_request = self.purchase_request.create(vals) + vals = { + 'request_id': purchase_request.id, + 'product_id': self.product1.id, + 'product_uom_id': self.env.ref('uom.product_uom_unit').id, + 'product_qty': 5.0, + } + self.purchase_request_line = self.purchase_request_line.create(vals) + purchase_request.button_to_approve() + purchase_request.button_approved() + + def test_purchase_request_to_purchase_requisition(self): + vals = {'supplier_id': self.env.ref('base.res_partner_12').id} + wiz_id = self.wiz.with_context( + active_model="purchase.request.line", + active_ids=[self.purchase_request_line.id], + active_id=self.purchase_request_line.id,).create(vals) + wiz_id.make_purchase_order() + purchase_id = self.purchase_request_line.purchase_lines.order_id + self.assertEqual( + purchase_id.operating_unit_id, + self.purchase_request_line.operating_unit_id, + 'Should have the same Operating Unit') diff --git a/purchase_request_operating_unit/view/purchase_request_view.xml b/purchase_request_operating_unit/view/purchase_request_view.xml index a4e1c0b8e3..a767d04088 100644 --- a/purchase_request_operating_unit/view/purchase_request_view.xml +++ b/purchase_request_operating_unit/view/purchase_request_view.xml @@ -1,8 +1,10 @@ - - + + + + + + purchase.request.tree @@ -10,7 +12,8 @@ - + @@ -21,11 +24,16 @@ - + + + + + {'operating_unit_id': operating_unit_id} + - - {'operating_unit_id': operating_unit_id} -
@@ -40,7 +48,8 @@ context="{'group_by':'operating_unit_id'}"/> - + @@ -51,7 +60,8 @@ - + @@ -62,7 +72,8 @@ - + @@ -73,7 +84,8 @@ - + ) +# 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 PurchaseRequestLineMakePurchaseOrder(models.TransientModel): + _inherit = "purchase.request.line.make.purchase.order" + + operating_unit_id = fields.Many2one( + 'operating.unit', + string='Operating Unit', + readonly=True, + ) + + @api.model + def default_get(self, fields): + res = super(PurchaseRequestLineMakePurchaseOrder, self).\ + default_get(fields) + request_line_obj = self.env['purchase.request.line'] + request_line_ids = self._context.get('active_ids', []) + operating_unit_id = False + for line in request_line_obj.browse(request_line_ids): + line_operating_unit_id = line.request_id.operating_unit_id \ + and line.request_id.operating_unit_id.id or False + if operating_unit_id\ + and line_operating_unit_id != operating_unit_id: + raise ValidationError(_('Could not process !' + 'You have to select lines' + 'from the same operating unit.')) + else: + operating_unit_id = line_operating_unit_id + res['operating_unit_id'] = operating_unit_id + return res + + @api.model + def _prepare_purchase_order(self, picking_type, location, + company_id, origin): + data = super(PurchaseRequestLineMakePurchaseOrder, self).\ + _prepare_purchase_order(picking_type, location, company_id, origin) + if self.operating_unit_id: + data['requesting_operating_unit_id'] = \ + self.operating_unit_id.id + data['operating_unit_id'] = \ + self.operating_unit_id.id + return data diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml new file mode 100644 index 0000000000..868cb36592 --- /dev/null +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml @@ -0,0 +1,25 @@ + + + + + + + + + Purchase Request Line Make Purchase Order + purchase.request.line.make.purchase.order + + form + + + + + + ['|', ('operating_unit_id', '=', False), ('operating_unit_id', '=', operating_unit_id)] + + + + + From ecd98b54dd805ab5ee538558649e6b4fb136a0b6 Mon Sep 17 00:00:00 2001 From: Pedro Castro Silva Date: Sat, 29 Feb 2020 12:10:19 +0000 Subject: [PATCH 04/16] Added translation using Weblate (Portuguese) --- purchase_request_operating_unit/i18n/pt.po | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 purchase_request_operating_unit/i18n/pt.po diff --git a/purchase_request_operating_unit/i18n/pt.po b/purchase_request_operating_unit/i18n/pt.po new file mode 100644 index 0000000000..90b7cd30c8 --- /dev/null +++ b/purchase_request_operating_unit/i18n/pt.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: pt\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" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:46 +#, python-format +msgid "Configuration error. The Purchase Request and the Warehouse of picking type must belong to the same Operating Unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:56 +#, python-format +msgid "Configuration error. The approver has not the indicated Operating Unit" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:32 +#, python-format +msgid "Could not process !You have to select linesfrom the same operating unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__operating_unit_id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__operating_unit_id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__operating_unit_id +#: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.purchase_request_line_search +#: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.view_purchase_request_search +msgid "Operating Unit" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request +msgid "Purchase Request" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line +msgid "Purchase Request Line" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line_make_purchase_order +msgid "Purchase Request Line Make Purchase Order" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:31 +#, python-format +msgid "The Company in the Purchase Request and in the Operating Unit must bethe same." +msgstr "" From ba8c7923a0268bb830d0ac85642fa566ffe24185 Mon Sep 17 00:00:00 2001 From: Pedro Castro Silva Date: Sat, 29 Feb 2020 12:36:37 +0000 Subject: [PATCH 05/16] Translated using Weblate (Portuguese) Currently translated at 12.5% (1 of 8 strings) Translation: operating-unit-12.0/operating-unit-12.0-purchase_request_operating_unit Translate-URL: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-purchase_request_operating_unit/pt/ --- purchase_request_operating_unit/i18n/pt.po | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/purchase_request_operating_unit/i18n/pt.po b/purchase_request_operating_unit/i18n/pt.po index 90b7cd30c8..73c7ff0b36 100644 --- a/purchase_request_operating_unit/i18n/pt.po +++ b/purchase_request_operating_unit/i18n/pt.po @@ -6,13 +6,15 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2020-02-29 15:13+0000\n" +"Last-Translator: Pedro Castro Silva \n" "Language-Team: none\n" "Language: pt\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 3.10\n" #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:46 @@ -39,7 +41,7 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.purchase_request_line_search #: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.view_purchase_request_search msgid "Operating Unit" -msgstr "" +msgstr "Unidade Operacional" #. module: purchase_request_operating_unit #: model:ir.model,name:purchase_request_operating_unit.model_purchase_request From 53948aac76e1c33a278b4c2ec2ddfc49d6831ccd Mon Sep 17 00:00:00 2001 From: Saran440 Date: Thu, 10 Dec 2020 16:21:09 +0700 Subject: [PATCH 06/16] [IMP] purchase_request_operating_unit: black, isort, prettier --- .../__manifest__.py | 11 +- .../model/purchase_request.py | 91 ++++++++------ .../readme/USAGE.rst | 2 +- .../security/purchase_security.xml | 29 ++--- .../test_purchase_request_operating_unit.py | 116 +++++++++--------- ..._purchase_request_to_rfq_operating_unit.py | 36 +++--- .../view/purchase_request_view.xml | 94 +++++++------- ...rchase_request_line_make_purchase_order.py | 49 ++++---- ..._request_line_make_purchase_order_view.xml | 27 ++-- 9 files changed, 245 insertions(+), 210 deletions(-) diff --git a/purchase_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index 5d628f1aa8..9d0cebd964 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -7,18 +7,15 @@ { "name": "Operating Unit in Purchase Requests", "version": "12.0.1.0.0", - "author": "Eficent, " - "SerpentCS, " - "Odoo Community Association (OCA)", + "author": "Eficent, " "SerpentCS, " "Odoo Community Association (OCA)", "website": "https://www.github.com/OCA/operating-unit", "license": "LGPL-3", "category": "Purchase Management", - "depends": ["purchase_request", - "purchase_operating_unit"], + "depends": ["purchase_request", "purchase_operating_unit"], "data": [ "security/purchase_security.xml", "view/purchase_request_view.xml", - "wizard/purchase_request_line_make_purchase_order_view.xml" + "wizard/purchase_request_line_make_purchase_order_view.xml", ], - 'installable': True, + "installable": True, } diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py index 03ec4edac0..d9daafa587 100644 --- a/purchase_request_operating_unit/model/purchase_request.py +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -4,66 +4,87 @@ # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo import fields, models, api, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class PurchaseRequest(models.Model): - _inherit = 'purchase.request' + _inherit = "purchase.request" operating_unit_id = fields.Many2one( - 'operating.unit', - string='Operating Unit', - states={'to_approve': [('readonly', True)], - 'approved': [('readonly', True)], - 'done': [('readonly', True)]}, - default=lambda self: - self.env['res.users']. - operating_unit_default_get(self._uid), + "operating.unit", + string="Operating Unit", + states={ + "to_approve": [("readonly", True)], + "approved": [("readonly", True)], + "done": [("readonly", True)], + }, + default=lambda self: self.env["res.users"].operating_unit_default_get( + self._uid + ), ) @api.multi - @api.constrains('operating_unit_id', 'company_id') + @api.constrains("operating_unit_id", "company_id") def _check_company_operating_unit(self): for rec in self: - if rec.company_id and rec.operating_unit_id and \ - rec.company_id != rec.operating_unit_id.company_id: - raise ValidationError(_('The Company in the Purchase Request ' - 'and in the Operating Unit must be' - 'the same.')) + if ( + rec.company_id + and rec.operating_unit_id + and rec.company_id != rec.operating_unit_id.company_id + ): + raise ValidationError( + _( + "The Company in the Purchase Request " + "and in the Operating Unit must be" + "the same." + ) + ) @api.multi - @api.constrains('operating_unit_id', 'picking_type_id') + @api.constrains("operating_unit_id", "picking_type_id") def _check_warehouse_operating_unit(self): for rec in self: picking_type = rec.picking_type_id if picking_type: - if picking_type.warehouse_id and\ - picking_type.warehouse_id.operating_unit_id\ - and rec.operating_unit_id and\ - picking_type.warehouse_id.operating_unit_id !=\ - rec.operating_unit_id: - raise ValidationError(_('Configuration error. The\ + if ( + picking_type.warehouse_id + and picking_type.warehouse_id.operating_unit_id + and rec.operating_unit_id + and picking_type.warehouse_id.operating_unit_id + != rec.operating_unit_id + ): + raise ValidationError( + _( + "Configuration error. The\ Purchase Request and the Warehouse of picking type\ - must belong to the same Operating Unit.')) + must belong to the same Operating Unit." + ) + ) - @api.constrains('operating_unit_id') + @api.constrains("operating_unit_id") def _check_approver_operating_unit(self): for rec in self: - if rec.assigned_to and rec.operating_unit_id and \ - rec.operating_unit_id not in \ - rec.assigned_to.operating_unit_ids: - raise ValidationError(_('Configuration error. The ' - 'approver has not the indicated ' - 'Operating Unit')) + if ( + rec.assigned_to + and rec.operating_unit_id + and rec.operating_unit_id not in rec.assigned_to.operating_unit_ids + ): + raise ValidationError( + _( + "Configuration error. The " + "approver has not the indicated " + "Operating Unit" + ) + ) class PurchaseRequestLine(models.Model): - _inherit = 'purchase.request.line' + _inherit = "purchase.request.line" operating_unit_id = fields.Many2one( - 'operating.unit', - related='request_id.operating_unit_id', - string='Operating Unit', + "operating.unit", + related="request_id.operating_unit_id", + string="Operating Unit", store=True, ) diff --git a/purchase_request_operating_unit/readme/USAGE.rst b/purchase_request_operating_unit/readme/USAGE.rst index 96966e237f..48e96938bc 100644 --- a/purchase_request_operating_unit/readme/USAGE.rst +++ b/purchase_request_operating_unit/readme/USAGE.rst @@ -6,4 +6,4 @@ Follow these steps: as Request manager and another one as Request User. #. Create a Purchase Request Order. By default, if there is no Approver, any Manager with the same OU can accept the PO. If you specify an Approver, he - must be in the same Operating Unit as the Purchase Request. \ No newline at end of file + must be in the same Operating Unit as the Purchase Request. diff --git a/purchase_request_operating_unit/security/purchase_security.xml b/purchase_request_operating_unit/security/purchase_security.xml index 70d1b5a965..bbc710f442 100644 --- a/purchase_request_operating_unit/security/purchase_security.xml +++ b/purchase_request_operating_unit/security/purchase_security.xml @@ -1,33 +1,30 @@ - + - - + ['|',('operating_unit_id','=',False), ('operating_unit_id','in',[g.id for g in user.operating_unit_ids])] Purchase Requests from allowed operating units - - - - - + + + + + - - + ['|',('request_id.operating_unit_id','=',False), ('request_id.operating_unit_id','in',[g.id for g in user.operating_unit_ids])] Purchase Requests lines from allowed operating units - - - - - + + + + + - diff --git a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py index 2179a03092..ed7af4091d 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -8,89 +8,93 @@ class TestPurchaseRequestOperatingUnit(common.TransactionCase): - def setUp(self): super(TestPurchaseRequestOperatingUnit, self).setUp() # Models - self.res_users_model = self.env['res.users'] - self.purchase_request = self.env['purchase.request'] - self.purchase_request_line = self.env['purchase.request.line'] + self.res_users_model = self.env["res.users"] + self.purchase_request = self.env["purchase.request"] + self.purchase_request_line = self.env["purchase.request.line"] # Company - self.company = self.env.ref('base.main_company') + self.company = self.env.ref("base.main_company") # Main Operating Unit - self.ou1 = self.env.ref('operating_unit.main_operating_unit') + self.ou1 = self.env.ref("operating_unit.main_operating_unit") # B2C Operating Unit - self.b2c = self.env.ref('operating_unit.b2c_operating_unit') + self.b2c = self.env.ref("operating_unit.b2c_operating_unit") # Product - self.product1 = self.env.ref('product.product_product_7') - self.product_uom = self.env.ref('uom.product_uom_unit') + self.product1 = self.env.ref("product.product_product_7") + self.product_uom = self.env.ref("uom.product_uom_unit") # User - self.user_root = self.env.ref('base.user_root') + self.user_root = self.env.ref("base.user_root") # Groups - self.grp_pr_mngr = self.env.\ - ref('purchase_request.group_purchase_request_manager') + self.grp_pr_mngr = self.env.ref( + "purchase_request.group_purchase_request_manager" + ) # Picking Type - b2c_wh = self.env.ref('stock_operating_unit.stock_warehouse_b2c') + b2c_wh = self.env.ref("stock_operating_unit.stock_warehouse_b2c") self.b2c_type_in_id = b2c_wh.in_type_id.id - self.picking_type = self.env.ref('stock.picking_type_in') + self.picking_type = self.env.ref("stock.picking_type_in") # Creates Users and Purchase request - self.user1 = self._create_user('user_1', [], - self.company, - [self.ou1]) - self.user2 = self._create_user('user_2', - self.grp_pr_mngr, - self.company, - [self.b2c]) + self.user1 = self._create_user("user_1", [], self.company, [self.ou1]) + self.user2 = self._create_user( + "user_2", self.grp_pr_mngr, self.company, [self.b2c] + ) self.request1 = self._create_purchase_request(self.ou1) self._purchase_line(self.request1) - self.request2 = self._create_purchase_request(self.b2c, - self.b2c_type_in_id) + self.request2 = self._create_purchase_request(self.b2c, self.b2c_type_in_id) self._purchase_line(self.request2) - def _create_user(self, login, groups, company, operating_units, - context=None): + def _create_user(self, login, groups, company, operating_units, context=None): """ Create a user. """ group_ids = [group.id for group in groups] - user = self.res_users_model.create({ - 'name': 'Test Purchase Request User', - 'login': login, - 'password': 'demo', - 'email': 'example@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)] - }) + user = self.res_users_model.create( + { + "name": "Test Purchase Request User", + "login": login, + "password": "demo", + "email": "example@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 def _purchase_line(self, request): - line = self.purchase_request_line.create({ - 'request_id': request.id, - 'product_id': self.product1.id, - 'product_uom_id': self.product_uom.id, - 'product_qty': 5.0, - }) + line = self.purchase_request_line.create( + { + "request_id": request.id, + "product_id": self.product1.id, + "product_uom_id": self.product_uom.id, + "product_qty": 5.0, + } + ) return line def _create_purchase_request(self, operating_unit, picking_type=False): if picking_type: - purchase_request = self.purchase_request.create({ - 'assigned_to': self.user_root.id, - 'picking_type_id': self.b2c_type_in_id, - 'operating_unit_id': operating_unit.id, - }) + purchase_request = self.purchase_request.create( + { + "assigned_to": self.user_root.id, + "picking_type_id": self.b2c_type_in_id, + "operating_unit_id": operating_unit.id, + } + ) else: - purchase_request = self.purchase_request.create({ - 'assigned_to': self.user_root.id, - 'picking_type_id': self.picking_type.id, - 'operating_unit_id': operating_unit.id, - }) + purchase_request = self.purchase_request.create( + { + "assigned_to": self.user_root.id, + "picking_type_id": self.picking_type.id, + "operating_unit_id": operating_unit.id, + } + ) return purchase_request def test_purchase_request(self): - record = self.purchase_request.sudo(self.user2.id).\ - search([('id', '=', self.request1.id), - ('operating_unit_id', '=', self.ou1.id)]) - self.assertEqual(record.ids, [], 'User 2 should not have access to ' - 'OU %s' % self.ou1.name) + record = self.purchase_request.sudo(self.user2.id).search( + [("id", "=", self.request1.id), ("operating_unit_id", "=", self.ou1.id)] + ) + self.assertEqual( + record.ids, [], "User 2 should not have access to " "OU %s" % self.ou1.name + ) diff --git a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py index 5dd8a569ba..0a0b405d16 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py @@ -9,46 +9,46 @@ class TestPurchaseRequestToRfq(common.TransactionCase): - def setUp(self): super(TestPurchaseRequestToRfq, self).setUp() - self.purchase_request = self.env['purchase.request'] - self.purchase_request_line = self.env['purchase.request.line'] - self.wiz =\ - self.env['purchase.request.line.make.purchase.order'] - self.purchase_order = self.env['purchase.order'] + self.purchase_request = self.env["purchase.request"] + self.purchase_request_line = self.env["purchase.request.line"] + self.wiz = self.env["purchase.request.line.make.purchase.order"] + self.purchase_order = self.env["purchase.order"] # Main Operating Unit - self.ou1 = self.env.ref('operating_unit.main_operating_unit') + self.ou1 = self.env.ref("operating_unit.main_operating_unit") # Products - self.product1 = self.env.ref('product.product_product_9') + self.product1 = self.env.ref("product.product_product_9") self._create_purchase_request() def _create_purchase_request(self): vals = { - 'picking_type_id': self.env.ref('stock.picking_type_in').id, - 'requested_by': SUPERUSER_ID, - 'operating_unit_id': self.ou1.id + "picking_type_id": self.env.ref("stock.picking_type_in").id, + "requested_by": SUPERUSER_ID, + "operating_unit_id": self.ou1.id, } purchase_request = self.purchase_request.create(vals) vals = { - 'request_id': purchase_request.id, - 'product_id': self.product1.id, - 'product_uom_id': self.env.ref('uom.product_uom_unit').id, - 'product_qty': 5.0, + "request_id": purchase_request.id, + "product_id": self.product1.id, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + "product_qty": 5.0, } self.purchase_request_line = self.purchase_request_line.create(vals) purchase_request.button_to_approve() purchase_request.button_approved() def test_purchase_request_to_purchase_requisition(self): - vals = {'supplier_id': self.env.ref('base.res_partner_12').id} + vals = {"supplier_id": self.env.ref("base.res_partner_12").id} wiz_id = self.wiz.with_context( active_model="purchase.request.line", active_ids=[self.purchase_request_line.id], - active_id=self.purchase_request_line.id,).create(vals) + active_id=self.purchase_request_line.id, + ).create(vals) wiz_id.make_purchase_order() purchase_id = self.purchase_request_line.purchase_lines.order_id self.assertEqual( purchase_id.operating_unit_id, self.purchase_request_line.operating_unit_id, - 'Should have the same Operating Unit') + "Should have the same Operating Unit", + ) diff --git a/purchase_request_operating_unit/view/purchase_request_view.xml b/purchase_request_operating_unit/view/purchase_request_view.xml index a767d04088..d3c76ab8c8 100644 --- a/purchase_request_operating_unit/view/purchase_request_view.xml +++ b/purchase_request_operating_unit/view/purchase_request_view.xml @@ -1,33 +1,35 @@ - + - purchase.request.tree purchase.request - + - + - purchase.request.form purchase.request - + - + @@ -36,65 +38,73 @@ - - purchase.request.list.select - purchase.request - - - - purchase.request.list.select + purchase.request + + + + + + + - - - - + /> + - purchase.request.line.tree purchase.request.line - + - + - purchase.request.line.form purchase.request.line - + - + - purchase.request.line.search purchase.request.line - + - + - + -
diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py index af51d9e4d0..6969ac62b4 100644 --- a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py @@ -4,7 +4,7 @@ # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError @@ -12,39 +12,40 @@ class PurchaseRequestLineMakePurchaseOrder(models.TransientModel): _inherit = "purchase.request.line.make.purchase.order" operating_unit_id = fields.Many2one( - 'operating.unit', - string='Operating Unit', - readonly=True, + "operating.unit", string="Operating Unit", readonly=True, ) @api.model def default_get(self, fields): - res = super(PurchaseRequestLineMakePurchaseOrder, self).\ - default_get(fields) - request_line_obj = self.env['purchase.request.line'] - request_line_ids = self._context.get('active_ids', []) + res = super(PurchaseRequestLineMakePurchaseOrder, self).default_get(fields) + request_line_obj = self.env["purchase.request.line"] + request_line_ids = self._context.get("active_ids", []) operating_unit_id = False for line in request_line_obj.browse(request_line_ids): - line_operating_unit_id = line.request_id.operating_unit_id \ - and line.request_id.operating_unit_id.id or False - if operating_unit_id\ - and line_operating_unit_id != operating_unit_id: - raise ValidationError(_('Could not process !' - 'You have to select lines' - 'from the same operating unit.')) + line_operating_unit_id = ( + line.request_id.operating_unit_id + and line.request_id.operating_unit_id.id + or False + ) + if operating_unit_id and line_operating_unit_id != operating_unit_id: + raise ValidationError( + _( + "Could not process !" + "You have to select lines" + "from the same operating unit." + ) + ) else: operating_unit_id = line_operating_unit_id - res['operating_unit_id'] = operating_unit_id + res["operating_unit_id"] = operating_unit_id return res @api.model - def _prepare_purchase_order(self, picking_type, location, - company_id, origin): - data = super(PurchaseRequestLineMakePurchaseOrder, self).\ - _prepare_purchase_order(picking_type, location, company_id, origin) + def _prepare_purchase_order(self, picking_type, location, company_id, origin): + data = super( + PurchaseRequestLineMakePurchaseOrder, self + )._prepare_purchase_order(picking_type, location, company_id, origin) if self.operating_unit_id: - data['requesting_operating_unit_id'] = \ - self.operating_unit_id.id - data['operating_unit_id'] = \ - self.operating_unit_id.id + data["requesting_operating_unit_id"] = self.operating_unit_id.id + data["operating_unit_id"] = self.operating_unit_id.id return data diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml index 868cb36592..bc584b8a6e 100644 --- a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml @@ -1,4 +1,4 @@ - + @@ -8,18 +8,23 @@ Purchase Request Line Make Purchase Order purchase.request.line.make.purchase.order - + form - - - - - ['|', ('operating_unit_id', '=', False), ('operating_unit_id', '=', operating_unit_id)] - + + + + + ['|', ('operating_unit_id', '=', False), ('operating_unit_id', '=', operating_unit_id)] + -
From 0b8314e158d1256e48c2ac708eb41abf2ccd5c91 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Thu, 10 Dec 2020 16:31:24 +0700 Subject: [PATCH 07/16] [13.0][MIG] purchase_request_operating_unit --- purchase_request_operating_unit/__manifest__.py | 4 ++-- .../model/purchase_request.py | 13 +++++-------- .../readme/CONTRIBUTORS.rst | 1 + .../tests/test_purchase_request_operating_unit.py | 6 +++--- .../test_purchase_request_to_rfq_operating_unit.py | 2 +- .../purchase_request_line_make_purchase_order.py | 8 ++++---- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/purchase_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index 9d0cebd964..d3c8ca26b5 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -6,8 +6,8 @@ { "name": "Operating Unit in Purchase Requests", - "version": "12.0.1.0.0", - "author": "Eficent, " "SerpentCS, " "Odoo Community Association (OCA)", + "version": "13.0.1.0.0", + "author": "Eficent, SerpentCS, Odoo Community Association (OCA)", "website": "https://www.github.com/OCA/operating-unit", "license": "LGPL-3", "category": "Purchase Management", diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py index d9daafa587..980b35e1bf 100644 --- a/purchase_request_operating_unit/model/purchase_request.py +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -24,7 +24,6 @@ class PurchaseRequest(models.Model): ), ) - @api.multi @api.constrains("operating_unit_id", "company_id") def _check_company_operating_unit(self): for rec in self: @@ -41,7 +40,6 @@ def _check_company_operating_unit(self): ) ) - @api.multi @api.constrains("operating_unit_id", "picking_type_id") def _check_warehouse_operating_unit(self): for rec in self: @@ -56,9 +54,9 @@ def _check_warehouse_operating_unit(self): ): raise ValidationError( _( - "Configuration error. The\ - Purchase Request and the Warehouse of picking type\ - must belong to the same Operating Unit." + "Configuration error. The Purchase Request and the" + "Warehouse of picking type must belong to the same " + "Operating Unit." ) ) @@ -72,9 +70,8 @@ def _check_approver_operating_unit(self): ): raise ValidationError( _( - "Configuration error. The " - "approver has not the indicated " - "Operating Unit" + "Configuration error. The approver has not " + "the indicated Operating Unit" ) ) diff --git a/purchase_request_operating_unit/readme/CONTRIBUTORS.rst b/purchase_request_operating_unit/readme/CONTRIBUTORS.rst index 03b3be1734..6251500b42 100644 --- a/purchase_request_operating_unit/readme/CONTRIBUTORS.rst +++ b/purchase_request_operating_unit/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Jordi Ballester Alomar * Serpent Consulting Services Pvt. Ltd. +* Saran Lim. diff --git a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py index ed7af4091d..485b79dfa6 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -9,7 +9,7 @@ class TestPurchaseRequestOperatingUnit(common.TransactionCase): def setUp(self): - super(TestPurchaseRequestOperatingUnit, self).setUp() + super().setUp() # Models self.res_users_model = self.env["res.users"] self.purchase_request = self.env["purchase.request"] @@ -92,9 +92,9 @@ def _create_purchase_request(self, operating_unit, picking_type=False): return purchase_request def test_purchase_request(self): - record = self.purchase_request.sudo(self.user2.id).search( + record = self.purchase_request.with_user(self.user2.id).search( [("id", "=", self.request1.id), ("operating_unit_id", "=", self.ou1.id)] ) self.assertEqual( - record.ids, [], "User 2 should not have access to " "OU %s" % self.ou1.name + record.ids, [], "User 2 should not have access to OU %s" % self.ou1.name ) diff --git a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py index 0a0b405d16..b2b21b35f0 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py @@ -10,7 +10,7 @@ class TestPurchaseRequestToRfq(common.TransactionCase): def setUp(self): - super(TestPurchaseRequestToRfq, self).setUp() + super().setUp() self.purchase_request = self.env["purchase.request"] self.purchase_request_line = self.env["purchase.request.line"] self.wiz = self.env["purchase.request.line.make.purchase.order"] diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py index 6969ac62b4..2b1160cea8 100644 --- a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py @@ -17,7 +17,7 @@ class PurchaseRequestLineMakePurchaseOrder(models.TransientModel): @api.model def default_get(self, fields): - res = super(PurchaseRequestLineMakePurchaseOrder, self).default_get(fields) + res = super().default_get(fields) request_line_obj = self.env["purchase.request.line"] request_line_ids = self._context.get("active_ids", []) operating_unit_id = False @@ -42,9 +42,9 @@ def default_get(self, fields): @api.model def _prepare_purchase_order(self, picking_type, location, company_id, origin): - data = super( - PurchaseRequestLineMakePurchaseOrder, self - )._prepare_purchase_order(picking_type, location, company_id, origin) + data = super()._prepare_purchase_order( + picking_type, location, company_id, origin + ) if self.operating_unit_id: data["requesting_operating_unit_id"] = self.operating_unit_id.id data["operating_unit_id"] = self.operating_unit_id.id From 3901958aa8ecf12ee95f741b60c00bef9a006b72 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Thu, 10 Dec 2020 16:46:37 +0700 Subject: [PATCH 08/16] [14.0][MIG] purchase_request_operating_unit --- purchase_request_operating_unit/README.rst | 11 +++-- .../__manifest__.py | 4 +- .../i18n/purchase_request_operating_unit.pot | 47 ++++++++++++++----- .../static/description/index.html | 7 +-- .../test_purchase_request_operating_unit.py | 2 +- ..._purchase_request_to_rfq_operating_unit.py | 2 +- ...rchase_request_line_make_purchase_order.py | 17 +++++-- 7 files changed, 63 insertions(+), 27 deletions(-) diff --git a/purchase_request_operating_unit/README.rst b/purchase_request_operating_unit/README.rst index a5bacb2704..4af8f6e27f 100644 --- a/purchase_request_operating_unit/README.rst +++ b/purchase_request_operating_unit/README.rst @@ -14,13 +14,13 @@ Operating Unit in Purchase Requests :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_request_operating_unit + :target: https://github.com/OCA/operating-unit/tree/14.0/purchase_request_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_request_operating_unit + :target: https://translation.odoo-community.org/projects/operating-unit-14-0/operating-unit-14-0-purchase_request_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/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -57,7 +57,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. @@ -75,6 +75,7 @@ Contributors * Jordi Ballester Alomar * Serpent Consulting Services Pvt. Ltd. +* Saran Lim. Maintainers ~~~~~~~~~~~ @@ -89,6 +90,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_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index d3c8ca26b5..86758a80d4 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -6,9 +6,9 @@ { "name": "Operating Unit in Purchase Requests", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "author": "Eficent, SerpentCS, Odoo Community Association (OCA)", - "website": "https://www.github.com/OCA/operating-unit", + "website": "https://github.com/OCA/operating-unit", "license": "LGPL-3", "category": "Purchase Management", "depends": ["purchase_request", "purchase_operating_unit"], diff --git a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot index 48817300b6..46a68c2c2f 100644 --- a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot +++ b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * purchase_request_operating_unit +# * purchase_request_operating_unit # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.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,21 +14,45 @@ msgstr "" "Plural-Forms: \n" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/model/purchase_request.py:46 +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format -msgid "Configuration error. The Purchase Request and the Warehouse of picking type must belong to the same Operating Unit." +msgid "" +"Configuration error. The Purchase Request and theWarehouse of picking type " +"must belong to the same Operating Unit." msgstr "" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/model/purchase_request.py:56 +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format msgid "Configuration error. The approver has not the indicated Operating Unit" msgstr "" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:32 +#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:0 #, python-format -msgid "Could not process !You have to select linesfrom the same operating unit." +msgid "" +"Could not process !You have to select linesfrom the same operating unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__display_name +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__display_name +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__display_name +msgid "Display Name" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__id +msgid "ID" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request____last_update +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line____last_update +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order____last_update +msgid "Last Modified on" msgstr "" #. module: purchase_request_operating_unit @@ -56,8 +80,9 @@ msgid "Purchase Request Line Make Purchase Order" msgstr "" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/model/purchase_request.py:31 +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format -msgid "The Company in the Purchase Request and in the Operating Unit must bethe same." +msgid "" +"The Company in the Purchase Request and in the Operating Unit must bethe " +"same." msgstr "" - diff --git a/purchase_request_operating_unit/static/description/index.html b/purchase_request_operating_unit/static/description/index.html index 5d2827fb1f..1284ade76e 100644 --- a/purchase_request_operating_unit/static/description/index.html +++ b/purchase_request_operating_unit/static/description/index.html @@ -367,7 +367,7 @@

Operating Unit in Purchase Requests

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module introduces the following features:

  • Adds the Operating Unit (OU) to the Purchase Request.
  • @@ -405,7 +405,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.

    @@ -422,6 +422,7 @@

    Contributors

    @@ -431,7 +432,7 @@

    Maintainers

    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_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py index 485b79dfa6..d5ae7adc63 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -45,7 +45,7 @@ def setUp(self): self._purchase_line(self.request2) def _create_user(self, login, groups, company, operating_units, context=None): - """ Create a user. """ + """Create a user.""" group_ids = [group.id for group in groups] user = self.res_users_model.create( { diff --git a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py index b2b21b35f0..bc4858c8cc 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py @@ -4,8 +4,8 @@ # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from odoo import SUPERUSER_ID from odoo.tests import common -from odoo.tools import SUPERUSER_ID class TestPurchaseRequestToRfq(common.TransactionCase): diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py index 2b1160cea8..f200f4432a 100644 --- a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py @@ -12,16 +12,25 @@ class PurchaseRequestLineMakePurchaseOrder(models.TransientModel): _inherit = "purchase.request.line.make.purchase.order" operating_unit_id = fields.Many2one( - "operating.unit", string="Operating Unit", readonly=True, + "operating.unit", + string="Operating Unit", + readonly=True, ) @api.model def default_get(self, fields): res = super().default_get(fields) - request_line_obj = self.env["purchase.request.line"] - request_line_ids = self._context.get("active_ids", []) operating_unit_id = False - for line in request_line_obj.browse(request_line_ids): + active_model = self.env.context.get("active_model", False) + active_ids = self.env.context.get("active_ids", False) + _model = { + "purchase.request.line": "", + "purchase.request": "line_ids", + } + request_lines = ( + self.env[active_model].browse(active_ids).mapped(_model[active_model]) + ) + for line in request_lines: line_operating_unit_id = ( line.request_id.operating_unit_id and line.request_id.operating_unit_id.id From f7c271fe0732ef59dc7225fd73a6c21e23d3a051 Mon Sep 17 00:00:00 2001 From: Khalid Hazam Date: Tue, 28 Jun 2022 08:52:34 +0000 Subject: [PATCH 09/16] Added translation using Weblate (French) --- purchase_request_operating_unit/i18n/fr.po | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 purchase_request_operating_unit/i18n/fr.po diff --git a/purchase_request_operating_unit/i18n/fr.po b/purchase_request_operating_unit/i18n/fr.po new file mode 100644 index 0000000000..58c1517ec8 --- /dev/null +++ b/purchase_request_operating_unit/i18n/fr.po @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_request_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: fr\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" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 +#, python-format +msgid "" +"Configuration error. The Purchase Request and theWarehouse of picking type " +"must belong to the same Operating Unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 +#, python-format +msgid "Configuration error. The approver has not the indicated Operating Unit" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:0 +#, python-format +msgid "" +"Could not process !You have to select linesfrom the same operating unit." +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__display_name +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__display_name +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__display_name +msgid "Display Name" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__id +msgid "ID" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request____last_update +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line____last_update +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__operating_unit_id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__operating_unit_id +#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__operating_unit_id +#: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.purchase_request_line_search +#: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.view_purchase_request_search +msgid "Operating Unit" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request +msgid "Purchase Request" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line +msgid "Purchase Request Line" +msgstr "" + +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line_make_purchase_order +msgid "Purchase Request Line Make Purchase Order" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 +#, python-format +msgid "" +"The Company in the Purchase Request and in the Operating Unit must bethe " +"same." +msgstr "" From badbe718e6c0f06d921319f644da33fa06e6fe80 Mon Sep 17 00:00:00 2001 From: Khalid Hazam Date: Tue, 28 Jun 2022 09:03:04 +0000 Subject: [PATCH 10/16] Translated using Weblate (French) Currently translated at 72.7% (8 of 11 strings) Translation: operating-unit-14.0/operating-unit-14.0-purchase_request_operating_unit Translate-URL: https://translation.odoo-community.org/projects/operating-unit-14-0/operating-unit-14-0-purchase_request_operating_unit/fr/ --- purchase_request_operating_unit/i18n/fr.po | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/purchase_request_operating_unit/i18n/fr.po b/purchase_request_operating_unit/i18n/fr.po index 58c1517ec8..43d7af01ea 100644 --- a/purchase_request_operating_unit/i18n/fr.po +++ b/purchase_request_operating_unit/i18n/fr.po @@ -6,13 +6,15 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2022-06-28 11:05+0000\n" +"Last-Translator: Khalid Hazam \n" "Language-Team: none\n" "Language: fr\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 4.3.2\n" #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 @@ -21,40 +23,46 @@ msgid "" "Configuration error. The Purchase Request and theWarehouse of picking type " "must belong to the same Operating Unit." msgstr "" +"Erreur de configuration. La demande d'achat et l'entrepôt de prélèvement " +"doivent appartenir à la même unité opérationnelle." #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 -#, python-format +#, fuzzy, python-format msgid "Configuration error. The approver has not the indicated Operating Unit" msgstr "" +"Erreur de configuration. L’approbateur n'a pas l'unité opérationnelle " +"indiquée" #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:0 -#, python-format +#, fuzzy, python-format msgid "" "Could not process !You have to select linesfrom the same operating unit." msgstr "" +"Impossible de traiter ! Vous devez sélectionner les lignes de la même unité " +"opérationnelle." #. module: purchase_request_operating_unit #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__display_name #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__display_name #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__display_name msgid "Display Name" -msgstr "" +msgstr "Nom affiché" #. module: purchase_request_operating_unit #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__id #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__id #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__id msgid "ID" -msgstr "" +msgstr "ID" #. module: purchase_request_operating_unit #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request____last_update #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line____last_update #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order____last_update msgid "Last Modified on" -msgstr "" +msgstr "Dernière modification le" #. module: purchase_request_operating_unit #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__operating_unit_id @@ -63,22 +71,23 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.purchase_request_line_search #: model_terms:ir.ui.view,arch_db:purchase_request_operating_unit.view_purchase_request_search msgid "Operating Unit" -msgstr "" +msgstr "Unité opérationnelle" #. module: purchase_request_operating_unit #: model:ir.model,name:purchase_request_operating_unit.model_purchase_request msgid "Purchase Request" -msgstr "" +msgstr "Demande d'achat" #. module: purchase_request_operating_unit #: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line msgid "Purchase Request Line" -msgstr "" +msgstr "Ligne de la demande d'achat" #. module: purchase_request_operating_unit #: model:ir.model,name:purchase_request_operating_unit.model_purchase_request_line_make_purchase_order +#, fuzzy msgid "Purchase Request Line Make Purchase Order" -msgstr "" +msgstr "Ligne de demande d'achat fait Bon de commande" #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 @@ -87,3 +96,5 @@ msgid "" "The Company in the Purchase Request and in the Operating Unit must bethe " "same." msgstr "" +"La société sur la demande d'achat et sur l'unité opérationnelle doit être la " +"même." From ada0530d95c6aa2bcadd53edced07431bd1deb48 Mon Sep 17 00:00:00 2001 From: BT-pcavero Date: Tue, 2 Aug 2022 09:46:23 +0200 Subject: [PATCH 11/16] [IMP] purchase_request_operating_unit: black, isort, prettier --- purchase_request_operating_unit/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/purchase_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index 86758a80d4..660871832a 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Operating Unit in Purchase Requests", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "author": "Eficent, SerpentCS, Odoo Community Association (OCA)", "website": "https://github.com/OCA/operating-unit", "license": "LGPL-3", From b8604697d195f750ab9548742a565c492282bf23 Mon Sep 17 00:00:00 2001 From: BT-pcavero Date: Tue, 2 Aug 2022 09:47:20 +0200 Subject: [PATCH 12/16] [15.0][MIG] purchase_request_operating_unit: Migration to 15.0 --- purchase_request_operating_unit/README.rst | 10 ++-- purchase_request_operating_unit/__init__.py | 1 - .../__manifest__.py | 5 +- .../i18n/purchase_request_operating_unit.pot | 23 +------- .../model/purchase_request.py | 3 +- .../security/purchase_security.xml | 4 +- .../static/description/index.html | 6 +-- .../test-requirements.txt | 1 + .../test_purchase_request_operating_unit.py | 54 +++++++++++-------- ..._purchase_request_to_rfq_operating_unit.py | 3 +- .../view/purchase_request_view.xml | 8 ++- ...rchase_request_line_make_purchase_order.py | 9 ++-- ..._request_line_make_purchase_order_view.xml | 4 +- 13 files changed, 57 insertions(+), 74 deletions(-) create mode 100644 purchase_request_operating_unit/test-requirements.txt diff --git a/purchase_request_operating_unit/README.rst b/purchase_request_operating_unit/README.rst index 4af8f6e27f..ae8c17486e 100644 --- a/purchase_request_operating_unit/README.rst +++ b/purchase_request_operating_unit/README.rst @@ -14,13 +14,13 @@ Operating Unit in Purchase Requests :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/14.0/purchase_request_operating_unit + :target: https://github.com/OCA/operating-unit/tree/15.0/purchase_request_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-14-0/operating-unit-14-0-purchase_request_operating_unit + :target: https://translation.odoo-community.org/projects/operating-unit-15-0/operating-unit-15-0-purchase_request_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/14.0 + :target: https://runbot.odoo-community.org/runbot/213/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -57,7 +57,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. @@ -90,6 +90,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_request_operating_unit/__init__.py b/purchase_request_operating_unit/__init__.py index 14550192e2..6081d63bec 100644 --- a/purchase_request_operating_unit/__init__.py +++ b/purchase_request_operating_unit/__init__.py @@ -1,5 +1,4 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import model -from . import tests from . import wizard diff --git a/purchase_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index 660871832a..db80b0bc5c 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -1,5 +1,4 @@ -# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) +# Copyright 2016-19 ForgeFlow S.L. # Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -11,7 +10,7 @@ "website": "https://github.com/OCA/operating-unit", "license": "LGPL-3", "category": "Purchase Management", - "depends": ["purchase_request", "purchase_operating_unit"], + "depends": ["purchase_request", "purchase_operating_unit", "stock_operating_unit"], "data": [ "security/purchase_security.xml", "view/purchase_request_view.xml", diff --git a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot index 46a68c2c2f..33fb5c2802 100644 --- a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot +++ b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -34,27 +34,6 @@ msgid "" "Could not process !You have to select linesfrom the same operating unit." msgstr "" -#. module: purchase_request_operating_unit -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__display_name -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__display_name -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__display_name -msgid "Display Name" -msgstr "" - -#. module: purchase_request_operating_unit -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__id -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__id -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__id -msgid "ID" -msgstr "" - -#. module: purchase_request_operating_unit -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request____last_update -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line____last_update -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order____last_update -msgid "Last Modified on" -msgstr "" - #. module: purchase_request_operating_unit #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__operating_unit_id #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__operating_unit_id diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py index 980b35e1bf..80529a8804 100644 --- a/purchase_request_operating_unit/model/purchase_request.py +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -1,5 +1,4 @@ -# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) +# Copyright 2016-19 ForgeFlow S.L. # Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). diff --git a/purchase_request_operating_unit/security/purchase_security.xml b/purchase_request_operating_unit/security/purchase_security.xml index bbc710f442..6d58eaff66 100644 --- a/purchase_request_operating_unit/security/purchase_security.xml +++ b/purchase_request_operating_unit/security/purchase_security.xml @@ -1,6 +1,6 @@ - - + + diff --git a/purchase_request_operating_unit/static/description/index.html b/purchase_request_operating_unit/static/description/index.html index 1284ade76e..79163a520a 100644 --- a/purchase_request_operating_unit/static/description/index.html +++ b/purchase_request_operating_unit/static/description/index.html @@ -367,7 +367,7 @@

    Operating Unit in Purchase Requests

    !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

    +

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

    This module introduces the following features:

    • Adds the Operating Unit (OU) to the Purchase Request.
    • @@ -405,7 +405,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.

      @@ -432,7 +432,7 @@

      Maintainers

      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_request_operating_unit/test-requirements.txt b/purchase_request_operating_unit/test-requirements.txt new file mode 100644 index 0000000000..60c9138394 --- /dev/null +++ b/purchase_request_operating_unit/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-purchase_operating_unit @ git+https://github.com/OCA/operating-unit@refs/pull/443/head#subdirectory=setup/purchase_operating_unit diff --git a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py index d5ae7adc63..5eb8d89439 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_operating_unit.py @@ -1,13 +1,13 @@ -# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) +# Copyright 2016-19 ForgeFlow S.L. # Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo.tests import common +from odoo.exceptions import ValidationError +from odoo.tests.common import Form, TransactionCase -class TestPurchaseRequestOperatingUnit(common.TransactionCase): +class TestPurchaseRequestOperatingUnit(TransactionCase): def setUp(self): super().setUp() # Models @@ -16,6 +16,7 @@ def setUp(self): self.purchase_request_line = self.env["purchase.request.line"] # Company self.company = self.env.ref("base.main_company") + self.company2 = self.env["res.company"].create({"name": "Test Company"}) # Main Operating Unit self.ou1 = self.env.ref("operating_unit.main_operating_unit") # B2C Operating Unit @@ -31,7 +32,7 @@ def setUp(self): ) # Picking Type b2c_wh = self.env.ref("stock_operating_unit.stock_warehouse_b2c") - self.b2c_type_in_id = b2c_wh.in_type_id.id + self.b2c_type_in = b2c_wh.in_type_id self.picking_type = self.env.ref("stock.picking_type_in") # Creates Users and Purchase request @@ -41,7 +42,7 @@ def setUp(self): ) self.request1 = self._create_purchase_request(self.ou1) self._purchase_line(self.request1) - self.request2 = self._create_purchase_request(self.b2c, self.b2c_type_in_id) + self.request2 = self._create_purchase_request(self.b2c, self.b2c_type_in.id) self._purchase_line(self.request2) def _create_user(self, login, groups, company, operating_units, context=None): @@ -72,23 +73,14 @@ def _purchase_line(self, request): ) return line - def _create_purchase_request(self, operating_unit, picking_type=False): - if picking_type: - purchase_request = self.purchase_request.create( - { - "assigned_to": self.user_root.id, - "picking_type_id": self.b2c_type_in_id, - "operating_unit_id": operating_unit.id, - } - ) - else: - purchase_request = self.purchase_request.create( - { - "assigned_to": self.user_root.id, - "picking_type_id": self.picking_type.id, - "operating_unit_id": operating_unit.id, - } - ) + def _create_purchase_request(self, operating_unit, picking_type_id=False): + purchase_request = self.purchase_request.create( + { + "assigned_to": self.user_root.id, + "picking_type_id": picking_type_id or self.picking_type.id, + "operating_unit_id": operating_unit.id, + } + ) return purchase_request def test_purchase_request(self): @@ -98,3 +90,19 @@ def test_purchase_request(self): self.assertEqual( record.ids, [], "User 2 should not have access to OU %s" % self.ou1.name ) + + # Check company in OU and operating unit must be equal + with self.assertRaises(ValidationError): + with Form(self.request1) as pr: + pr.company_id = self.company2 + + # Check OU in picking type and operating unit must be equal + with self.assertRaises(ValidationError): + with Form(self.request1) as pr: + pr.picking_type_id = self.b2c_type_in + + # Check OU in assigned_to and operating unit must be equal + with self.assertRaises(ValidationError): + with Form(self.request1) as pr: + pr.assigned_to = self.user2 + pr.operating_unit_id = self.ou1 diff --git a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py index bc4858c8cc..d55d605923 100644 --- a/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py +++ b/purchase_request_operating_unit/tests/test_purchase_request_to_rfq_operating_unit.py @@ -1,5 +1,4 @@ -# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) +# Copyright 2016-19 ForgeFlow S.L. # Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). diff --git a/purchase_request_operating_unit/view/purchase_request_view.xml b/purchase_request_operating_unit/view/purchase_request_view.xml index d3c76ab8c8..a3d5ba9d11 100644 --- a/purchase_request_operating_unit/view/purchase_request_view.xml +++ b/purchase_request_operating_unit/view/purchase_request_view.xml @@ -1,6 +1,6 @@ - - + + @@ -27,8 +27,7 @@ @@ -100,7 +99,6 @@ diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py index f200f4432a..f7d01b31f9 100644 --- a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py @@ -1,5 +1,4 @@ -# Copyright 2016-19 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) +# Copyright 2016-19 ForgeFlow S.L. # Copyright 2016-19 Serpent Consulting Services Pvt. Ltd. # () # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -50,9 +49,11 @@ def default_get(self, fields): return res @api.model - def _prepare_purchase_order(self, picking_type, location, company_id, origin): + def _prepare_purchase_order( + self, picking_type, group_id, company, currency, origin + ): data = super()._prepare_purchase_order( - picking_type, location, company_id, origin + picking_type, group_id, company, currency, origin ) if self.operating_unit_id: data["requesting_operating_unit_id"] = self.operating_unit_id.id diff --git a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml index bc584b8a6e..44daca72a8 100644 --- a/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml +++ b/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order_view.xml @@ -1,6 +1,6 @@ - - + + From 442810abb029aa5b2e66a8bc6fda3a8f586f8990 Mon Sep 17 00:00:00 2001 From: AaronHForgeFlow Date: Wed, 14 Jun 2023 10:57:00 +0200 Subject: [PATCH 13/16] [FIX] purchase_request_operating_unit: operating unit when purchase request is created based on procurements --- purchase_request_operating_unit/README.rst | 15 +++--- .../__manifest__.py | 2 +- purchase_request_operating_unit/i18n/fr.po | 47 +++++++++---------- purchase_request_operating_unit/i18n/pt.po | 26 ++++++---- .../i18n/purchase_request_operating_unit.pot | 7 ++- .../model/__init__.py | 1 + .../model/purchase_request.py | 2 +- .../model/stock_rule.py | 15 ++++++ .../static/description/index.html | 38 ++++++++------- 9 files changed, 94 insertions(+), 59 deletions(-) create mode 100644 purchase_request_operating_unit/model/stock_rule.py diff --git a/purchase_request_operating_unit/README.rst b/purchase_request_operating_unit/README.rst index ae8c17486e..ff3bcfb296 100644 --- a/purchase_request_operating_unit/README.rst +++ b/purchase_request_operating_unit/README.rst @@ -2,10 +2,13 @@ Operating Unit in Purchase Requests =================================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:54a4115b5d9b148887d60353dc7b0b263fa63e89f31442d28c0a43745094b5fd + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -19,11 +22,11 @@ Operating Unit in Purchase Requests .. |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_request_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 +.. |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=15.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module introduces the following features: @@ -56,7 +59,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 +If you spotted it first, help us to smash it by providing a detailed and welcomed `feedback `_. Do not contact contributors directly about support or help with technical issues. diff --git a/purchase_request_operating_unit/__manifest__.py b/purchase_request_operating_unit/__manifest__.py index db80b0bc5c..2d8f58d5c3 100644 --- a/purchase_request_operating_unit/__manifest__.py +++ b/purchase_request_operating_unit/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Operating Unit in Purchase Requests", - "version": "15.0.1.0.0", + "version": "15.0.1.0.1", "author": "Eficent, SerpentCS, Odoo Community Association (OCA)", "website": "https://github.com/OCA/operating-unit", "license": "LGPL-3", diff --git a/purchase_request_operating_unit/i18n/fr.po b/purchase_request_operating_unit/i18n/fr.po index 43d7af01ea..c57b6b6d87 100644 --- a/purchase_request_operating_unit/i18n/fr.po +++ b/purchase_request_operating_unit/i18n/fr.po @@ -20,11 +20,9 @@ msgstr "" #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format msgid "" -"Configuration error. The Purchase Request and theWarehouse of picking type " +"Configuration error. The Purchase Request and the Warehouse of picking type " "must belong to the same Operating Unit." msgstr "" -"Erreur de configuration. La demande d'achat et l'entrepôt de prélèvement " -"doivent appartenir à la même unité opérationnelle." #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 @@ -43,27 +41,6 @@ msgstr "" "Impossible de traiter ! Vous devez sélectionner les lignes de la même unité " "opérationnelle." -#. module: purchase_request_operating_unit -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__display_name -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__display_name -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__display_name -msgid "Display Name" -msgstr "Nom affiché" - -#. module: purchase_request_operating_unit -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__id -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__id -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order__id -msgid "ID" -msgstr "ID" - -#. module: purchase_request_operating_unit -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request____last_update -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line____last_update -#: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line_make_purchase_order____last_update -msgid "Last Modified on" -msgstr "Dernière modification le" - #. module: purchase_request_operating_unit #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request__operating_unit_id #: model:ir.model.fields,field_description:purchase_request_operating_unit.field_purchase_request_line__operating_unit_id @@ -89,6 +66,11 @@ msgstr "Ligne de la demande d'achat" msgid "Purchase Request Line Make Purchase Order" msgstr "Ligne de demande d'achat fait Bon de commande" +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_stock_rule +msgid "Stock Rule" +msgstr "" + #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format @@ -98,3 +80,20 @@ msgid "" msgstr "" "La société sur la demande d'achat et sur l'unité opérationnelle doit être la " "même." + +#, python-format +#~ msgid "" +#~ "Configuration error. The Purchase Request and theWarehouse of picking " +#~ "type must belong to the same Operating Unit." +#~ msgstr "" +#~ "Erreur de configuration. La demande d'achat et l'entrepôt de prélèvement " +#~ "doivent appartenir à la même unité opérationnelle." + +#~ msgid "Display Name" +#~ msgstr "Nom affiché" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Dernière modification le" diff --git a/purchase_request_operating_unit/i18n/pt.po b/purchase_request_operating_unit/i18n/pt.po index 73c7ff0b36..fce60a9bc1 100644 --- a/purchase_request_operating_unit/i18n/pt.po +++ b/purchase_request_operating_unit/i18n/pt.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * purchase_request_operating_unit +# * purchase_request_operating_unit # msgid "" msgstr "" @@ -17,21 +17,24 @@ msgstr "" "X-Generator: Weblate 3.10\n" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/model/purchase_request.py:46 +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format -msgid "Configuration error. The Purchase Request and the Warehouse of picking type must belong to the same Operating Unit." +msgid "" +"Configuration error. The Purchase Request and the Warehouse of picking type " +"must belong to the same Operating Unit." msgstr "" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/model/purchase_request.py:56 +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format msgid "Configuration error. The approver has not the indicated Operating Unit" msgstr "" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:32 +#: code:addons/purchase_request_operating_unit/wizard/purchase_request_line_make_purchase_order.py:0 #, python-format -msgid "Could not process !You have to select linesfrom the same operating unit." +msgid "" +"Could not process !You have to select linesfrom the same operating unit." msgstr "" #. module: purchase_request_operating_unit @@ -59,7 +62,14 @@ msgid "Purchase Request Line Make Purchase Order" msgstr "" #. module: purchase_request_operating_unit -#: code:addons/purchase_request_operating_unit/model/purchase_request.py:31 +#: model:ir.model,name:purchase_request_operating_unit.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: purchase_request_operating_unit +#: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format -msgid "The Company in the Purchase Request and in the Operating Unit must bethe same." +msgid "" +"The Company in the Purchase Request and in the Operating Unit must bethe " +"same." msgstr "" diff --git a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot index 33fb5c2802..652bfc835b 100644 --- a/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot +++ b/purchase_request_operating_unit/i18n/purchase_request_operating_unit.pot @@ -17,7 +17,7 @@ msgstr "" #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format msgid "" -"Configuration error. The Purchase Request and theWarehouse of picking type " +"Configuration error. The Purchase Request and the Warehouse of picking type " "must belong to the same Operating Unit." msgstr "" @@ -58,6 +58,11 @@ msgstr "" msgid "Purchase Request Line Make Purchase Order" msgstr "" +#. module: purchase_request_operating_unit +#: model:ir.model,name:purchase_request_operating_unit.model_stock_rule +msgid "Stock Rule" +msgstr "" + #. module: purchase_request_operating_unit #: code:addons/purchase_request_operating_unit/model/purchase_request.py:0 #, python-format diff --git a/purchase_request_operating_unit/model/__init__.py b/purchase_request_operating_unit/model/__init__.py index 639be8329b..8e771c09a4 100644 --- a/purchase_request_operating_unit/model/__init__.py +++ b/purchase_request_operating_unit/model/__init__.py @@ -1,3 +1,4 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import purchase_request +from . import stock_rule diff --git a/purchase_request_operating_unit/model/purchase_request.py b/purchase_request_operating_unit/model/purchase_request.py index 80529a8804..debecd7175 100644 --- a/purchase_request_operating_unit/model/purchase_request.py +++ b/purchase_request_operating_unit/model/purchase_request.py @@ -53,7 +53,7 @@ def _check_warehouse_operating_unit(self): ): raise ValidationError( _( - "Configuration error. The Purchase Request and the" + "Configuration error. The Purchase Request and the " "Warehouse of picking type must belong to the same " "Operating Unit." ) diff --git a/purchase_request_operating_unit/model/stock_rule.py b/purchase_request_operating_unit/model/stock_rule.py new file mode 100644 index 0000000000..f0b59d782c --- /dev/null +++ b/purchase_request_operating_unit/model/stock_rule.py @@ -0,0 +1,15 @@ +# Copyright 2023 ForgeFlow, S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) + +from odoo import api, models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + @api.model + def _prepare_purchase_request(self, origin, values): + res = super(StockRule, self)._prepare_purchase_request(origin, values) + if self.warehouse_id.operating_unit_id: + res.update({"operating_unit_id": self.warehouse_id.operating_unit_id.id}) + return res diff --git a/purchase_request_operating_unit/static/description/index.html b/purchase_request_operating_unit/static/description/index.html index 79163a520a..8a8fb267ac 100644 --- a/purchase_request_operating_unit/static/description/index.html +++ b/purchase_request_operating_unit/static/description/index.html @@ -1,20 +1,20 @@ - + - + Operating Unit in Purchase Requests