@ -0,0 +1,49 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Sale Stock Restrict |
|||
=================== |
|||
* This module helps manage out-of-stock products based on on-hand or forecast quantity. |
|||
|
|||
Installation |
|||
============ |
|||
- www.odoo.com/documentation/17.0/setup/install.html |
|||
- Install our custom addon |
|||
|
|||
License |
|||
------- |
|||
Affero General Public License v3.0 (AGPL v3) |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* 'Cybrosys Techno Solutions <https://cybrosys.com/> |
|||
|
|||
Credits |
|||
------- |
|||
* Developer: Developer : (V18) Raneesha M K |
|||
(V17) Ashok P K |
|||
Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
* Website : https://cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit https://www.cybrosys.com |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import models |
@ -0,0 +1,43 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
{ |
|||
'name': 'Sale Stock Restrict', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Sales', |
|||
'summary': 'Module helps to restrict out of stock products', |
|||
'description': """This module helps manage out-of-stock products based on |
|||
on-hand or forecast quantity.""", |
|||
'author': 'Cybrosys Techno solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['base', 'sale_management', 'stock', 'account','website_sale'], |
|||
'data': [ |
|||
'views/res_config_settings_views.xml', |
|||
'views/sale_order.xml', |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
@ -0,0 +1,6 @@ |
|||
## Module <sale_stock_restrict> |
|||
|
|||
#### 03.11.2024 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
- Initial Commit for Sale Stock Restrict |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import res_config_settings |
|||
from . import sale_order |
@ -0,0 +1,56 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class ResConfigSettings(models.TransientModel): |
|||
"""Class to add fields and functions in settings""" |
|||
_inherit = 'res.config.settings' |
|||
|
|||
product_restriction = fields.Boolean( |
|||
string='Out Of Stock Product Restriction', |
|||
help='Enable this to restrict the out of stock product') |
|||
check_stock = fields.Selection( |
|||
[('on_hand_quantity', 'On Hand Quantity'), |
|||
('forecast_quantity', 'Forecast Quantity')], string="Based On", |
|||
help='Choose the type of restriction') |
|||
|
|||
@api.model |
|||
def get_values(self): |
|||
"""Function to take values from the fields""" |
|||
res = super().get_values() |
|||
params = self.env['ir.config_parameter'].sudo().get_param |
|||
product_restriction = params('sale_stock_restrict.product_restriction') |
|||
check_stock = params('sale_stock_restrict.check_stock') |
|||
res.update( |
|||
product_restriction=product_restriction, |
|||
check_stock=check_stock |
|||
) |
|||
return res |
|||
|
|||
def set_values(self): |
|||
"""Function to set the values in the fields""" |
|||
super().set_values() |
|||
self.env['ir.config_parameter'].sudo().set_param( |
|||
'sale_stock_restrict.product_restriction', self.product_restriction) |
|||
self.env['ir.config_parameter'].sudo().set_param( |
|||
'sale_stock_restrict.check_stock', self.check_stock) |
@ -0,0 +1,98 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# 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 (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import api, fields, models |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class SaleOrderLine(models.Model): |
|||
"""Class to add fields in sale order line and automatically display the |
|||
value in the fields if we select a product.""" |
|||
_inherit = 'sale.order.line' |
|||
|
|||
qty_available = fields.Float( |
|||
string="On Hand Quantity", |
|||
help='Count of on hand quantity') |
|||
forecast_quantity = fields.Float( |
|||
string="Forecast Quantity", |
|||
help='Count of forecast quantity') |
|||
|
|||
@api.onchange('product_id') |
|||
def _onchange_product_id(self): |
|||
"""Function to set the value of the fields based on product.""" |
|||
product_restriction = self.env['ir.config_parameter'].sudo().get_param( |
|||
'sale_stock_restrict.product_restriction') |
|||
check_stock = self.env[ |
|||
'ir.config_parameter'].sudo().get_param( |
|||
'sale_stock_restrict.check_stock') |
|||
if product_restriction: |
|||
if check_stock == 'on_hand_quantity': |
|||
self.qty_available = self.product_id.qty_available |
|||
if check_stock == 'forecast_quantity': |
|||
self.forecast_quantity = self.product_id.virtual_available |
|||
|
|||
|
|||
class SaleOrder(models.Model): |
|||
"""Class to add fields in sale order and a function for confirming |
|||
quotation.""" |
|||
_inherit = 'sale.order' |
|||
|
|||
onhand_check = fields.Boolean( |
|||
string='Enable OnHand', |
|||
help='To check whether it is based on on-hand quantity') |
|||
forecast_check = fields.Boolean( |
|||
string='Enable Forecast', |
|||
help='To check whether it is based on forecast quantity') |
|||
|
|||
def action_confirm(self): |
|||
"""Function to restrict the confirming of quotation if the product is |
|||
out of stock.""" |
|||
res = super().action_confirm() |
|||
low_qty = ["Can't confirm the sale order due to: \n"] |
|||
for rec in self.order_line: |
|||
product_restriction = self.env[ |
|||
'ir.config_parameter'].sudo().get_param( |
|||
'sale_stock_restrict.product_restriction') |
|||
check_stock = self.env[ |
|||
'ir.config_parameter'].sudo().get_param( |
|||
'sale_stock_restrict.check_stock') |
|||
if (product_restriction and not self.website_id and |
|||
rec.product_id.type == 'consu'): |
|||
if (check_stock == 'on_hand_quantity' and |
|||
rec.product_uom_qty > rec.qty_available): |
|||
self.onhand_check = True |
|||
low_qty.append( |
|||
f"You have added {rec.product_uom_qty} units of " |
|||
f"{rec.product_id.name}, but you only have " |
|||
f"{rec.qty_available} units available.") |
|||
if (check_stock == 'forecast_quantity' and |
|||
rec.product_uom_qty > rec.forecast_quantity): |
|||
self.forecast_check = True |
|||
low_qty.append( |
|||
f"You have added {rec.product_uom_qty} units of " |
|||
f"{rec.product_id.name}, but you only have " |
|||
f"{rec.forecast_quantity} units available.") |
|||
message = ' '.join(map(str, low_qty)) |
|||
if self.onhand_check: |
|||
raise ValidationError(message) |
|||
if self.forecast_check: |
|||
raise ValidationError(message) |
|||
return res |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 156 KiB |
After Width: | Height: | Size: 151 KiB |
After Width: | Height: | Size: 196 KiB |
After Width: | Height: | Size: 203 KiB |
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 272 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 716 KiB |
After Width: | Height: | Size: 41 KiB |
@ -0,0 +1,31 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!--View for the fields to enable the restriction in settings.--> |
|||
<record id="res_config_settings_view_form" model="ir.ui.view"> |
|||
<field name="name"> |
|||
res.config.settings.view.form.inherit.sale.stock.restrict |
|||
</field> |
|||
<field name="model">res.config.settings</field> |
|||
<field name="priority" eval="40"/> |
|||
<field name="inherit_id" ref="sale.res_config_settings_view_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//block[@id='connectors_setting_container']" |
|||
position="after"> |
|||
<block title="Product Restriction" id="stock_product_restriction"> |
|||
<setting help="Restrict the sale if the product is out of stock." |
|||
id="product_restriction"> |
|||
<field name="product_restriction"/> |
|||
<div class="content-group" |
|||
invisible="not product_restriction"> |
|||
<div class="row mt16" |
|||
id="out_of_stock_product_restriction"> |
|||
<label for="check_stock" class="col-lg-3"/> |
|||
<field name="check_stock"/> |
|||
</div> |
|||
</div> |
|||
</setting> |
|||
</block> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<odoo> |
|||
<!--View for fields in the sale order line.--> |
|||
<record id="view_order_form" model="ir.ui.view"> |
|||
<field name="name">sale.order.view.form.inherit.sale.stock.restrict</field> |
|||
<field name="model">sale.order</field> |
|||
<field name="inherit_id" ref="sale.view_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='order_line']/list//field[@name='product_uom_qty']" |
|||
position="after"> |
|||
<field name="qty_available"/> |
|||
<field name="forecast_quantity"/> |
|||
</xpath> |
|||
<xpath expr="//field[@name='payment_term_id']" |
|||
position="after"> |
|||
<field name="onhand_check" invisible="True"/> |
|||
<field name="forecast_check" invisible="True"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |