diff --git a/sale_restrict/LICENSE/LICENSE b/sale_restrict/LICENSE/LICENSE new file mode 100644 index 000000000..e2c856860 --- /dev/null +++ b/sale_restrict/LICENSE/LICENSE @@ -0,0 +1,17 @@ + OpenERP, Open Source Management Solution + Copyright (C) 2004-2010 OpenERP SA () + Copyright (C) 2011-Today Serpent Consulting Services Pvt. Ltd. (). + + 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 . + diff --git a/sale_restrict/README.rst b/sale_restrict/README.rst new file mode 100644 index 000000000..09802216c --- /dev/null +++ b/sale_restrict/README.rst @@ -0,0 +1,38 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +============= +Sale Restrict +============= + +* This module restricts a user from confirming a Sale Order/Quotation + if it contains products having sale price zero. + +Bug Tracker +=========== + +Credits +======= + +Contributors +------------ + +* Jay Vora +* Meet Dholakia +* Sudhir Arya . + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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. diff --git a/sale_restrict/__init__.py b/sale_restrict/__init__.py new file mode 100644 index 000000000..a14d2375b --- /dev/null +++ b/sale_restrict/__init__.py @@ -0,0 +1,3 @@ +# See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/sale_restrict/__manifest__.py b/sale_restrict/__manifest__.py new file mode 100644 index 000000000..d7d8d4e43 --- /dev/null +++ b/sale_restrict/__manifest__.py @@ -0,0 +1,19 @@ +# See LICENSE file for full copyright and licensing details. + +{ + 'name': 'SO - Product Price Check', + 'version': '14.0.1.0.0', + 'category': 'Sales Management', + 'author': 'Serpent Consulting Services Pvt. Ltd.', + 'summary': 'Restrict sales on 0 value.', + 'license': 'AGPL-3', + 'maintainer': 'Serpent Consulting Services Pvt. Ltd.', + 'website': 'http://www.serpentcs.com', + 'depends': [ + 'sale_management', + ], + 'images': [ + 'static/description/PriceCheck.png', + ], + 'installable': True, +} diff --git a/sale_restrict/i18n/fr.po b/sale_restrict/i18n/fr.po new file mode 100644 index 000000000..0c5dc603b --- /dev/null +++ b/sale_restrict/i18n/fr.po @@ -0,0 +1,24 @@ +# French translation for openobject-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2014-08-14 13:08+0000\n" +"PO-Revision-Date: 2014-08-21 16:10+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-08-15 06:57+0000\n" +"X-Generator: Launchpad (build 17156)\n" + +#. module: sale_restrict +#: code:addons/sale_restrict/sale_order.py:15 +#, python-format +msgid "Please specify unit price for the following products:" +msgstr "S'il vous plaît indiquer le prix unitaire pour les produits suivants" diff --git a/sale_restrict/i18n/sale_restrict.pot b/sale_restrict/i18n/sale_restrict.pot new file mode 100644 index 000000000..356505978 --- /dev/null +++ b/sale_restrict/i18n/sale_restrict.pot @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_restrict +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0rc1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-08-14 13:08+0000\n" +"PO-Revision-Date: 2014-08-21 13:08+0000\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: sale_restrict +#: code:addons/sale_restrict/sale_order.py:15 +#, python-format +msgid "Please specify unit price for the following products:" +msgstr "S'il vous plaît indiquer le prix unitaire pour les produits suivants" diff --git a/sale_restrict/models/__init__.py b/sale_restrict/models/__init__.py new file mode 100644 index 000000000..f9f20ab56 --- /dev/null +++ b/sale_restrict/models/__init__.py @@ -0,0 +1,3 @@ +# See LICENSE file for full copyright and licensing details. + +from . import sale_order diff --git a/sale_restrict/models/sale_order.py b/sale_restrict/models/sale_order.py new file mode 100644 index 000000000..7de4e972f --- /dev/null +++ b/sale_restrict/models/sale_order.py @@ -0,0 +1,19 @@ +# See LICENSE file for full copyright and licensing details. + +from odoo import _, models +from odoo.exceptions import UserError + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + def action_confirm(self): + zero_price = [x.product_id.name + for x in self.order_line if not x.price_unit > 0.0] + + if zero_price: + message = _("Please specify unit price for " + "the following products:") + '\n' + message += '\n'.join(map(str, zero_price)) + raise UserError(message.rstrip()) + return super(SaleOrder, self).action_confirm() diff --git a/sale_restrict/static/description/.png b/sale_restrict/static/description/.png new file mode 100644 index 000000000..de8db314a Binary files /dev/null and b/sale_restrict/static/description/.png differ diff --git a/sale_restrict/static/description/PriceCheck.png b/sale_restrict/static/description/PriceCheck.png new file mode 100644 index 000000000..3406009a3 Binary files /dev/null and b/sale_restrict/static/description/PriceCheck.png differ diff --git a/sale_restrict/static/description/icon.png b/sale_restrict/static/description/icon.png new file mode 100644 index 000000000..ff6d49556 Binary files /dev/null and b/sale_restrict/static/description/icon.png differ diff --git a/sale_restrict/static/description/index.html b/sale_restrict/static/description/index.html new file mode 100644 index 000000000..c9e25055e --- /dev/null +++ b/sale_restrict/static/description/index.html @@ -0,0 +1,50 @@ + +
+
+ +
+
+ +
+
+
+

