Skip to content

Commit

Permalink
Merge pull request #508 from Chandresh-SerpentCS/14.0_mig_sale_restrict
Browse files Browse the repository at this point in the history
[14.0] [MIG] sale_restrict: Module migrated in v14. (Ready to test)
  • Loading branch information
JayVora-SerpentCS authored Jul 29, 2021
2 parents d5d589d + 9c586e4 commit 806c0e8
Show file tree
Hide file tree
Showing 17 changed files with 221 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sale_restrict/LICENSE/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
OpenERP, Open Source Management Solution
Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
Copyright (C) 2011-Today Serpent Consulting Services Pvt. Ltd. (<http://www.serpentcs.com>).

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 <http://www.gnu.org/licenses/>.

38 changes: 38 additions & 0 deletions sale_restrict/README.rst
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* Meet Dholakia <[email protected]>
* Sudhir Arya <[email protected]>.

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.
3 changes: 3 additions & 0 deletions sale_restrict/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See LICENSE file for full copyright and licensing details.

from . import models
19 changes: 19 additions & 0 deletions sale_restrict/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
24 changes: 24 additions & 0 deletions sale_restrict/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\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 <EMAIL@ADDRESS>\n"
"Language-Team: French <[email protected]>\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"
22 changes: 22 additions & 0 deletions sale_restrict/i18n/sale_restrict.pot
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions sale_restrict/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See LICENSE file for full copyright and licensing details.

from . import sale_order
19 changes: 19 additions & 0 deletions sale_restrict/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -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()
Binary file added sale_restrict/static/description/.png
Binary file not shown.
Binary file added sale_restrict/static/description/PriceCheck.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sale_restrict/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions sale_restrict/static/description/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

<section class="oe_container oe_dark">
<div class='oe_cover'>
<a href="http://www.serpentcs.com" target="new" ><img src="serpent_logo.png" align="right"></a>
</div>
</section>

<section class="oe_container ">
<div class="oe_row">
<div class="oe_row">
<h2 class="oe_slogan" style="color:#875A7B;">SO- Product price check</h2>
<h3 class="oe_slogan">
This module restricts a user from confirming a Sale</h3>
<h3 class="oe_slogan">Order/Quotation if it contains products having sale price zero.</h3>
</div>
</div>
</section>

<section class='oe_container oe_dark'>
<div class='oe_row oe_spaced'>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="sale1.png">
</div>
</div>
<div style="margin: 16px 8%;">
<p class='oe_mt32'>
If you select products having sale price zero,
then upon confirming the sale,
</p>
</div>

</div>
</section>

<section class='oe_container'>
<div class='oe_row oe_spaced'>
<div class="oe_span6">
<p class='oe_mt32'>
It will raise a warning to the user insisting him/her to
specify the unit price for the listed products.
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="sale2.png">
</div>
</div>
</div>
</section>
Binary file added sale_restrict/static/description/sale1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sale_restrict/static/description/sale2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sale_restrict/static/description/serpent_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions sale_restrict/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See LICENSE file for full copyright and licensing details.

from . import test_sale_restrict
23 changes: 23 additions & 0 deletions sale_restrict/tests/test_sale_restrict.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 806c0e8

Please sign in to comment.