-
-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81e6588
commit 8c33664
Showing
26 changed files
with
1,114 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/stock_move_actual_date/odoo/addons/stock_move_actual_date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_move_actual_date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
====================== | ||
Stock Move Actual Date | ||
====================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:d70c1f46222bd6a5f01ae300908138b08df6c418a5dc4eb01168cd345ba95e59 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fstock--logistics--warehouse-lightgray.png?logo=github | ||
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_move_actual_date | ||
:alt: OCA/stock-logistics-warehouse | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_move_actual_date | ||
: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/stock-logistics-warehouse&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module adds an Actual Date field to the stock picking, stock scrap, stock move, and stock move line models. This field allows users to record the actual date on which a stock transfer or stock scrap took place, in case the transaction in Odoo is processed after the fact. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Use this module's function in the following situations: | ||
|
||
* If you are late in processing a transfer or scrap in Odoo and wish to record the transaction with the actual transfer date, fill in the Actual Date field in the picking or scrap form. The Actual Date of the picking or scrap is then propagated to its corresponding stock moves and stock move lines, and is also passed to the journal entry as the date. | ||
* You can also update the Actual Date of a completed picking or scrap if you belong to the Inventory Manager group. This operation updates the date of the related journal entries, re-proposing a new sequence to them as necessary. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
Updating the Actual Date of a completed receipt picking for a foreign currency purchase does not trigger a recalculation of the amounts in the associated journal entries, even if the currency rate for the new date differs. | ||
|
||
For the Actual Date of existing stock move and stock move line records created before this module was installed, the user's timezone will not be considered, and only the date part from the 'date' field in the UTC timezone will be assigned. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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/stock-logistics-warehouse/issues/new?body=module:%20stock_move_actual_date%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 | ||
~~~~~~~ | ||
|
||
* Quartile | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Quartile <https://www.quartile.co>`__: | ||
|
||
* Aung Ko Ko Lin | ||
* Yoshi Tashiro | ||
|
||
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/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_move_actual_date>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from .hooks import pre_init_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Stock Move Actual Date", | ||
"version": "16.0.1.0.0", | ||
"author": "Quartile, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/stock-logistics-warehouse", | ||
"category": "Stock", | ||
"license": "AGPL-3", | ||
"depends": ["stock_account"], | ||
"data": [ | ||
"views/stock_move_line_views.xml", | ||
"views/stock_move_views.xml", | ||
"views/stock_picking_views.xml", | ||
"views/stock_scrap_views.xml", | ||
], | ||
"pre_init_hook": "pre_init_hook", | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
def pre_init_hook(cr): | ||
cr.execute( | ||
""" | ||
ALTER TABLE stock_move | ||
ADD COLUMN actual_date DATE; | ||
UPDATE stock_move | ||
SET actual_date = DATE(date); | ||
""" | ||
) | ||
cr.execute( | ||
""" | ||
ALTER TABLE stock_move_line | ||
ADD COLUMN actual_date DATE; | ||
UPDATE stock_move_line | ||
SET actual_date = DATE(date); | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_picking_accounting_date | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2023-05-18 04:34+0000\n" | ||
"PO-Revision-Date: 2023-05-18 04:34+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_picking_accounting_date | ||
#: model:ir.model.fields,field_description:stock_picking_accounting_date.field_stock_picking__accounting_date | ||
msgid "Accounting Date" | ||
msgstr "会計日" | ||
|
||
#. module: stock_picking_accounting_date | ||
#: model:ir.model.fields,help:stock_picking_accounting_date.field_stock_picking__accounting_date | ||
msgid "Accounting date for stock valuation journal entry." | ||
msgstr "在庫評価仕訳の会計日" | ||
|
||
#. module: stock_picking_accounting_date | ||
#: model:ir.model.fields,field_description:stock_picking_accounting_date.field_stock_picking__show_accounting_date | ||
msgid "Show Accounting Date" | ||
msgstr "会計日を表示" | ||
|
||
#. module: stock_picking_accounting_date | ||
#: model:ir.model,name:stock_picking_accounting_date.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "在庫移動" | ||
|
||
#. module: stock_picking_accounting_date | ||
#: model:ir.model,name:stock_picking_accounting_date.model_stock_picking | ||
msgid "Transfer" | ||
msgstr "運送" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from . import account_move | ||
from . import actual_date_mixin | ||
from . import res_currency | ||
from . import stock_move | ||
from . import stock_move_line | ||
from . import stock_picking | ||
from . import stock_scrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
def _must_check_constrains_date_sequence(self): | ||
if self.env.context.get("skip_date_sequence_check"): | ||
return False | ||
return super()._must_check_constrains_date_sequence() | ||
|
||
def _update_accounting_date(self): | ||
self.button_draft() | ||
for move in self: | ||
move = move.with_context(skip_date_sequence_check=True) | ||
move.date = move.stock_move_id.actual_date | ||
if not move._sequence_matches_date(): | ||
move.name = False | ||
self.action_post() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ActualDateMixin(models.AbstractModel): | ||
_name = "actual.date.mixin" | ||
|
||
actual_date = fields.Date( | ||
tracking=True, | ||
help="If set, the value is propagated " | ||
"to the related journal entries as the date.", | ||
) | ||
is_editable_actual_date = fields.Boolean( | ||
compute="_compute_is_editable_actual_date", string="Is Editable" | ||
) | ||
|
||
def _compute_is_editable_actual_date(self): | ||
for rec in self: | ||
rec.is_editable_actual_date = False | ||
if rec.state not in ["done", "cancel"] or self.env.user.has_group( | ||
"stock.group_stock_manager" | ||
): | ||
rec.is_editable_actual_date = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class ResCurrency(models.Model): | ||
_inherit = "res.currency" | ||
|
||
def _convert(self, from_amount, to_currency, company, date, round=True): | ||
date = self.env.context.get("actual_date") or date | ||
return super()._convert(from_amount, to_currency, company, date, round) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
actual_date = fields.Date( | ||
compute="_compute_actual_date", | ||
store=True, | ||
) | ||
|
||
def _get_timezone(self): | ||
return self.env.context.get("tz") or self.env.user.tz or "UTC" | ||
|
||
@api.depends("date", "picking_id.actual_date", "scrap_ids.actual_date") | ||
def _compute_actual_date(self): | ||
tz = self._get_timezone() | ||
for rec in self: | ||
actual_date = ( | ||
self.env.context.get("actual_date") or rec.scrap_ids.actual_date | ||
) | ||
if actual_date: | ||
rec.actual_date = actual_date | ||
continue | ||
if not rec.scrapped and rec.picking_id.actual_date: | ||
rec.actual_date = rec.picking_id.actual_date | ||
continue | ||
rec.actual_date = fields.Date.context_today( | ||
self.with_context(tz=tz), rec.date | ||
) | ||
|
||
def _prepare_account_move_vals( | ||
self, | ||
credit_account_id, | ||
debit_account_id, | ||
journal_id, | ||
qty, | ||
description, | ||
svl_id, | ||
cost, | ||
): | ||
am_vals = super(StockMove, self)._prepare_account_move_vals( | ||
credit_account_id, | ||
debit_account_id, | ||
journal_id, | ||
qty, | ||
description, | ||
svl_id, | ||
cost, | ||
) | ||
# i.e. Inventory adjustments with actual date | ||
if self._context.get("force_period_date"): | ||
self.write({"actual_date": self._context["force_period_date"]}) | ||
return am_vals | ||
if self.actual_date: | ||
am_vals.update({"date": self.actual_date}) | ||
return am_vals | ||
|
||
def _get_price_unit(self): | ||
"""Passes the actual_date to be used in currency conversion for receipts | ||
in foreign currency purchases. | ||
""" | ||
self.ensure_one() | ||
self = self.with_context(actual_date=self.actual_date) | ||
return super()._get_price_unit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import fields, models | ||
|
||
|
||
class StockMoveLine(models.Model): | ||
_inherit = "stock.move.line" | ||
|
||
actual_date = fields.Date(related="move_id.actual_date", store=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class StockPicking(models.Model): | ||
_name = "stock.picking" | ||
_inherit = ["stock.picking", "actual.date.mixin"] | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
if "actual_date" in vals: | ||
for rec in self: | ||
if rec.state != "done": | ||
continue | ||
account_moves = rec.move_ids.account_move_ids | ||
if not account_moves: | ||
continue | ||
account_moves._update_accounting_date() | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2024 Quartile (https://www.quartile.co) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class StockScrap(models.Model): | ||
_name = "stock.scrap" | ||
_inherit = ["stock.scrap", "actual.date.mixin"] | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
if "actual_date" in vals: | ||
for rec in self: | ||
if rec.state != "done": | ||
continue | ||
account_moves = rec.move_id.account_move_ids | ||
if not account_moves: | ||
continue | ||
account_moves._update_accounting_date() | ||
return res | ||
|
||
def do_scrap(self): | ||
"""Passes the actual_date as context to be used in _compute_actual_date() | ||
of stock move. | ||
""" | ||
for scrap in self: | ||
scrap = scrap.with_context(actual_date=scrap.actual_date) | ||
super(StockScrap, scrap).do_scrap() | ||
return True |
Oops, something went wrong.