Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] Migration of module stock_picking_accounting_date #2196

Open
wants to merge 4 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions stock_picking_accounting_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
=============================
Stock Picking Accounting Date
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6ea5a26fe4d1c53faf75d943d99aa5f0f6aa708073ca5ada21895467c5f94c30
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/17.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-17-0/stock-logistics-warehouse-17-0-stock_picking_accounting_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=17.0
:alt: Try me on Runboat

|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 <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_picking_accounting_date%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
-------

* Quartile Limited
* Jarsa

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

- `Quartile <https://www.quartile.co>`__:

- Aung Ko Ko Lin

- `Jarsa <https://www.jarsa.com>`__:

- Alan Ramos

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/17.0/stock_picking_accounting_date>`_ 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_picking_accounting_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions stock_picking_accounting_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Quartile Limited
# Copyright 2023 Jarsa
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Stock Picking Accounting Date",
"version": "17.0.1.0.0",
"author": "Quartile Limited, Jarsa, 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,
}
41 changes: 41 additions & 0 deletions stock_picking_accounting_date/i18n/ja.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_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 "運送"
6 changes: 6 additions & 0 deletions stock_picking_accounting_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2023 Quartile Limited
# Copyright 2023 Jarsa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_picking
from . import stock_move
70 changes: 70 additions & 0 deletions stock_picking_accounting_date/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2023 Quartile Limited
# Copyright 2023 Jarsa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models
from odoo.tools import float_round


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()._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

def _get_price_unit(self):
"""Returns the unit price for the move"""
self.ensure_one()
if (
not self.origin_returned_move_id
and self.purchase_line_id
and self.product_id.id == self.purchase_line_id.product_id.id
):
price_unit_prec = self.env["decimal.precision"].precision_get(
"Product Price"
)
line = self.purchase_line_id
order = line.order_id
price_unit = line.price_unit
if line.taxes_id:
qty = line.product_qty or 1
price_unit = line.taxes_id.with_context(round=False).compute_all(
price_unit, currency=line.order_id.currency_id, quantity=qty
)["total_void"]
price_unit = float_round(
price_unit / qty, precision_digits=price_unit_prec
)
if line.product_uom.id != line.product_id.uom_id.id:
price_unit *= line.product_uom.factor / line.product_id.uom_id.factor
if (
order.currency_id != order.company_id.currency_id
and self.picking_id.accounting_date
):
return order.currency_id._convert(
price_unit,
order.company_id.currency_id,
order.company_id,
self.picking_id.accounting_date,
round=False,
)
return super()._get_price_unit()
26 changes: 26 additions & 0 deletions stock_picking_accounting_date/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Quartile Limited
# Copyright 2023 Jarsa
# 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(
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_without_package.with_company(
pick.company_id
).product_id.filtered(
lambda x: x.detailed_type == "product" and x.valuation == "real_time"
):
pick.show_accounting_date = True
3 changes: 3 additions & 0 deletions stock_picking_accounting_date/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions stock_picking_accounting_date/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Quartile](https://www.quartile.co):
- Aung Ko Ko Lin
- [Jarsa](https://www.jarsa.com):
- Alan Ramos
14 changes: 14 additions & 0 deletions stock_picking_accounting_date/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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.
Loading
Loading