Skip to content

Commit

Permalink
[ADD] product_expiry_ux: create module.
Browse files Browse the repository at this point in the history
X-original-commit: ecc7acc
  • Loading branch information
vib-adhoc committed Mar 23, 2023
1 parent e2fac66 commit aa42adf
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
73 changes: 73 additions & 0 deletions product_expiry_ux/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=================
Product Expiry Ux
=================

Change lots expiration tags.

#. "Expired" according to expiration date

#. "Expiration Alert" according to alert date

Installation
============

To install this module, you need to:

#. Just install module.

Configuration
=============

To configure this module, you need to:

#. No configuration needed.

Usage
=====

To use this module, you need to:


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/ingadhoc/product/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
------

* |company| |icon|

Contributors
------------

Maintainer
----------

|company_logo|

This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.
1 change: 1 addition & 0 deletions product_expiry_ux/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions product_expiry_ux/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
'name': 'Products Expiration Date UX',
'version': '15.0.1.0.0',
'category': 'Inventory/Inventory',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'depends': ['product_expiry'],
'data': ['views/production_lot_views.xml'],
'demo': [],
'license': 'AGPL-3',
'installable': False,
'auto_install': True,
'application': False,
}
1 change: 1 addition & 0 deletions product_expiry_ux/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import production_lot
16 changes: 16 additions & 0 deletions product_expiry_ux/models/production_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import api, fields, models
from odoo.tools import float_compare

class StockProductionLot(models.Model):
_inherit = 'stock.production.lot'

is_alert_date = fields.Boolean(compute='_compute_is_alert_date', help="The Alert Date has been reached")

@api.depends('alert_date')
def _compute_is_alert_date(self):
current_date = fields.Datetime.now()
for lot in self:
if lot.alert_date:
lot.is_alert_date = (lot.alert_date <= current_date)
else:
lot.is_alert_date = False
17 changes: 17 additions & 0 deletions product_expiry_ux/views/production_lot_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding='UTF-8'?>
<odoo>
<record id="view_move_form_expiry_ux" model="ir.ui.view">
<field name="name">stock.production.lot.inherit.form.ux</field>
<field name="model">stock.production.lot</field>
<field name="inherit_id" ref="product_expiry.view_move_form_expiry" />
<field name="arch" type="xml">
<xpath expr="//span[hasclass('badge-danger')]" position="replace">
<span class="badge badge-danger" attrs="{'invisible': [('product_expiry_alert', '=', False)]}">Expired</span>
</xpath>
<xpath expr="//span[hasclass('badge-danger')]" position="after">
<field name="is_alert_date" invisible="1"/>
<span class="badge badge-warning" attrs="{'invisible': [('is_alert_date', '=', False)]}">Expiration Alert</span>
</xpath>
</field>
</record>
</odoo>

0 comments on commit aa42adf

Please sign in to comment.