Skip to content

Commit

Permalink
Merge PR #1275 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by rousseldenis
  • Loading branch information
OCA-git-bot committed Apr 15, 2024
2 parents 8cd313c + c35f37c commit e538b6e
Show file tree
Hide file tree
Showing 19 changed files with 770 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_lot_is_archived/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
86 changes: 86 additions & 0 deletions stock_lot_is_archived/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
================================
Stock Production Lot Is Archived
================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/16.0/stock_production_lot_is_archived
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-16-0/product-attribute-16-0-stock_production_lot_is_archived
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/135/16.0
:alt: Try me on Runbot

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

This module allows to adds a field on lots that means a product is archived.
This differs from Odoo core 'active' attribute (see `stock_production_lot_active` module).
A cron is also provided to automatically archive lots when there is new one,
based on the expiration date.

**Table of contents**

.. contents::
:local:

Usage
=====

* Create some lots with different expiration dates
* Go To Settings > Technical > Automation > Scheduled Actions
* Run the 'Archive products lots (Is Archived)' one.
* Only one lot with the most recent expiration date should remain with
Is Archived field unticked.


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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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 <https://github.com/OCA/product-attribute/issues/new?body=module:%20stock_production_lot_is_archived%0Aversion:%2016.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
~~~~~~~

* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Denis Roussel <[email protected]>

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/product-attribute <https://github.com/OCA/product-attribute/tree/16.0/stock_production_lot_is_archived>`_ 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 stock_lot_is_archived/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models, wizards
18 changes: 18 additions & 0 deletions stock_lot_is_archived/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Lot Is Archived",
"summary": """
This module adds a simple property on Lots that means a lot is archived""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"depends": ["product_expiry", "stock"],
"data": [
"security/security.xml",
"views/stock_lot.xml",
"data/ir_cron.xml",
],
}
17 changes: 17 additions & 0 deletions stock_lot_is_archived/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<!-- Scheduler to archive lots -->
<record forcecreate="True" id="ir_cron_archive_lots" model="ir.cron">
<field name="name">Archive product lots (Is Archived)</field>
<field eval="False" name="active" />
<field name="doall" eval="False" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="model_id" ref="model_stock_lot_archive" />
<field name="code">model._archive_lots()</field>
<field name="state">code</field>
</record>

</odoo>
1 change: 1 addition & 0 deletions stock_lot_is_archived/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_lot
24 changes: 24 additions & 0 deletions stock_lot_is_archived/models/stock_lot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class StockLot(models.Model):

_inherit = "stock.lot"

is_archived = fields.Boolean(
default=False,
help="Check this if you want to say this lot is archived (not inactive)",
)
is_archived_editable = fields.Boolean(
compute="_compute_is_archived_editable",
)

@api.depends_context("uid")
def _compute_is_archived_editable(self):
if self.user_has_groups("stock.group_stock_manager"):
self.update({"is_archived_editable": True})
else:
self.update({"is_archived_editable": False})
1 change: 1 addition & 0 deletions stock_lot_is_archived/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Denis Roussel <[email protected]>
4 changes: 4 additions & 0 deletions stock_lot_is_archived/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module allows to adds a field on lots that means a product is archived.
This differs from Odoo core 'active' attribute (see `stock_production_lot_active` module).
A cron is also provided to automatically archive lots when there is new one,
based on the expiration date.
5 changes: 5 additions & 0 deletions stock_lot_is_archived/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* Create some lots with different expiration dates
* Go To Settings > Technical > Automation > Scheduled Actions
* Run the 'Archive products lots (Is Archived)' one.
* Only one lot with the most recent expiration date should remain with
Is Archived field unticked.
14 changes: 14 additions & 0 deletions stock_lot_is_archived/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 ACSONE SA/NV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.model.access" id="stock_lot_archive_access">
<field name="name">stock.lot.archive Access</field>
<field name="model_id" ref="stock_lot_is_archived.model_stock_lot_archive" />
<field name="group_id" ref="stock.group_stock_manager" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />
<field name="perm_unlink" eval="1" />
</record>
</odoo>
Binary file added stock_lot_is_archived/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 e538b6e

Please sign in to comment.