Skip to content

Commit

Permalink
Merge pull request #642 from OCA/14.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/operating-unit (14.0)
  • Loading branch information
bt-admin authored Jan 29, 2025
2 parents 897f5fb + 2230165 commit 463183f
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 81 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ addon | version | maintainers | summary
[account_asset_operating_unit](account_asset_operating_unit/) | 14.0.1.0.2 | [![ps-tubtim](https://github.com/ps-tubtim.png?size=30px)](https://github.com/ps-tubtim) | This module adds operating unit information to assets.
[account_asset_operating_unit_access_all](account_asset_operating_unit_access_all/) | 14.0.1.0.0 | [![ps-tubtim](https://github.com/ps-tubtim.png?size=30px)](https://github.com/ps-tubtim) | Access all OUs' Assets
[account_financial_report_operating_unit](account_financial_report_operating_unit/) | 14.0.1.0.2 | | Introduces Operating Unit (OU) in financial reports
[account_operating_unit](account_operating_unit/) | 14.0.1.0.3 | | Introduces Operating Unit (OU) in invoices and Accounting Entries with clearing account
[account_operating_unit](account_operating_unit/) | 14.0.1.1.0 | | Introduces Operating Unit (OU) in invoices and Accounting Entries with clearing account
[account_operating_unit_access_all](account_operating_unit_access_all/) | 14.0.1.0.0 | [![kittiu](https://github.com/kittiu.png?size=30px)](https://github.com/kittiu) | Access all OUs' Accounting
[agreement_operating_unit](agreement_operating_unit/) | 14.0.1.0.0 | [![max3903](https://github.com/max3903.png?size=30px)](https://github.com/max3903) | This module adds operating unit information to agreements and service profiles.
[analytic_operating_unit](analytic_operating_unit/) | 14.0.1.0.1 | | Analytic Operating Unit
Expand Down
3 changes: 2 additions & 1 deletion account_operating_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Accounting with Operating Units
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8b7babbbed1263baf68d3587a2aef22a73fe289aa4b269a6512aa9fad4c0e89c
!! source digest: sha256:bad839db79072fcf85c79a1665d78f2ff474c840ab26c6afb4b6ad952e0da0ef
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -127,6 +127,7 @@ Contributors
* Michael Villamar <[email protected]>
* Jarsa Sistemas <[email protected]>
* Alan Ramos <[email protected]>
* Hieu, Vo Minh Bao <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
1 change: 0 additions & 1 deletion account_operating_unit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

from . import models
from . import report
from . import wizards
2 changes: 1 addition & 1 deletion account_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Accounting with Operating Units",
"summary": "Introduces Operating Unit (OU) in invoices and "
"Accounting Entries with clearing account",
"version": "14.0.1.0.3",
"version": "14.0.1.1.0",
"author": "ForgeFlow, "
"Serpent Consulting Services Pvt. Ltd.,"
"WilldooIT Pty Ltd,"
Expand Down
8 changes: 0 additions & 8 deletions account_operating_unit/i18n/account_operating_unit.pot
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ msgstr ""
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company__display_name
msgid "Display Name"
msgstr ""
Expand All @@ -90,7 +89,6 @@ msgstr ""
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register__id
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company__id
msgid "ID"
msgstr ""
Expand Down Expand Up @@ -126,7 +124,6 @@ msgstr ""
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company____last_update
msgid "Last Modified on"
msgstr ""
Expand Down Expand Up @@ -166,11 +163,6 @@ msgstr ""
msgid "Payments"
msgstr ""

#. module: account_operating_unit
#: model:ir.model,name:account_operating_unit.model_account_payment_register
msgid "Register Payment"
msgstr ""

#. module: account_operating_unit
#: code:addons/account_operating_unit/models/account_move.py:0
#, python-format
Expand Down
15 changes: 4 additions & 11 deletions account_operating_unit/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ msgstr ""
#: code:addons/account_operating_unit/models/res_company.py:0
#, python-format
msgid ""
"Configuration error. Please provide an Inter-operating unit clearing "
"account."
"Configuration error. Please provide an Inter-operating unit clearing account."
msgstr ""
"Error de configuración. Por favor indique una cuenta de compensación entre "
"unidades operacionales."
Expand Down Expand Up @@ -97,7 +96,6 @@ msgstr ""
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"
Expand All @@ -108,7 +106,6 @@ msgstr "Mostrar Nombre"
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register__id
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company__id
msgid "ID"
msgstr "ID"
Expand Down Expand Up @@ -144,7 +141,6 @@ msgstr "Artículo Diario"
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"
Expand Down Expand Up @@ -185,11 +181,6 @@ msgstr "Las Unidades operacionales están auto balanceadas"
msgid "Payments"
msgstr "Pagos"

#. module: account_operating_unit
#: model:ir.model,name:account_operating_unit.model_account_payment_register
msgid "Register Payment"
msgstr "Registro de Pago"

#. module: account_operating_unit
#: code:addons/account_operating_unit/models/account_move.py:0
#, python-format
Expand All @@ -199,7 +190,6 @@ msgstr ""

#. module: account_operating_unit
#: code:addons/account_operating_unit/models/account_move.py:0
#: code:addons/account_operating_unit/models/account_move.py:0
#, python-format
msgid "The OU in the Move and in Journal must be the same."
msgstr "La UO en el Movimiento y en el Diario debe ser la misma."
Expand All @@ -210,3 +200,6 @@ msgstr "La UO en el Movimiento y en el Diario debe ser la misma."
msgid "This operating unit will be defaulted in the move lines."
msgstr ""
"Esta unidad operativa aparecerá por defecto en las líneas de movimiento."

#~ msgid "Register Payment"
#~ msgstr "Registro de Pago"
11 changes: 3 additions & 8 deletions account_operating_unit/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ msgstr ""
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register__display_name
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company__display_name
msgid "Display Name"
msgstr "Nome visualizzato"
Expand All @@ -107,7 +106,6 @@ msgstr "Nome visualizzato"
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment__id
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register__id
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company__id
msgid "ID"
msgstr "ID"
Expand Down Expand Up @@ -143,7 +141,6 @@ msgstr "Movimento contabile"
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_move_line____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_account_payment_register____last_update
#: model:ir.model.fields,field_description:account_operating_unit.field_res_company____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"
Expand Down Expand Up @@ -185,11 +182,6 @@ msgstr "Le unità operative sono autobilanciate"
msgid "Payments"
msgstr "Pagamenti"

#. module: account_operating_unit
#: model:ir.model,name:account_operating_unit.model_account_payment_register
msgid "Register Payment"
msgstr "Registra pagamento"

#. module: account_operating_unit
#: code:addons/account_operating_unit/models/account_move.py:0
#, python-format
Expand All @@ -207,3 +199,6 @@ msgstr "L'unità operativa nel movimento e nel Registro deve essere la stessa."
#: model:ir.model.fields,help:account_operating_unit.field_account_move__operating_unit_id
msgid "This operating unit will be defaulted in the move lines."
msgstr "Questa unità operativa sarà predefinita nelle righe di movimento."

#~ msgid "Register Payment"
#~ msgstr "Registra pagamento"
61 changes: 60 additions & 1 deletion account_operating_unit/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,63 @@ def _check_move_operating_unit(self):
)
)

def _check_ou_balance(self, lines):
# Look for the balance of each OU
ou_balance = {}
for line in lines:
if line.operating_unit_id.id not in ou_balance:
ou_balance[line.operating_unit_id.id] = 0.0
ou_balance[line.operating_unit_id.id] += line.credit - line.debit
return ou_balance

def reconcile(self):
# if one OU pays the invoices of different OU
# a regularization entry must be created (this
# was a feature in version <= 12)
if self and not self[0].company_id.ou_is_self_balanced:
return super().reconcile()
bank_journal = self.mapped("move_id.journal_id").filtered(
lambda l: l.type in ("bank", "cash")
)
if not bank_journal:
return super().reconcile()
bank_journal = bank_journal[0]
# If all move lines point to the same operating unit, there's no
# need to create a balancing move line
if len(self.mapped("operating_unit_id")) <= 1:
return super().reconcile()
# Create balancing entries for un-balanced OU's.
move_vals = self._prepare_inter_ou_balancing_move(bank_journal)
move = self.env["account.move"].create(move_vals)
ou_balances = self._check_ou_balance(self)
amls = []
for ou_id in list(ou_balances.keys()):
# If the OU is already balanced, then do not continue
if move.company_id.currency_id.is_zero(ou_balances[ou_id]):
continue
# Create a balancing move line in the operating unit
# clearing account
line_data = move._prepare_inter_ou_balancing_move_line(
move, ou_id, ou_balances
)
if line_data:
amls.append(self.with_context(wip=True).create(line_data))
if amls:
move.with_context(wip=False).write(
{"line_ids": [(4, aml.id) for aml in amls]}
)
move.with_context(inter_ou_balance_entry=True).action_post()
return super().reconcile()

def _prepare_inter_ou_balancing_move(self, journal):
move_vals = {
"journal_id": journal.id,
"date": max(self.mapped("date")),
"ref": "Inter OU Balancing",
"company_id": journal.company_id.id,
}
return move_vals


class AccountMove(models.Model):
_inherit = "account.move"
Expand Down Expand Up @@ -163,7 +220,9 @@ def _check_ou_balance(self, move):
def _post(self, soft=True):
ml_obj = self.env["account.move.line"]
for move in self:
if not move.company_id.ou_is_self_balanced:
if not move.company_id.ou_is_self_balanced or self.env.context.get(
"inter_ou_balance_entry", False
):
continue

# If all move lines point to the same operating unit, there's no
Expand Down
4 changes: 3 additions & 1 deletion account_operating_unit/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def _prepare_move_line_default_vals(self, write_off_line_vals=None):
):
destination_account_id = self.destination_account_id.id
for line in res:
if line["account_id"] == destination_account_id:
if not line.get("operating_unit_id", False) or (
line["account_id"] == destination_account_id
):
line["operating_unit_id"] = invoices_ou.id
return res
1 change: 1 addition & 0 deletions account_operating_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* Michael Villamar <[email protected]>
* Jarsa Sistemas <[email protected]>
* Alan Ramos <[email protected]>
* Hieu, Vo Minh Bao <[email protected]>
15 changes: 9 additions & 6 deletions account_operating_unit/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Accounting with Operating Units</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:8b7babbbed1263baf68d3587a2aef22a73fe289aa4b269a6512aa9fad4c0e89c
!! source digest: sha256:bad839db79072fcf85c79a1665d78f2ff474c840ab26c6afb4b6ad952e0da0ef
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/operating-unit/tree/14.0/account_operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/operating-unit-14-0/operating-unit-14-0-account_operating_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows a company to manage the accounting based on Operating
Expand Down Expand Up @@ -479,12 +479,15 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Michael Villamar &lt;<a class="reference external" href="mailto:michael.villamar&#64;willdooit.com">michael.villamar&#64;willdooit.com</a>&gt;</li>
<li>Jarsa Sistemas &lt;<a class="reference external" href="mailto:info&#64;jarsa.com.mx">info&#64;jarsa.com.mx</a>&gt;</li>
<li>Alan Ramos &lt;<a class="reference external" href="mailto:alan.ramos&#64;jarsa.com.mx">alan.ramos&#64;jarsa.com.mx</a>&gt;</li>
<li>Hieu, Vo Minh Bao &lt;<a class="reference external" href="mailto:hieu.vmb&#64;komit-consulting.com">hieu.vmb&#64;komit-consulting.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
7 changes: 6 additions & 1 deletion account_operating_unit/tests/test_payment_operating_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ def test_payment_from_two_invoices(self):

register_payments.action_create_payments()
payments = self.payment_model.search([], order="id desc", limit=2)
inter_ou_moves = self.move_model.search(
[("ref", "=", "Inter OU Balancing")], order="id desc", limit=2
)
self.assertEqual(sum(inter_ou_moves[0].mapped("line_ids.debit")), 115000)
self.assertEqual(sum(inter_ou_moves[1].mapped("line_ids.debit")), 115000)
for payment in payments:
# Validate that inter OU balance move lines are created
self.assertEqual(len(payment.move_id.line_ids), 4)
self.assertEqual(len(payment.move_id.line_ids), 2)
self.assertAlmostEqual(payment.amount, 115000)
self.assertEqual(payment.state, "posted")
for invoice in invoices:
Expand Down
3 changes: 0 additions & 3 deletions account_operating_unit/wizards/__init__.py

This file was deleted.

Loading

0 comments on commit 463183f

Please sign in to comment.