Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
18ce9b9
Added stock_account OU module
serpentcs-dev1 Jan 18, 2016
bd71a8e
[MIG] stock_account_operating_unit: Migration to 10.0
AaronHForgeFlow May 26, 2017
c7484a2
[MIG] stock_account_operating_unit: Migration to v12
bjeficent Feb 8, 2019
5825441
[UPD] Update stock_account_operating_unit.pot
oca-travis Nov 28, 2019
9528178
[UPD] README.rst
OCA-git-bot Nov 28, 2019
03850ea
[ADD] icon.png
OCA-git-bot Nov 28, 2019
2093917
[IMP] stock_account_operating_unit: black, isort
alan196 Feb 13, 2020
6c9b227
[MIG] stock_account_operating_unit: Migration to V13
alan196 Feb 13, 2020
5c8a6d5
[UPD] Update stock_account_operating_unit.pot
oca-travis Dec 28, 2021
24e598c
[UPD] README.rst
OCA-git-bot Dec 28, 2021
ed56388
Added translation using Weblate (Spanish)
javierjcf Mar 14, 2022
3fdcf8c
Translated using Weblate (Spanish)
javierjcf Mar 14, 2022
c839675
[15.0][MIG] stock_account_operating_unit: Migration to 15.0
Jun 17, 2022
9c974bc
[15.0][MIG] stock_account_operating_unit: Migration to 15.0
Jun 21, 2022
a674a7f
[UPD] Update stock_account_operating_unit.pot
Feb 13, 2023
5d98f40
[UPD] README.rst
OCA-git-bot Feb 13, 2023
b014eb9
[UPD] README.rst
OCA-git-bot Sep 3, 2023
3f3e623
[REM] stock_account_operating_unit: remove tes-requirements.txt file …
alan196 May 9, 2024
929fe97
[IMP] stock_account_operating_unite: pre-commit auto fixes
AtaponDew May 19, 2025
630d914
[MIG] stock_account_operating_unit: Migration to 18.0
AtaponDew May 19, 2025
9b16e57
[FIX] stock_account_operating_unit: Add missing parameter in _generat…
AtaponDew Jun 11, 2025
3e5e688
[FIX] stock_account_operating_unit: Fix codes and unit test
AtaponDew Aug 15, 2025
f481086
[FIX] stock_account_operating_unit: Fix code compativle with pre-commit
AtaponDew Aug 15, 2025
83b3e4e
[FIX] stock_account_operating_unit: Fix code too long and structure
AtaponDew Aug 15, 2025
f8a75c6
[FIX] stock_account_operating_unit: Fix test
AtaponDew Aug 15, 2025
10f331e
[FIX] stock_account_operating_unit: Fix setupClass in test
AtaponDew Aug 15, 2025
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
89 changes: 89 additions & 0 deletions stock_account_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
=======================================
Stock account moves with Operating Unit
=======================================

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

.. |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-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/18.0/stock_account_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-stock_account_operating_unit
: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/operating-unit&target_branch=18.0
:alt: Try me on Runboat

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

This module introduces the following features:

- Creates account move lines when stock moves are posted between
internal locations within the same company, but different OU’s.

**Table of contents**

.. contents::
:local:

Usage
=====

Create stock moves between internal locations within the same company,
but different OU’s. The journal entries are created and they are
self-balanced within the OU when the journal entries are posted

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20stock_account_operating_unit%0Aversion:%2018.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
-------

* Eficent Business and IT Consulting Services S.L.
* Serpent Consulting Services Pvt. Ltd.

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

- Eficent Business and IT Consulting Services S.L. <contact@eficent.com>
- Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
- Jarsa Sistemas <info@jarsa.com.mx>

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/operating-unit <https://github.com/OCA/operating-unit/tree/18.0/stock_account_operating_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions stock_account_operating_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import model
23 changes: 23 additions & 0 deletions stock_account_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# © 2019 Eficent Business and IT Consulting Services S.L.
# - Jordi Ballester Alomar
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
"name": "Stock account moves with Operating Unit",
"summary": "Create journal entries in moves between internal locations "
"with different operating units.",
"version": "18.0.1.0.0",
"category": "Generic Modules/Sales & Purchases",
"author": "Eficent Business and IT Consulting Services S.L., "
"Serpent Consulting Services Pvt. Ltd.,"
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/operating-unit",
"depends": [
"stock_operating_unit",
"account_operating_unit",
"stock_account",
],
"installable": True,
}
38 changes: 38 additions & 0 deletions stock_account_operating_unit/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_account_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-03-14 11:17+0000\n"
"Last-Translator: Javier Colmenero <javierjcf@gmail.com>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: stock_account_operating_unit
#: code:addons/stock_account_operating_unit/model/stock_move.py:0
#, python-format
msgid "%s - OU Move"
msgstr "%s - movimiento unidad operacional"

#. module: stock_account_operating_unit
#: model:ir.model,name:stock_account_operating_unit.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de stock"

