Skip to content

Commit

Permalink
[14.0][ADD] account_payment_order_inter_company
Browse files Browse the repository at this point in the history
  • Loading branch information
chafique-delli committed Sep 22, 2022
1 parent 2b21593 commit e53f5ae
Show file tree
Hide file tree
Showing 13 changed files with 735 additions and 0 deletions.
77 changes: 77 additions & 0 deletions account_payment_order_inter_company/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
===================================
Account Payment Order Inter Company
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Fmulti--company-lightgray.png?logo=github
:target: https://github.com/OCA/multi-company/tree/14.0/account_payment_order_inter_company
:alt: OCA/multi-company
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/multi-company-14-0/multi-company-14-0-account_payment_order_inter_company
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/251/14.0
:alt: Try me on Runbot

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

This module allows for an inter-company billing to automatically pay the invoice in Company A as soon as the invoice in Company B is paid.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/multi-company/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/multi-company/issues/new?body=module:%20account_payment_order_inter_company%0Aversion:%2014.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
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Sébastien Beau <sebastien.beau@akretion.com>
* Chafique Delli <chafique.delli@akretion.com>

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/multi-company <https://github.com/OCA/multi-company/tree/14.0/account_payment_order_inter_company>`_ 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 account_payment_order_inter_company/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions account_payment_order_inter_company/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Payment Order Inter Company",
"version": "14.0.1.0.0",
"category": "Accounting & Finance",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/multi-company",
"license": "AGPL-3",
"depends": ["account_invoice_inter_company", "account_payment_order"],
"data": [],
"installable": True,
}
1 change: 1 addition & 0 deletions account_payment_order_inter_company/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_payment_order
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright 2022 Akretion France (http://www.akretion.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order"

def _prepare_move_line_vals(self, payment_line, invoice, journal, company):
vals_list = []
vals1 = {}
vals2 = {}
vals = {
"journal_id": journal.id,
"move_id": invoice.id,
"partner_id": invoice.partner_id.id,
"company_id": company.id,
}
if invoice.move_type == "out_invoice":
vals1 = {
"account_id": journal.suspense_account_id.id,
"debit": payment_line.amount_currency,
"credit": 0.0,
}
vals1.update(vals)
vals2 = {
"account_id": invoice.partner_id.with_company(
company.id
).property_account_receivable_id.id,
"credit": payment_line.amount_currency,
"debit": 0.0,
}
vals2.update(vals)
elif invoice.move_type == "in_invoice":
vals1 = {
"account_id": journal.suspense_account_id.id,
"debit": 0.0,
"credit": payment_line.amount_currency,
}
vals1.update(vals)
vals2 = {
"account_id": invoice.partner_id.with_company(
company.id
).property_account_payable_id.id,
"credit": 0.0,
"debit": payment_line.amount_currency,
}
vals2.update(vals)
if vals1 and vals2:
vals_list.extend((vals1, vals2))
return vals_list

def generate_move(self):
super().generate_move()
for bank_line in self.bank_line_ids:
dest_company = (
self.env["res.company"]
.sudo()
.search([("partner_id", "=", bank_line.partner_id.id)], limit=1)
)
if dest_company:
for payment_line in bank_line.payment_line_ids:
orig_invoice = payment_line.move_line_id.move_id
if orig_invoice.auto_generated:
dest_invoice = orig_invoice.auto_invoice_id
else:
dest_invoice = self.env["account.move"].search(
[
("auto_invoice_id", "=", orig_invoice.id),
("company_id", "=", dest_company.id),
],
limit=1,
)
if dest_invoice.payment_state != "paid":
dest_journal = self.env["account.journal"].search(
[
("company_id", "=", dest_company.id),
("type", "=", "bank"),
(
"bank_account_id",
"=",
payment_line.partner_bank_id.id,
),
],
limit=1,
)
vals_list = self._prepare_move_line_vals(
payment_line, dest_invoice, dest_journal, dest_company
)
for vals in vals_list:
self.env["account.move.line"].with_context(
check_move_validity=False
).create(vals)
lines_to_reconcile = dest_invoice.line_ids.filtered(
lambda line: line.account_internal_type
in ["receivable", "payable"]
)
lines_to_reconcile.reconcile()
2 changes: 2 additions & 0 deletions account_payment_order_inter_company/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Sébastien Beau <sebastien.beau@akretion.com>
* Chafique Delli <chafique.delli@akretion.com>
1 change: 1 addition & 0 deletions account_payment_order_inter_company/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to map tax and account depending of the product.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_fiscal_position_product_rule,access on account.fiscal.position.product.rule,model_account_fiscal_position_product_rule,account.group_account_user,1,1,1,1
Loading

0 comments on commit e53f5ae

Please sign in to comment.