Skip to content

Commit

Permalink
[16.0][ADD] stock_orderpoint_first_dates: In Invetory - Operations - …
Browse files Browse the repository at this point in the history
…Replenishment, new fields "First Reception Date", and "First Shipping Date".
  • Loading branch information
alfredoavanzosc committed Dec 9, 2024
1 parent 4575dd8 commit ee09d68
Show file tree
Hide file tree
Showing 14 changed files with 333 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_orderpoint_first_dates/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,
)
29 changes: 29 additions & 0 deletions stock_orderpoint_first_dates/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

============================
Stock orderpoint first dates
============================

* In Invetory - Operations - Replenishment, new fields "First Reception Date",
and "First Shipping Date".

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

Bugs are tracked on `GitHub Issues
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble,
please check there if your issue has already been reported. If you spotted
it first, help us smash it by providing detailed and welcomed feedback.

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

Credits
=======

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

* Ana Juaristi <anajuaristi@avanzosc.es>
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
1 change: 1 addition & 0 deletions stock_orderpoint_first_dates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions stock_orderpoint_first_dates/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Stock Orderpoint First Dates",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Avanzosc",
"category": "Inventory/Inventory",
"website": "https://github.com/avanzosc/odoo-addons",
"depends": ["stock"],
"data": [
"views/stock_warehouse_orderpoint_views.xml",
],
"installable": True,
}
41 changes: 41 additions & 0 deletions stock_orderpoint_first_dates/i18n/ca_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_first_dates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-07 07:02+0000\n"
"PO-Revision-Date: 2024-10-07 07:02+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour
msgid "Date Deadline Without Hour"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date
msgid "First Reception Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date
msgid "First Shipping Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr "Regla d'inventari mínim"

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move
msgid "Stock Move"
msgstr "Moviment d'estoc"
41 changes: 41 additions & 0 deletions stock_orderpoint_first_dates/i18n/en_GB.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_first_dates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-07 07:03+0000\n"
"PO-Revision-Date: 2024-10-07 07:03+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour
msgid "Date Deadline Without Hour"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date
msgid "First Reception Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date
msgid "First Shipping Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move
msgid "Stock Move"
msgstr ""
41 changes: 41 additions & 0 deletions stock_orderpoint_first_dates/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_first_dates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-07 07:03+0000\n"
"PO-Revision-Date: 2024-10-07 07:03+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour
msgid "Date Deadline Without Hour"
msgstr "Fecha límite sin hora"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date
msgid "First Reception Date"
msgstr "Fecha primera recepción"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date
msgid "First Shipping Date"
msgstr "Fecha primer envío"

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr "Regla de inventario mínimo"

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"
41 changes: 41 additions & 0 deletions stock_orderpoint_first_dates/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_first_dates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-07 07:03+0000\n"
"PO-Revision-Date: 2024-10-07 07:03+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour
msgid "Date Deadline Without Hour"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date
msgid "First Reception Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date
msgid "First Shipping Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr "Règle de stock minimum"

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move
msgid "Stock Move"
msgstr "Mouvement de stock"
41 changes: 41 additions & 0 deletions stock_orderpoint_first_dates/i18n/stock_orderpoint_first_dates.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_orderpoint_first_dates
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-07 07:02+0000\n"
"PO-Revision-Date: 2024-10-07 07:02+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_move__date_deadline_without_hour
msgid "Date Deadline Without Hour"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_reception_date
msgid "First Reception Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model.fields,field_description:stock_orderpoint_first_dates.field_stock_warehouse_orderpoint__first_shipping_date
msgid "First Shipping Date"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_warehouse_orderpoint
msgid "Minimum Inventory Rule"
msgstr ""

#. module: stock_orderpoint_first_dates
#: model:ir.model,name:stock_orderpoint_first_dates.model_stock_move
msgid "Stock Move"
msgstr ""
2 changes: 2 additions & 0 deletions stock_orderpoint_first_dates/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move
from . import stock_warehouse_orderpoint
26 changes: 26 additions & 0 deletions stock_orderpoint_first_dates/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import pytz

from odoo import api, fields, models


class StockMove(models.Model):
_inherit = "stock.move"

date_deadline_without_hour = fields.Date(
compute="_compute_date_deadline_without_hour",
store=True,
copy=False,
)

@api.depends("date_deadline")
def _compute_date_deadline_without_hour(self):
for move in self:
date_deadline_without_hour = False
if move.date_deadline:
local_dt = move.date_deadline.astimezone(
pytz.timezone(self.env.user.tz or "UTC")
)
date_deadline_without_hour = local_dt.date()
self.date_deadline_without_hour = date_deadline_without_hour
35 changes: 35 additions & 0 deletions stock_orderpoint_first_dates/models/stock_warehouse_orderpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Alfredo de la Fuente - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models


class StockWarehouseOrderpoint(models.Model):
_inherit = "stock.warehouse.orderpoint"

first_reception_date = fields.Date(compute="_compute_first_reception_shipping_date")
first_shipping_date = fields.Date(compute="_compute_first_reception_shipping_date")

def _compute_first_reception_shipping_date(self):
for orderpoint in self:
first_reception_date = False
first_shipping_date = False
moves = orderpoint.product_id.stock_move_ids.filtered(
lambda x: x.location_dest_id == orderpoint.location_id
and x.location_id.usage != "internal"
and x.date_deadline_without_hour
and x.date_deadline_without_hour > fields.Date.context_today(self)
and x.state not in ("draft", "cancel", "done")
)
if moves:
first_reception_date = min(moves.mapped("date_deadline_without_hour"))
moves = orderpoint.product_id.stock_move_ids.filtered(
lambda x: x.location_id == orderpoint.location_id
and x.location_dest_id.usage != "internal"
and x.date_deadline_without_hour
and x.date_deadline_without_hour > fields.Date.context_today(self)
and x.state not in ("draft", "cancel", "done")
)
if moves:
first_shipping_date = min(moves.mapped("date_deadline_without_hour"))
orderpoint.first_reception_date = first_reception_date
orderpoint.first_shipping_date = first_shipping_date
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_warehouse_orderpoint_tree_editable" model="ir.ui.view">
<field name="model">stock.warehouse.orderpoint</field>
<field name="inherit_id" ref="stock.view_warehouse_orderpoint_tree_editable" />
<field name="arch" type="xml">
<field name="location_id" position="after">
<field name="first_reception_date" optional="show" readonly="1" />
<field name="first_shipping_date" optional="show" readonly="1" />
</field>
</field>
</record>
</odoo>

0 comments on commit ee09d68

Please sign in to comment.