#. module: stock_account_operating_unit
#: code:addons/stock_account_operating_unit/model/stock_move.py:0
#, python-format
msgid ""
"You cannot create stock moves involving separate source and destination "
"accounts related to different operating units."
msgstr ""
"No puedes crear movimientos de stock, involucrando distintos orígines y "
"destinos asociados a unidades operacionales diferentes."
33 changes: 33 additions & 0 deletions stock_account_operating_unit/i18n/stock_account_operating_unit.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_account_operating_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \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_account_operating_unit
#: code:addons/stock_account_operating_unit/model/stock_move.py:0
#, python-format
msgid "%s - OU Move"
msgstr ""

#. module: stock_account_operating_unit
#: model:ir.model,name:stock_account_operating_unit.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: stock_account_operating_unit
#: code:addons/stock_account_operating_unit/model/stock_move.py:0
#, python-format
msgid ""
"You cannot create stock moves involving separate source and destination "
"accounts related to different operating units."
msgstr ""
2 changes: 2 additions & 0 deletions stock_account_operating_unit/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import stock_move
124 changes: 124 additions & 0 deletions stock_account_operating_unit/model/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# © 2019 Eficent Business and IT Consulting Services S.L.
# - Jordi Ballester Alomar
# © 2019 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import exceptions, models


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

def _generate_valuation_lines_data(
self,
partner_id,
qty,
debit_value,
credit_value,
debit_account_id,
credit_account_id,
svl_id,
description,
):
res = super()._generate_valuation_lines_data(
partner_id,
qty,
debit_value,
credit_value,
debit_account_id,
credit_account_id,
svl_id,
description,
)
if res:
debit_line_vals = res.get("debit_line_vals")
credit_line_vals = res.get("credit_line_vals")
price_diff_line_vals = res.get("price_diff_line_vals", {})

if (
self.operating_unit_id
and self.operating_unit_dest_id
and self.operating_unit_id != self.operating_unit_dest_id
and debit_line_vals["account_id"] != credit_line_vals["account_id"]
):
raise exceptions.UserError(
self.env._(
"You cannot create stock moves involving separate source"
" and destination accounts related to different "
"operating units."
)
)

if not self.operating_unit_dest_id and not self.operating_unit_id:
ou_id = (
self.picking_id.picking_type_id.warehouse_id.operating_unit_id.id
)
else:
ou_id = False

debit_line_vals["operating_unit_id"] = (
ou_id or self.operating_unit_dest_id.id or self.operating_unit_id.id
)
credit_line_vals["operating_unit_id"] = (
ou_id or self.operating_unit_id.id or self.operating_unit_dest_id.id
)
rslt = {
"credit_line_vals": credit_line_vals,
"debit_line_vals": debit_line_vals,
}
if price_diff_line_vals:
price_diff_line_vals["operating_unit_id"] = (
ou_id or self.operating_unit_id.id or self.operating_unit_dest_id.id
)
rslt["price_diff_line_vals"] = price_diff_line_vals
return rslt
return res

def _action_done(self, cancel_backorder=False):
"""
Generate accounting moves if the product being moved is subject
to real_time valuation tracking,
and the source or destination location are
a transit location or is outside of the company or the source or
destination locations belong to different operating units.
"""
res = super()._action_done(cancel_backorder)
for move in self:
if move.product_id.valuation == "real_time":
# Inter-operating unit moves do not accept to
# from/to non-internal location
if move.location_id.company_id and (
move.location_id.company_id == move.location_dest_id.company_id
and move.operating_unit_id != move.operating_unit_dest_id
):
(
journal_id,
acc_src,
acc_dest,
acc_valuation,
) = move._get_accounting_data_for_valuation()

move_lines = move._prepare_account_move_line(
move.product_qty,
move.product_id.standard_price,
acc_valuation,
acc_valuation,
self.env._("%s - OU Move") % move.product_id.display_name,
)
am = (
self.env["account.move"]
.with_context(
company_id=move.company_id.id,
)
.create(
{
"journal_id": journal_id,
"line_ids": move_lines,
"company_id": move.company_id.id,
"ref": move.picking_id and move.picking_id.name,
"stock_move_id": move.id,
}
)
.with_company(move.location_id.company_id.id)
)
am.action_post()
return res
3 changes: 3 additions & 0 deletions stock_account_operating_unit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
11 changes: 11 additions & 0 deletions stock_account_operating_unit/readme/CONFIGURATION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
If your company is required to generate a balanced balance sheet by
operating unit you can specify at company level that operating units should
be self-balanced, and then indicate a self-balancing clearing account.

#. Create an account for "Inter-OU Clearing" of type Regular.
#. Go to *Settings / Companies / Configuration* and:

* Set the "Operating Units are self-balanced" checkbox.
* Set the "Inter-OU Clearing" account in "Inter-operating unit clearing
account" field.
#. Assign Operating Unit in Accounts.
4 changes: 4 additions & 0 deletions stock_account_operating_unit/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Eficent Business and IT Consulting Services S.L.
\<contact@eficent.com\>
- Serpent Consulting Services Pvt. Ltd. \<support@serpentcs.com\>
- Jarsa Sistemas \<info@jarsa.com.mx\>
4 changes: 4 additions & 0 deletions stock_account_operating_unit/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module introduces the following features:

- Creates account move lines when stock moves are posted between
internal locations within the same company, but different OU’s.
3 changes: 3 additions & 0 deletions stock_account_operating_unit/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Create stock moves between internal locations within the same company,
but different OU’s. The journal entries are created and they are
self-balanced within the OU when the journal entries are posted
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading