From ebf73d298ff28f7c27ea9ad7bf71f7e5146268c7 Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Tue, 27 Dec 2022 10:42:41 +0630 Subject: [PATCH] [ADD] stock_picking_accounting_date --- .../odoo/addons/stock_picking_accounting_date | 1 + setup/stock_picking_accounting_date/setup.py | 6 + stock_picking_accounting_date/README.rst | 87 ++++ stock_picking_accounting_date/__init__.py | 1 + stock_picking_accounting_date/__manifest__.py | 15 + stock_picking_accounting_date/i18n/ja.po | 41 ++ .../models/__init__.py | 2 + .../models/stock_move.py | 31 ++ .../models/stock_picking.py | 24 + .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 13 + .../static/description/index.html | 427 ++++++++++++++++++ .../tests/__init__.py | 1 + .../test_stock_picking_accounting_date.py | 55 +++ .../views/stock_picking_views.xml | 27 ++ 15 files changed, 734 insertions(+) create mode 120000 setup/stock_picking_accounting_date/odoo/addons/stock_picking_accounting_date create mode 100644 setup/stock_picking_accounting_date/setup.py create mode 100644 stock_picking_accounting_date/README.rst create mode 100644 stock_picking_accounting_date/__init__.py create mode 100644 stock_picking_accounting_date/__manifest__.py create mode 100644 stock_picking_accounting_date/i18n/ja.po create mode 100644 stock_picking_accounting_date/models/__init__.py create mode 100644 stock_picking_accounting_date/models/stock_move.py create mode 100644 stock_picking_accounting_date/models/stock_picking.py create mode 100644 stock_picking_accounting_date/readme/CONTRIBUTORS.rst create mode 100644 stock_picking_accounting_date/readme/DESCRIPTION.rst create mode 100644 stock_picking_accounting_date/static/description/index.html create mode 100644 stock_picking_accounting_date/tests/__init__.py create mode 100644 stock_picking_accounting_date/tests/test_stock_picking_accounting_date.py create mode 100644 stock_picking_accounting_date/views/stock_picking_views.xml diff --git a/setup/stock_picking_accounting_date/odoo/addons/stock_picking_accounting_date b/setup/stock_picking_accounting_date/odoo/addons/stock_picking_accounting_date new file mode 120000 index 000000000000..6f32de4126ee --- /dev/null +++ b/setup/stock_picking_accounting_date/odoo/addons/stock_picking_accounting_date @@ -0,0 +1 @@ +../../../../stock_picking_accounting_date \ No newline at end of file diff --git a/setup/stock_picking_accounting_date/setup.py b/setup/stock_picking_accounting_date/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_picking_accounting_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_accounting_date/README.rst b/stock_picking_accounting_date/README.rst new file mode 100644 index 000000000000..db00482d5225 --- /dev/null +++ b/stock_picking_accounting_date/README.rst @@ -0,0 +1,87 @@ +============================= +Stock Picking Accounting Date +============================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fstock--logistics--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_picking_accounting_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_picking_accounting_date + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds accounting date in picking and pass the value to accounting date +of SVL's journal entry. + +Background +~~~~~~~~~~ + +When a user makes the transfer for the products with "real time" +inventory valuation, effective date in transfer couldn't be selected. + +And Accounting date for stock valuation journal entry will be the same with effective date. +So, for the users who want to specify each transfer's actual accounting date needs to reset to draft +manually and change acocunting date. This module intends to get rid of this +inconvenience by adding accounting date in transfer and pass to journal entry. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Quartile Limited + +Contributors +~~~~~~~~~~~~ + +* `Quartile `__: + + * Aung Ko Ko Lin + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_picking_accounting_date/__init__.py b/stock_picking_accounting_date/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/stock_picking_accounting_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_accounting_date/__manifest__.py b/stock_picking_accounting_date/__manifest__.py new file mode 100644 index 000000000000..4d9e6fb34cbe --- /dev/null +++ b/stock_picking_accounting_date/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Stock Picking Accounting Date", + "version": "16.0.1.0.0", + "author": "Quartile Limited, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Stock", + "license": "AGPL-3", + "depends": ["stock_account"], + "data": [ + "views/stock_picking_views.xml", + ], + "installable": True, +} diff --git a/stock_picking_accounting_date/i18n/ja.po b/stock_picking_accounting_date/i18n/ja.po new file mode 100644 index 000000000000..ad7120bfca67 --- /dev/null +++ b/stock_picking_accounting_date/i18n/ja.po @@ -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 "運送" diff --git a/stock_picking_accounting_date/models/__init__.py b/stock_picking_accounting_date/models/__init__.py new file mode 100644 index 000000000000..3c71fd1b863b --- /dev/null +++ b/stock_picking_accounting_date/models/__init__.py @@ -0,0 +1,2 @@ +from . import stock_picking +from . import stock_move diff --git a/stock_picking_accounting_date/models/stock_move.py b/stock_picking_accounting_date/models/stock_move.py new file mode 100644 index 000000000000..fcc9af9575da --- /dev/null +++ b/stock_picking_accounting_date/models/stock_move.py @@ -0,0 +1,31 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockMove(models.Model): + _inherit = "stock.move" + + 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, + ) + if self.picking_id.accounting_date: + am_vals.update({"date": self.picking_id.accounting_date}) + return am_vals diff --git a/stock_picking_accounting_date/models/stock_picking.py b/stock_picking_accounting_date/models/stock_picking.py new file mode 100644 index 000000000000..ef3ba9527136 --- /dev/null +++ b/stock_picking_accounting_date/models/stock_picking.py @@ -0,0 +1,24 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + accounting_date = fields.Date( + states={"done": [("readonly", True)], "cancel": [("readonly", True)]}, + help="Accounting date for stock valuation journal entry.", + ) + show_accounting_date = fields.Boolean(compute="_compute_show_accounting_date") + + def _compute_show_accounting_date(self): + for pick in self: + pick.show_accounting_date = False + if pick.picking_type_code not in ("incoming", "outgoing"): + continue + if pick.move_ids.with_company(pick.company_id).product_id.filtered( + lambda x: x.detailed_type == "product" and x.valuation == "real_time" + ): + pick.show_accounting_date = True diff --git a/stock_picking_accounting_date/readme/CONTRIBUTORS.rst b/stock_picking_accounting_date/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..cd4e44ca98b5 --- /dev/null +++ b/stock_picking_accounting_date/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Quartile `__: + + * Aung Ko Ko Lin diff --git a/stock_picking_accounting_date/readme/DESCRIPTION.rst b/stock_picking_accounting_date/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..0f18d08124f1 --- /dev/null +++ b/stock_picking_accounting_date/readme/DESCRIPTION.rst @@ -0,0 +1,13 @@ +This module adds accounting date in picking and pass the value to accounting date +of SVL's journal entry. + +Background +~~~~~~~~~~ + +When a user makes the transfer for the products with "real time" +inventory valuation, effective date in transfer couldn't be selected. + +And Accounting date for stock valuation journal entry will be the same with effective date. +So, for the users who want to specify each transfer's actual accounting date needs to reset to draft +manually and change acocunting date. This module intends to get rid of this +inconvenience by adding accounting date in transfer and pass to journal entry. diff --git a/stock_picking_accounting_date/static/description/index.html b/stock_picking_accounting_date/static/description/index.html new file mode 100644 index 000000000000..c2a348eba93f --- /dev/null +++ b/stock_picking_accounting_date/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Stock Picking Accounting Date + + + +
+

