Skip to content
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
48 changes: 24 additions & 24 deletions account_invoice_inter_company/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ Configuration
To configure this module, you need to go to the menu *Settings > General
Settings*, go to the tab *Companies / Inter Company OCA features*

You now have access to other options *Intercompany user for invoices*
and *Invoice Auto Validation*.
You now have access to other options *Generate Intercompany Invoices*,
*Intercompany user for invoices* and *Invoice Auto Validation*.

To customize products sharing don't hesitate to override
\_compute_share_product() in res.company model.

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

- This module cannot be fully used in combination with
remove_odoo_entreprise module. If you need both, uninstall
remove_odoo_entreprise, complete settings with
account_invoice_inter_company and then re-install
remove_odoo_entreprise.
- Product mapping: would be nice to have a matrix with the products
on the left side and on the top row the companies.
- This module cannot be fully used in combination with
remove_odoo_entreprise module. If you need both, uninstall
remove_odoo_entreprise, complete settings with
account_invoice_inter_company and then re-install
remove_odoo_entreprise.
- Product mapping: would be nice to have a matrix with the products
on the left side and on the top row the companies.

Bug Tracker
===========
Expand All @@ -89,26 +89,26 @@ Authors
Contributors
------------

- Odoo S.A. (original module inter_company_rules)
- Andrea Stirpe <a.stirpe@onestein.nl>
- Adria Gil Sorribes <adria.gil@forgeflow.com>
- Christopher Ormaza <chris.ormaza@forgeflow.com>
- \`Akretion <https://www.akretion.com>\`:
- Odoo S.A. (original module inter_company_rules)
- Andrea Stirpe <a.stirpe@onestein.nl>
- Adria Gil Sorribes <adria.gil@forgeflow.com>
- Christopher Ormaza <chris.ormaza@forgeflow.com>
- \`Akretion <https://www.akretion.com>\`:

- Chafique Delli <chafique.delli@akretion.com>
- Alexis de Lattre <alexis.delattre@akretion.com>
- David Beal <david.beal@akretion.com>
- Chafique Delli <chafique.delli@akretion.com>
- Alexis de Lattre <alexis.delattre@akretion.com>
- David Beal <david.beal@akretion.com>

- \`Tecnativa <https://www.tecnativa.com>\`:
- \`Tecnativa <https://www.tecnativa.com>\`:

- Jairo Llopis
- David Vidal
- Pedro M. Baeza
- Jairo Llopis
- David Vidal
- Pedro M. Baeza

- Isaac Gallart <igallart@puntsistemes.es>
- \`Komit <https://komit-consulting.com>\`:
- Isaac Gallart <igallart@puntsistemes.es>
- \`Komit <https://komit-consulting.com>\`:

- Cuong Nguyen Mtm <cuong.nmtm@komit-consulting.com>
- Cuong Nguyen Mtm <cuong.nmtm@komit-consulting.com>

Maintainers
-----------
Expand Down
7 changes: 7 additions & 0 deletions account_invoice_inter_company/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def action_post(self):
dest_company = src_invoice._find_company_from_invoice_partner()
if not dest_company:
continue
# If one of the involved companies have the intercompany
# setting disabled, skip
if (
not dest_company.intercompany_invoicing
or not src_invoice.company_id.intercompany_invoicing
):
continue
intercompany_user = dest_company.intercompany_invoice_user_id
if intercompany_user:
src_invoice = src_invoice.with_user(intercompany_user).sudo()
Expand Down
8 changes: 8 additions & 0 deletions account_invoice_inter_company/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class ResCompany(models.Model):
help="Responsible user for creation of invoices triggered by "
"intercompany rules.",
)
intercompany_invoicing = fields.Boolean(
string="Generate Inter company Invoices",
help="Enable intercompany invoicing: "
"\n* Generate a Customer Invoice when a bill with this company is created."
"\n* Generate a Vendor Bill when an invoice with this company as a customer"
" is created.",
default=True,
)

def _get_user_domain(self):
self.ensure_one()
Expand Down
9 changes: 9 additions & 0 deletions account_invoice_inter_company/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ class ResConfigSettings(models.TransientModel):
"intercompany rules. If not set the user initiating the"
"transaction will be used",
)
intercompany_invoicing = fields.Boolean(
string="Generate Inter company Invoices",
related="company_id.intercompany_invoicing",
help="Enable intercompany invoicing: "
"\n * Generate a Customer Invoice when a bill with this company is created."
"\n * Generate a Vendor Bill when an invoice with this company as a customer"
" is created.",
readonly=False,
)
2 changes: 1 addition & 1 deletion account_invoice_inter_company/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ To configure this module, you need to go to the menu *Settings \>
General Settings*, go to the tab *Companies / Inter Company OCA
features*

You now have access to other options *Intercompany user for invoices* and
You now have access to other options *Generate Intercompany Invoices*, *Intercompany user for invoices* and
*Invoice Auto Validation*.

To customize products sharing don't hesitate to override
Expand Down
4 changes: 2 additions & 2 deletions account_invoice_inter_company/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ <h1 class="title">Inter Company Invoices</h1>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To configure this module, you need to go to the menu <em>Settings &gt; General
Settings</em>, go to the tab <em>Companies / Inter Company OCA features</em></p>
<p>You now have access to other options <em>Intercompany user for invoices</em>
and <em>Invoice Auto Validation</em>.</p>
<p>You now have access to other options <em>Generate Intercompany Invoices</em>,
<em>Intercompany user for invoices</em> and <em>Invoice Auto Validation</em>.</p>
<p>To customize products sharing don’t hesitate to override
_compute_share_product() in res.company model.</p>
</div>
Expand Down
15 changes: 15 additions & 0 deletions account_invoice_inter_company/tests/test_inter_company_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def setUpClass(cls):
{
"name": "Company A",
"invoice_auto_validation": True,
"intercompany_invoicing": True,
}
)
cls.partner_company_a = cls.env["res.partner"].create(
Expand All @@ -30,6 +31,7 @@ def setUpClass(cls):
{
"name": "Company B",
"invoice_auto_validation": True,
"intercompany_invoicing": True,
}
)
cls.partner_company_b = cls.env["res.partner"].create(
Expand Down Expand Up @@ -575,3 +577,16 @@ def _confirm_invoice_with_product(self):
)
self.assertEqual(len(invoices), 1)
return invoices

def test_confirm_invoice_intercompany_disabled(self):
# ensure the catalog is shared
self.env.ref("product.product_comp_rule").write({"active": False})
# Disable the configuration in company A
self.company_a.intercompany_invoicing = False
# Confirm the invoice of company A
self.invoice_company_a.with_user(self.user_company_a.id).action_post()
# Check that no destination invoice has been created in company B
invoices = self.account_move_obj.with_user(self.user_company_b.id).search(
[("auto_invoice_id", "=", self.invoice_company_a.id)]
)
self.assertFalse(invoices)
12 changes: 10 additions & 2 deletions account_invoice_inter_company/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
>
<div class="text-decoration-underline mt8 mb8">Invoice</div>
<div class="content-group" string="Invoice">
<div>
<div id="intercompany_invoicing">
<label
string="Generate Intercompany Invoices"
for="intercompany_invoicing"
class="o_light_label mr8"
/>
<field name="intercompany_invoicing" class="oe_inline" />
</div>
<div invisible="not intercompany_invoicing">
<label
for="intercompany_invoice_user_id"
string="Invoices User"
Expand All @@ -28,7 +36,7 @@
class="oe_inline"
/>
</div>
<div>
<div invisible="not intercompany_invoicing">
<label
for="invoice_auto_validation"
class="o_light_label mr8"
Expand Down