SO- Product price check

+

+ This module restricts a user from confirming a Sale

+

Order/Quotation if it contains products having sale price zero.

+
+
+
+ +
+
+
+
+ +
+
+
+

+ If you select products having sale price zero, + then upon confirming the sale, +

+
+ +
+
+ +
+
+
+

+ It will raise a warning to the user insisting him/her to + specify the unit price for the listed products. +

+
+
+
+ +
+
+
+
diff --git a/sale_restrict/static/description/sale1.png b/sale_restrict/static/description/sale1.png new file mode 100644 index 000000000..4cea9ee56 Binary files /dev/null and b/sale_restrict/static/description/sale1.png differ diff --git a/sale_restrict/static/description/sale2.png b/sale_restrict/static/description/sale2.png new file mode 100644 index 000000000..3526339fc Binary files /dev/null and b/sale_restrict/static/description/sale2.png differ diff --git a/sale_restrict/static/description/serpent_logo.png b/sale_restrict/static/description/serpent_logo.png new file mode 100644 index 000000000..68dacf854 Binary files /dev/null and b/sale_restrict/static/description/serpent_logo.png differ diff --git a/sale_restrict/tests/__init__.py b/sale_restrict/tests/__init__.py new file mode 100644 index 000000000..0ba8fd954 --- /dev/null +++ b/sale_restrict/tests/__init__.py @@ -0,0 +1,3 @@ +# See LICENSE file for full copyright and licensing details. + +from . import test_sale_restrict diff --git a/sale_restrict/tests/test_sale_restrict.py b/sale_restrict/tests/test_sale_restrict.py new file mode 100644 index 000000000..653727684 --- /dev/null +++ b/sale_restrict/tests/test_sale_restrict.py @@ -0,0 +1,23 @@ +# See LICENSE file for full copyright and licensing details. + +from odoo.tests import common + + +class SaleOrder(common.TransactionCase): + + def setup(self): + super(SaleOrder, self).setup() + + def test_sale_action(self): + self.partner = self.ref('base.res_partner_2') + self.product_1 = self.env.ref('product.product_product_12') + self.sale_order = self.env['sale.order'].create( + {'partner_id': self.partner, + 'order_line': [(0, 0, {'name': self.product_1.name, + 'product_id': self.product_1.id, + 'product_uom_qty': 2, + 'product_uom': self.product_1.uom_id.id, + 'price_unit': self.product_1.list_price} + )], + }) + self.sale_order.action_confirm()