diff --git a/account_fiscalyear_close_operating_unit/README.rst b/account_fiscalyear_close_operating_unit/README.rst index 8843223..c75c368 100644 --- a/account_fiscalyear_close_operating_unit/README.rst +++ b/account_fiscalyear_close_operating_unit/README.rst @@ -21,11 +21,11 @@ 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 `_. diff --git a/account_operating_unit/README.rst b/account_operating_unit/README.rst index 01f6c86..a576713 100644 --- a/account_operating_unit/README.rst +++ b/account_operating_unit/README.rst @@ -58,11 +58,11 @@ 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 `_. diff --git a/crm_operating_unit/__init__.py b/crm_operating_unit/__init__.py index b9ea7f2..162c458 100644 --- a/crm_operating_unit/__init__.py +++ b/crm_operating_unit/__init__.py @@ -1,21 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/crm_operating_unit/__openerp__.py b/crm_operating_unit/__openerp__.py index d51a72e..7be6b65 100644 --- a/crm_operating_unit/__openerp__.py +++ b/crm_operating_unit/__openerp__.py @@ -1,28 +1,13 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Operating Unit in CRM", - "version": "1.0", - "author": "Eficent", + "version": "7.0.1.0.0", + "author": "Eficent, Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Purchase Management", "depends": ["crm", "operating_unit"], @@ -35,10 +20,6 @@ "views/crm_lead_view.xml", "security/crm_security.xml", ], - 'demo': [ - ], - 'test': [ - ], 'installable': True, 'active': False, 'certificate': '', diff --git a/crm_operating_unit/models/__init__.py b/crm_operating_unit/models/__init__.py index 149d99d..dac0e73 100644 --- a/crm_operating_unit/models/__init__.py +++ b/crm_operating_unit/models/__init__.py @@ -1,21 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import crm_lead diff --git a/crm_operating_unit/models/crm_lead.py b/crm_operating_unit/models/crm_lead.py index 1867066..6643e73 100644 --- a/crm_operating_unit/models/crm_lead.py +++ b/crm_operating_unit/models/crm_lead.py @@ -1,23 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openerp.osv import fields, orm @@ -45,7 +30,6 @@ def _check_company_operating_unit(self, cr, uid, ids, context=None): _constraints = [ (_check_company_operating_unit, - 'The Company in the Purchase Order and in the Operating ' + 'The Company in the CRM lead and in the Operating ' 'Unit must be the same.', ['operating_unit_id', - 'requesting_operating_unit_id', 'company_id'])] diff --git a/crm_operating_unit/tests/__init__.py b/crm_operating_unit/tests/__init__.py index 9ddd008..f67a06a 100644 --- a/crm_operating_unit/tests/__init__.py +++ b/crm_operating_unit/tests/__init__.py @@ -1,26 +1,10 @@ # -*- coding: utf-8 -*- -# -# -# Authors: Guewen Baconnier -# Copyright 2015 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - -from . import test_purchase_operating_unit +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import test_crm_operating_unit checks = [ - test_purchase_operating_unit, + test_crm_operating_unit, ] diff --git a/crm_operating_unit/tests/test_crm_operating_unit.py b/crm_operating_unit/tests/test_crm_operating_unit.py index 6affc4b..a0f2585 100644 --- a/crm_operating_unit/tests/test_crm_operating_unit.py +++ b/crm_operating_unit/tests/test_crm_operating_unit.py @@ -1,24 +1,8 @@ # -*- coding: utf-8 -*- -# -# -# Authors: Guewen Baconnier -# Copyright 2015 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# - +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openerp.tests import common from openerp import netsvc @@ -28,122 +12,41 @@ class TestPurchaseOperatingUnit(common.TransactionCase): def setUp(self): super(TestPurchaseOperatingUnit, self).setUp() cr, uid, context = self.cr, self.uid, {} - - self.purchase_model = self.registry('purchase.order') - self.purchase_line_model = self.registry('purchase.order.line') - self.stock_picking_model = self.registry('stock.picking') - self.account_invoice_model = self.registry('account.invoice') - self.product_model = self.registry('product.product') - self.partner_model = self.registry('res.partner') - self.location_model = self.registry('stock.location') - self.pricelist_model = self.registry('product.pricelist') - self.operating_unit_model = self.registry('operating.unit') - self.res_users_model = self.registry('res.users') - self.res_company_model = self.registry('res.company') - self.res_groups = self.registry('res.groups') - data_model = self.registry('ir.model.data') - - _, company1_id = data_model.get_object_reference( - cr, uid, 'base', 'main_company') - self.company1 = self.res_company_model.browse(cr, uid, company1_id, - context=context) - _, company1_id = data_model.get_object_reference( - cr, uid, 'stock', 'res_company_2') - self.company2 = self.res_company_model.browse(cr, uid, company1_id, - context=context) - _, group_purchase_user_id = data_model.get_object_reference( - cr, uid, 'purchase', 'group_purchase_user') - self.group_purchase_user = self.res_groups.browse( - cr, uid, group_purchase_user_id, context=context) - _, group_stock_user_id = data_model.get_object_reference( - cr, uid, 'stock', 'group_stock_user') - self.group_stock_user = self.res_groups.browse(cr, uid, - group_stock_user_id, - context=context) - _, ou1_id = data_model.get_object_reference( - cr, uid, 'operating_unit', 'main_operating_unit') - self.ou1 = self.operating_unit_model.browse(cr, uid, ou1_id, - context=context) - _, ou2_id = data_model.get_object_reference( - cr, uid, 'stock_operating_unit', 'operating_unit_shop1') - self.ou2 = self.operating_unit_model.browse(cr, uid, ou1_id, - context=context) - _, partner1_id = data_model.get_object_reference(cr, uid, 'base', - 'res_partner_1') - self.partner1 = self.partner_model.browse(cr, uid, partner1_id, - context=context) - _, product1_id = data_model.get_object_reference( - cr, uid, 'product', 'product_product_7') - self.product1 = self.product_model.browse( - cr, uid, product1_id, context=context) - - _, product2_id = data_model.get_object_reference(cr, uid, 'product', - 'product_product_9') - self.product2 = self.product_model.browse( - cr, uid, product2_id, context=context) - - _, product3_id = data_model.get_object_reference( - cr, uid, 'product', 'product_product_11') - self.product3 = self.product_model.browse( - cr, uid, product3_id, context=context) - - _, warehouse1_id = data_model.get_object_reference( - cr, uid, 'stock', 'warehouse0') - self.warehouse1 = self.product_model.browse( - cr, uid, warehouse1_id, context=context) - - _, location_stock1_id = data_model.get_object_reference( - cr, uid, 'stock', 'stock_location_stock') - self.location_stock1 = self.location_model.browse( - cr, uid, location_stock1_id, context=context) - - _, purchase_pricelist_id = data_model.get_object_reference( - cr, uid, 'purchase', 'list0') - self.purchase_pricelist = self.pricelist_model.browse( - cr, uid, purchase_pricelist_id, context=context) - - user1_id = self._create_user(cr, uid, 'user_1', - [self.group_purchase_user, - self.group_stock_user], - self.company1, + self.res_users_model = self.registry('res.users') + self.crm_lead_model = self.registry('crm.lead') + # Groups + self.grp_sale_user = data_model.get_object(cr, uid, 'base', + 'group_sale_manager') + self.grp_user = data_model.get_object(cr, uid, 'base', + 'group_user') + # Company + self.company = data_model.get_object(cr, uid, 'base', 'main_company') + # Main Operating Unit + self.ou1 = data_model.get_object(cr, uid, 'operating_unit', + 'main_operating_unit') + # B2C Operating Unit + self.b2c = data_model.get_object(cr, uid, 'operating_unit', + 'b2c_operating_unit') + # Create User 1 with Main OU + self.user1_id = self._create_user(cr, uid, 'user_1', + [self.grp_sale_user, self.grp_user], + self.company, [self.ou1], context=context) - self.user1 = self.res_users_model.browse( - cr, uid, user1_id, context=context) - - user2_id = self._create_user(cr, uid, 'user_2', - [self.group_purchase_user, - self.group_stock_user], - self.company2, - [self.ou2], context=context) - self.user2 = self.res_users_model.browse( - cr, uid, user2_id, context=context) - - purchase1_id = self._create_purchase( - cr, user1_id, 'picking', [(self.product1, 1000), - (self.product2, 500), - (self.product3, 800)], context=context) - self.purchase1 = self.purchase_model.browse( - cr, user1_id, purchase1_id, context=context) - - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', purchase1_id, - 'purchase_confirm', cr) - - purchase2_id = self._create_purchase( - cr, user1_id, 'order', [(self.product1, 1000), - (self.product2, 500), - (self.product3, 800)], context=context) - self.purchase2 = self.purchase_model.browse( - cr, user1_id, purchase2_id, context=context) - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'purchase.order', purchase2_id, - 'purchase_confirm', cr) + # Create User 2 with B2C OU + self.user2_id = self._create_user(cr, uid, 'user_2', + [self.grp_sale_user, self.grp_user], + self.company, + [self.b2c], context=context) + # Create CRM Leads + self.lead1_id = self._create_crm_lead(cr, self.user1_id, self.ou1, + context=context) + self.lead2_id = self._create_crm_lead(cr, self.user2_id, self.b2c, + context=context) def _create_user(self, cr, uid, login, groups, company, operating_units, context=None): - """ Create a user. - """ + """ Create a user. """ group_ids = [group.id for group in groups] user_id = self.res_users_model.create(cr, uid, { 'name': 'Chicago Purchase User', @@ -155,81 +58,25 @@ def _create_user(self, cr, uid, login, groups, company, operating_units, 'operating_unit_ids': [(4, ou.id) for ou in operating_units], 'groups_id': [(6, 0, group_ids)] }) - return user_id - def _create_purchase(self, cr, uid, invoice_method, line_products, - context=None): - """ Create a purchase order. - - ``line_products`` is a list of tuple [(product, qty)] - """ - lines = [] - for product, qty in line_products: - line_values = { - 'product_id': product.id, - 'product_qty': qty, - 'product_uom': product.uom_id.id, - 'price_unit': 50, - } - onchange_res = self.purchase_line_model.onchange_product_id( - cr, uid, [], self.purchase_pricelist.id, product.id, qty, - product.uom_id.id, self.partner1.id, context=context) - line_values.update(onchange_res['value']) - lines.append( - (0, 0, line_values) - ) - po = self.purchase_model.create(cr, uid, { - 'operating_unit_id': self.ou1.id, - 'requesting_operating_unit_id': self.ou1.id, - 'partner_id': self.partner1.id, - 'warehouse_id': self.warehouse1.id, - 'location_id': self.location_stock1.id, - 'pricelist_id': self.purchase_pricelist.id, - 'order_line': lines, - 'invoice_method': invoice_method, - 'company_id': self.company1.id, - }, context=context) - return po + def _create_crm_lead(self, cr, uid, operating_unit, context=None): + """Create a sale order.""" + crm_id = self.crm_lead_model.create(cr, uid, { + 'name': 'CRM LEAD', + 'operating_unit_id': operating_unit.id + }) + return crm_id def test_security(self): cr, uid, context = self.cr, self.uid, {} - # User 2 is only assigned to Operating Unit 2, and cannot list - # purchase orders from Operating Unit 1. - po_ids = self.purchase_model.search(cr, self.user2.id, - [('operating_unit_id', '=', + # User 2 is only assigned to B2C Operating Unit, and cannot + # access CRM leads for Main Operating Unit. + user2 = self.res_users_model.browse(cr, uid, self.user2_id, + context=None) + lead_ids = self.crm_lead_model.search(cr, user2.id, + [('id', '=', self.lead1_id), + ('operating_unit_id', '=', self.ou1.id)], context=context) - self.assertEqual(po_ids, []) - - # User 2 cannot list the picking that was created from PO 1 - picking_ids = self.stock_picking_model.search( - cr, self.user2.id, [('purchase_id', '=', self.purchase1.id)], - context=context) - self.assertEqual(picking_ids, []) - - # User 2 cannot list the invoice that was created from PO 2 - invoices = [inv.id for inv in self.purchase2.invoice_ids] - invoice_ids = self.account_invoice_model.search( - cr, self.user2.id, [('id', '=', invoices[0])], - context=context) - self.assertEqual(invoice_ids, []) - - # User 1 is assigned to Operating Unit 1, and can list - # the purchase order 1 from Operating Unit 1. - po_ids = self.purchase_model.search(cr, self.user1.id, - [('operating_unit_id', '=', - self.ou1.id)], context=context) - self.assertNotEqual(po_ids, []) - - # User 1 can list the picking that was created from PO 1 - picking_ids = self.stock_picking_model.search( - cr, self.user1.id, [('purchase_id', '=', self.purchase1.id)], - context=context) - self.assertNotEqual(picking_ids, []) - - # User 1 can list the invoice that was created from PO 2 - invoices = [inv.id for inv in self.purchase2.invoice_ids] - invoice_ids = self.account_invoice_model.search( - cr, self.user1.id, [('id', '=', invoices[0])], - context=context) - self.assertNotEqual(invoice_ids, []) + self.assertEqual(lead_ids, [], 'User 2 should not have access to ' + 'OU %s' % self.ou1.name) diff --git a/operating_unit/README.rst b/operating_unit/README.rst index 1345dc9..2cfb0e1 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -43,11 +43,11 @@ 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 `_. diff --git a/procurement_operating_unit/README.rst b/procurement_operating_unit/README.rst index 0d0b667..2bffb90 100644 --- a/procurement_operating_unit/README.rst +++ b/procurement_operating_unit/README.rst @@ -35,12 +35,12 @@ 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 diff --git a/purchase_operating_unit/README.rst b/purchase_operating_unit/README.rst index 85663df..ef058da 100644 --- a/purchase_operating_unit/README.rst +++ b/purchase_operating_unit/README.rst @@ -32,11 +32,11 @@ 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 `_. diff --git a/sale_operating_unit/README.rst b/sale_operating_unit/README.rst new file mode 100644 index 0000000..d1500bc --- /dev/null +++ b/sale_operating_unit/README.rst @@ -0,0 +1,71 @@ +.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg + :target: https://www.gnu.org/licenses/agpl.html + :alt: License: AGPL-3 + +=============================== +Operating Unit in Sales +=============================== + +This module was written to extend the Sales capabilities of Odoo. +This module introduces the operating unit to the Sales Order. +Security rules are defined to ensure that users can only display the +Sales Orders in which they are allowed access to. + +Installation +============ + +No additional installation instructions are required. + +Configuration +============= + +Go to 'Settings / Technical / Actions / User-defined Defaults' and remove +the default set for the Shop. + +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/7.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 +------------ + +* Eficent Business and IT Consulting Services S.L. +* 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 http://odoo-community.org. \ No newline at end of file diff --git a/sale_operating_unit/__init__.py b/sale_operating_unit/__init__.py index 55c73fa..821bd14 100644 --- a/sale_operating_unit/__init__.py +++ b/sale_operating_unit/__init__.py @@ -4,4 +4,4 @@ # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models -from . import tests +#from . import tests diff --git a/sale_operating_unit/__openerp__.py b/sale_operating_unit/__openerp__.py index 4e55c18..e400584 100644 --- a/sale_operating_unit/__openerp__.py +++ b/sale_operating_unit/__openerp__.py @@ -6,8 +6,8 @@ { "name": "Operating Unit in Sales", - "version": "1.0", - "author": "Eficent", + "version": "7.0.1.0.0", + "author": "Eficent, Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Purchase Management", "depends": ["sale", @@ -21,35 +21,12 @@ Security rules are defined to ensure that users can only display the Sales Orders in which they are allowed access to. - - -Installation -============ - -No additional installation instructions are required. - - -Configuration -============= - -Go to 'Settings / Technical / Actions / User-defined Defaults' and remove -the default set for the Shop. - - -Credits -======= - -Contributors ------------- - -* Jordi Ballester - """, + "license": "AGPL-3", "data": [ "data/sale_data.xml", "views/sale_view.xml", "security/sale_security.xml", - ], 'installable': True, 'active': False, diff --git a/sale_operating_unit/static/description/icon.png b/sale_operating_unit/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/sale_operating_unit/static/description/icon.png differ diff --git a/sale_stock_operating_unit/README.rst b/sale_stock_operating_unit/README.rst new file mode 100644 index 0000000..6ef136b --- /dev/null +++ b/sale_stock_operating_unit/README.rst @@ -0,0 +1,71 @@ +.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg + :target: https://www.gnu.org/licenses/agpl.html + :alt: License: AGPL-3 + +=============================== +Operating Unit in Sales Stock +=============================== + +This module was written to extend the Sales capabilities of Odoo. +This module introduces the operating unit to the Sales Order. +Security rules are defined to ensure that users can only display the +Sales Orders in which they are allowed access to. + +Installation +============ + +No additional installation instructions are required. + +Configuration +============= + +Go to 'Settings / Technical / Actions / User-defined Defaults' and remove +the default set for the Shop. + +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/7.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 +------------ + +* Eficent Business and IT Consulting Services S.L. +* 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 http://odoo-community.org. \ No newline at end of file diff --git a/sale_stock_operating_unit/__init__.py b/sale_stock_operating_unit/__init__.py index b9ea7f2..162c458 100644 --- a/sale_stock_operating_unit/__init__.py +++ b/sale_stock_operating_unit/__init__.py @@ -1,21 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/sale_stock_operating_unit/__openerp__.py b/sale_stock_operating_unit/__openerp__.py index 4016904..ce7351c 100644 --- a/sale_stock_operating_unit/__openerp__.py +++ b/sale_stock_operating_unit/__openerp__.py @@ -1,30 +1,15 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Operating Unit in Sales Stock", - "version": "1.0", - "author": "Eficent", + "version": "7.0.1.0.0", + "author": "Eficent, Odoo Community Association (OCA)", "website": "http://www.eficent.com", - "category": "Purchase Management", + "category": "Sales Management", "depends": ["sale_stock", "sale_operating_unit", "stock_operating_unit"], diff --git a/sale_stock_operating_unit/models/__init__.py b/sale_stock_operating_unit/models/__init__.py index 47e290a..f70eaa1 100644 --- a/sale_stock_operating_unit/models/__init__.py +++ b/sale_stock_operating_unit/models/__init__.py @@ -1,21 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import sale diff --git a/sale_stock_operating_unit/models/sale.py b/sale_stock_operating_unit/models/sale.py index 569a6a0..59b10a3 100644 --- a/sale_stock_operating_unit/models/sale.py +++ b/sale_stock_operating_unit/models/sale.py @@ -1,23 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openerp.osv import fields, orm from openerp.tools.translate import _ diff --git a/sale_stock_operating_unit/static/description/icon.png b/sale_stock_operating_unit/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/sale_stock_operating_unit/static/description/icon.png differ diff --git a/sale_stock_operating_unit/tests/__init__.py b/sale_stock_operating_unit/tests/__init__.py new file mode 100644 index 0000000..b60f709 --- /dev/null +++ b/sale_stock_operating_unit/tests/__init__.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import test_sale_stock_operating_unit + +checks = [ + test_sale_stock_operating_unit, +] diff --git a/sale_stock_operating_unit/tests/test_sale_stock_operating_unit.py b/sale_stock_operating_unit/tests/test_sale_stock_operating_unit.py new file mode 100644 index 0000000..e97b6a0 --- /dev/null +++ b/sale_stock_operating_unit/tests/test_sale_stock_operating_unit.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# © 2015 Eficent Business and IT Consulting Services S.L. - +# Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openerp import netsvc +from openerp.addons.sale_operating_unit.tests import test_sale_operating_unit + + +class TestSaleStockOperatingUnit(test_sale_operating_unit. + TestSaleOperatingUnit): + + def setUp(self): + super(TestSaleStockOperatingUnit, self).setUp() + cr, uid, context = self.cr, self.uid, {} + data_model = self.registry('ir.model.data') + self.warehouse_model = self.registry('stock.warehouse') + # B2C Warehouse + self.warehouse2 = data_model.get_object(cr, uid, + 'stock_operating_unit', + 'stock_warehouse_b2c') + # Create Shop2 + self.new_shop2_id = self._update_shops(cr, self.user2_id, + self.shop2_id, self.warehouse2, + context=context) + self.stock_pick_model = self.registry('stock.picking.out') +# # Create Sale Order2 + self.new_sale2_id = self._update_sale_order(cr, self.user2_id, + self.sale2_id, + self.new_shop2_id, + context=context) + + def _update_shops(self, cr, uid, shop_id, warehouse, context=None): + """Create a shop.""" + self.shop_model.write(cr, uid, [shop_id], { + 'warehouse_id': warehouse.id, + }) + shop = self.shop_model.browse(cr, uid, shop_id) + new_shop_id = shop.id + return new_shop_id + + def _update_sale_order(self, cr, uid, sale_id, shop, context=None): + """Create a sale order.""" + self.sale_model.write(cr, uid, [sale_id], { + 'shop_id': shop, + }) + sale = self.sale_model.browse(cr, uid, sale_id) + new_sale_id = sale.id + return new_sale_id + + def _confirm_sale(self, cr, uid, sale_id): + self.sale_model.action_button_confirm(cr, uid, [sale_id]) + sale = self.sale_model.browse(cr, uid, sale_id) + for picking in sale.picking_ids: + self.operating_unit = picking.operating_unit_id + return sale + + def test_security(self): + """Test Sale Stock Operating Unit""" + # User 2 is only assigned to Operating Unit B2C, and cannot + # Access Sales order from Main Operating Unit. + cr, uid = self.cr, self.uid + sale_ids = self.sale_model.search(self.cr, self.user2_id, + [('operating_unit_id', '=', + self.ou1.id)]) + self.assertEqual(sale_ids, [], 'User 2 should not have access to ' + 'OU %s' % self.ou1.name) + # Confirm Sale1 + sale1 = self._confirm_sale(cr, uid, self.sale1_id) + # Checks that OU in sale order and stock picking matches or not. + self.assertEqual(self.operating_unit, sale1.operating_unit_id, + 'OU in Sale Order and Picking should be same') + # Confirm Sale2 + sale2 = self._confirm_sale(cr, uid, self.new_sale2_id) + # Checks that OU in sale order and stock picking matches or not. + self.assertEqual(self.operating_unit, sale2.operating_unit_id, + 'OU in Sale Order and Picking should be same') diff --git a/stock_account_operating_unit/README.rst b/stock_account_operating_unit/README.rst index 9645b64..8841ea9 100644 --- a/stock_account_operating_unit/README.rst +++ b/stock_account_operating_unit/README.rst @@ -49,11 +49,11 @@ 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 `_. diff --git a/stock_operating_unit/README.rst b/stock_operating_unit/README.rst index 5182cca..1f6f8e9 100644 --- a/stock_operating_unit/README.rst +++ b/stock_operating_unit/README.rst @@ -37,11 +37,11 @@ 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 `_.