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

[15.0][MIG] stock_account_operating_unit: Migration to 15.0 #478

Merged
merged 14 commits into from
Feb 13, 2023
Merged
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
6 changes: 6 additions & 0 deletions setup/stock_account_operating_unit/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,
)
86 changes: 86 additions & 0 deletions stock_account_operating_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
=======================================
Stock account moves with Operating Unit
=======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-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/13.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-13-0/operating-unit-13-0-stock_account_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/213/13.0
:alt: Try me on Runbot

|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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20stock_account_operating_unit%0Aversion:%2013.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. <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
* Jarsa Sistemas <[email protected]>

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/13.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
19 changes: 19 additions & 0 deletions stock_account_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# © 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": "15.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 <[email protected]>\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 13.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,
description,
):
res = super(StockMove, self)._generate_valuation_lines_data(
partner_id,
qty,
debit_value,
credit_value,
debit_account_id,
credit_account_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(
_(
"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(StockMove, self)._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,
_("%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
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.
3 changes: 3 additions & 0 deletions stock_account_operating_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Eficent Business and IT Consulting Services S.L. <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
* Jarsa Sistemas <[email protected]>
4 changes: 4 additions & 0 deletions stock_account_operating_unit/readme/DESCRIPTION.rst
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.rst
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