Skip to content

Commit

Permalink
[ADD] pos_lot_expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Jan 10, 2024
1 parent b9e1429 commit a2aa0eb
Show file tree
Hide file tree
Showing 15 changed files with 680 additions and 0 deletions.
80 changes: 80 additions & 0 deletions pos_lot_expiry/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
==============
Pos Lot Expiry
==============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fb1254ede511c375e1801f7b532b22cd07a533c94d3cac3d17c5d424357b4065
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/17.0/pos_lot_expiry
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_lot_expiry
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Evaluate expiry of product in order to check if we can deliver the
product

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_lot_expiry%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit
* INVITU

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

- Dixmit

- Enric Tobella

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/17.0/pos_lot_expiry>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions pos_lot_expiry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions pos_lot_expiry/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 Dixmit
# Copyright 2024 INVITU
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Pos Lot Expiry",
"summary": """
Evaluate expiry of lot""",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,INVITU,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"depends": ["point_of_sale", "product_expiry"],
"assets": {
"point_of_sale._assets_pos": [
"pos_lot_expiry/static/src/js/**/*.js",
],
},
"data": [
"views/res_config_settings_views.xml",
],
}
4 changes: 4 additions & 0 deletions pos_lot_expiry/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import pos_session
from . import product_product
from . import pos_config
from . import res_config_settings
10 changes: 10 additions & 0 deletions pos_lot_expiry/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class PosConfig(models.Model):
_inherit = "pos.config"

check_lot_expiry = fields.Boolean(default=True)
13 changes: 13 additions & 0 deletions pos_lot_expiry/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class PosSession(models.Model):
_inherit = "pos.session"

def _loader_params_product_product(self):
result = super()._loader_params_product_product()
result["search_params"]["fields"].append("use_expiration_date")
return result

Check warning on line 13 in pos_lot_expiry/models/pos_session.py

View check run for this annotation

Codecov / codecov/patch

pos_lot_expiry/models/pos_session.py#L11-L13

Added lines #L11 - L13 were not covered by tests
32 changes: 32 additions & 0 deletions pos_lot_expiry/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, fields, models


class ProductProduct(models.Model):
_inherit = "product.product"

def check_pos_lots(self, lots, company_id):
self.ensure_one()
found_lots = (

Check warning on line 12 in pos_lot_expiry/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

pos_lot_expiry/models/product_product.py#L11-L12

Added lines #L11 - L12 were not covered by tests
self.env["stock.lot"]
.sudo()
.search(
[
("product_id", "=", self.id),
("name", "in", lots),
"|",
("company_id", "=", company_id),
("company_id", "=", False),
]
)
)
if len(lots) > len(found_lots):
return _("Some lots couldn't be found")
now = fields.Datetime.now()

Check warning on line 27 in pos_lot_expiry/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

pos_lot_expiry/models/product_product.py#L26-L27

Added lines #L26 - L27 were not covered by tests
if found_lots.filtered(lambda r: r.expiration_date and r.expiration_date < now):
return _(

Check warning on line 29 in pos_lot_expiry/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

pos_lot_expiry/models/product_product.py#L29

Added line #L29 was not covered by tests
"Some lots are expired and you are not enabled to sell expired lots"
)
return False

Check warning on line 32 in pos_lot_expiry/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

pos_lot_expiry/models/product_product.py#L32

Added line #L32 was not covered by tests
12 changes: 12 additions & 0 deletions pos_lot_expiry/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

pos_check_lot_expiry = fields.Boolean(
related="pos_config_id.check_lot_expiry", readonly=False
)
3 changes: 3 additions & 0 deletions pos_lot_expiry/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions pos_lot_expiry/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Dixmit
- Enric Tobella
1 change: 1 addition & 0 deletions pos_lot_expiry/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Evaluate expiry of product in order to check if we can deliver the product
Binary file added pos_lot_expiry/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.
Loading

0 comments on commit a2aa0eb

Please sign in to comment.