Browse Source

May 30: [FIX] Bug Fixed 'low_stocks_product_alert'

pull/320/head
RisvanaCybro 11 months ago
parent
commit
0925dfde4b
  1. 19
      low_stocks_product_alert/models/product_product.py
  2. 6
      low_stocks_product_alert/models/product_template.py
  3. 21
      low_stocks_product_alert/models/res_config_settings.py
  4. BIN
      low_stocks_product_alert/static/description/assets/screenshots/1.png
  5. BIN
      low_stocks_product_alert/static/description/assets/screenshots/2.png
  6. BIN
      low_stocks_product_alert/static/description/assets/screenshots/3.png
  7. BIN
      low_stocks_product_alert/static/description/assets/screenshots/4.png
  8. BIN
      low_stocks_product_alert/static/description/assets/screenshots/5.png
  9. BIN
      low_stocks_product_alert/static/description/assets/screenshots/hero.gif
  10. BIN
      low_stocks_product_alert/static/description/assets/screenshots/low-stock-product-alert-v16-gif.gif
  11. BIN
      low_stocks_product_alert/static/description/assets/screenshots/lows1.png
  12. BIN
      low_stocks_product_alert/static/description/assets/screenshots/lows2.png
  13. BIN
      low_stocks_product_alert/static/description/assets/screenshots/lows3.png
  14. BIN
      low_stocks_product_alert/static/description/assets/screenshots/lows4.png
  15. BIN
      low_stocks_product_alert/static/description/assets/screenshots/lows5.png
  16. BIN
      low_stocks_product_alert/static/description/assets/screenshots/lows6.png
  17. 1092
      low_stocks_product_alert/static/description/index.html
  18. 11
      low_stocks_product_alert/views/product_product_views.xml
  19. 13
      low_stocks_product_alert/views/res_config_settings_views.xml

19
low_stocks_product_alert/models/product_product.py

@ -36,7 +36,18 @@ class ProductProduct(models.Model):
alert_tag = fields.Char(
string='Product Alert Tag', compute='_compute_alert_tag',
help='This field represents the alert tag of the product.')
help='This field represents the alert tag of the product.', store=True)
is_low_stock_alert = fields.Boolean(
string="Low Stock Alert",
help='This field determines the minimum stock quantity at which a low '
'stock alert will be triggered.When the product quantity falls '
'below this value, the background color for the product will be '
'changed based on the alert state.',
)
min_low_stock_alert = fields.Integer(
string='Alert Quantity',
help='Change the background color for the product based'
'on the Alert Quant.')
@api.depends('qty_available')
def _compute_alert_tag(self):
@ -49,3 +60,9 @@ class ProductProduct(models.Model):
self.env['ir.config_parameter'].sudo().get_param(
'low_stocks_product_alert.min_low_stock_alert'))
rec.alert_tag = rec.qty_available if is_low_stock else False
elif self.env['ir.config_parameter'].sudo().get_param(
'low_stocks_product_alert.is_low_stock_alert_individual'):
for rec in self:
is_low_stock_single = rec.detailed_type == 'product' and rec.qty_available <= int(
rec.min_low_stock_alert)
rec.alert_tag = rec.qty_available if is_low_stock_single else False

6
low_stocks_product_alert/models/product_template.py

@ -56,6 +56,12 @@ class ProductTemplate(models.Model):
self.env['ir.config_parameter'].sudo().get_param(
'low_stocks_product_alert.min_low_stock_alert')) \
else (True, '#fdc6c673')
elif self.env['ir.config_parameter'].sudo().get_param(
'low_stocks_product_alert.is_low_stock_alert_individual') and self.filtered(lambda x: x.product_variant_id.is_low_stock_alert):
for rec in self:
rec.alert_state, rec.color_field = (False, 'white') if \
rec.detailed_type != 'product' or rec.qty_available > int(rec.product_variant_id.min_low_stock_alert) \
else (True, '#fdc6c673')
else:
self.alert_state = False
self.color_field = 'white'

21
low_stocks_product_alert/models/res_config_settings.py

@ -19,7 +19,7 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import fields, models
from odoo import api, fields, models
class ResConfig(models.TransientModel):
@ -32,14 +32,31 @@ class ResConfig(models.TransientModel):
_inherit = 'res.config.settings'
is_low_stock_alert = fields.Boolean(
string="Low Stock Alert",
string="Low Stock Alert For All Products",
help='This field determines the minimum stock quantity at which a low '
'stock alert will be triggered.When the product quantity falls '
'below this value, the background color for the product will be '
'changed based on the alert state.',
config_parameter='low_stocks_product_alert.is_low_stock_alert')
is_low_stock_alert_individual = fields.Boolean(
string="Low Stock Alert For Individual Product",
help='This field determines the minimum stock quantity at which a low '
'stock alert will be triggered.When the product quantity falls '
'below this value, the background color for the product will be '
'changed based on the alert state.',
config_parameter='low_stocks_product_alert.is_low_stock_alert_individual',
default=False)
min_low_stock_alert = fields.Integer(
string='Alert Quantity', default=0,
help='Change the background color for the product based'
'on the Alert Quant.',
config_parameter='low_stocks_product_alert.min_low_stock_alert')
@api.onchange('is_low_stock_alert_individual')
def _onchange_is_low_stock_alert_individual(self):
"""The function is used to change the stock alert in the product form"""
if self.env['ir.config_parameter'].sudo().get_param(
'low_stocks_product_alert.is_low_stock_alert_individual'):
product_variants = self.env['product.product'].search([])
for rec in product_variants:
rec.is_low_stock_alert = True

BIN
low_stocks_product_alert/static/description/assets/screenshots/1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/hero.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/low-stock-product-alert-v16-gif.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/lows1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/lows2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/lows3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/lows4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/lows5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

BIN
low_stocks_product_alert/static/description/assets/screenshots/lows6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

1092
low_stocks_product_alert/static/description/index.html

File diff suppressed because it is too large

11
low_stocks_product_alert/views/product_product_views.xml

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!--Inherit product.product view form to add field-->
<!--Inherit product.product view form to add field-->
<record id="product_normal_form_view" model="ir.ui.view">
<field name="name">product.product.view.form.inherit.low.stocks.product.alert</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="pos_categ_id" position="after">
<field name="alert_tag" />
<field name="alert_tag"/>
</field>
<xpath expr="//group[@name='group_lots_and_weight']"
position="inside">
<field name="is_low_stock_alert" invisible="1"/>
<field name="min_low_stock_alert" attrs="{'invisible':[('is_low_stock_alert','=', False)]}"/>
</xpath>
</field>
</record>
</odoo>

13
low_stocks_product_alert/views/res_config_settings_views.xml

@ -15,8 +15,8 @@
<field name="is_low_stock_alert"/>
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Low Stock Alert</span>
<div class="text-muted">Quantity for Low Stock Alert
<span class="o_form_label">Low Stock Alert For All Products</span>
<div class="text-muted">To set Alert for all products
</div>
<div class="row mt-16"
attrs="{'invisible': [('is_low_stock_alert', '=', False)]}">
@ -26,6 +26,15 @@
class="oe_inline"/>
</div>
</div>
<br/>
<div class="o_setting_left_pane">
<field name="is_low_stock_alert_individual"/>
</div>
<div class="o_setting_right_pane">
<span class="o_form_label">Low Stock Alert For Individual Products</span>
<div class="text-muted">To set Alert for individual product
</div>
</div>
</div>
</xpath>
</field>

Loading…
Cancel
Save