Stock Picking Accounting Date

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module adds accounting date in picking and pass the value to accounting date +of SVL’s journal entry.

+
+

Background

+

When a user makes the transfer for the products with “real time” +inventory valuation, effective date in transfer couldn’t be selected.

+

And Accounting date for stock valuation journal entry will be the same with effective date. +So, for the users who want to specify each transfer’s actual accounting date needs to reset to draft +manually and change acocunting date. This module intends to get rid of this +inconvenience by adding accounting date in transfer and pass to journal entry.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+ +
+
+

Authors

+
    +
  • Quartile Limited
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+ + diff --git a/stock_picking_accounting_date/tests/__init__.py b/stock_picking_accounting_date/tests/__init__.py new file mode 100644 index 000000000000..b94843c070f8 --- /dev/null +++ b/stock_picking_accounting_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_accounting_date diff --git a/stock_picking_accounting_date/tests/test_stock_picking_accounting_date.py b/stock_picking_accounting_date/tests/test_stock_picking_accounting_date.py new file mode 100644 index 000000000000..207a82dc9f25 --- /dev/null +++ b/stock_picking_accounting_date/tests/test_stock_picking_accounting_date.py @@ -0,0 +1,55 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import date, timedelta + +from odoo.addons.stock_account.tests.test_stockvaluation import TestStockValuation + + +class TestStockValuation(TestStockValuation): + def setUp(self): + super(TestStockValuation, self).setUp() + + def test_stock_picking_accounting_date(self): + self.product1.categ_id.property_cost_method = "fifo" + accounting_date = date.today() + timedelta(days=1) + receipt = self.env["stock.picking"].create( + { + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "partner_id": self.partner.id, + "picking_type_id": self.env.ref("stock.picking_type_in").id, + "accounting_date": accounting_date, + } + ) + + move = self.env["stock.move"].create( + { + "picking_id": receipt.id, + "name": "10 in", + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "product_id": self.product1.id, + "product_uom": self.uom_unit.id, + "product_uom_qty": 10.0, + "price_unit": 10, + "move_line_ids": [ + ( + 0, + 0, + { + "product_id": self.product1.id, + "location_id": self.supplier_location.id, + "location_dest_id": self.stock_location.id, + "product_uom_id": self.uom_unit.id, + "qty_done": 10.0, + }, + ) + ], + } + ) + move._action_confirm() + move._action_done() + self.assertEqual( + move.stock_valuation_layer_ids.account_move_id.date, accounting_date + ) diff --git a/stock_picking_accounting_date/views/stock_picking_views.xml b/stock_picking_accounting_date/views/stock_picking_views.xml new file mode 100644 index 000000000000..cbeaad9d0aae --- /dev/null +++ b/stock_picking_accounting_date/views/stock_picking_views.xml @@ -0,0 +1,27 @@ + + + + stock.picking.form + stock.picking + + + + + + + + + + stock.picking.tree + stock.picking + + + + + + + +