Skip to content

Commit 66c3259

Browse files
committed
Merge PR #805 into 17.0
Signed-off-by JordiBForgeFlow
2 parents 586f993 + 14245e8 commit 66c3259

8 files changed

Lines changed: 76 additions & 29 deletions

File tree

account_invoice_inter_company/README.rst

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ Configuration
5050
To configure this module, you need to go to the menu *Settings > General
5151
Settings*, go to the tab *Companies / Inter Company OCA features*
5252

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

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

5959
Known issues / Roadmap
6060
======================
6161

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

7070
Bug Tracker
7171
===========
@@ -89,26 +89,26 @@ Authors
8989
Contributors
9090
------------
9191

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

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

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

104-
- Jairo Llopis
105-
- David Vidal
106-
- Pedro M. Baeza
104+
- Jairo Llopis
105+
- David Vidal
106+
- Pedro M. Baeza
107107

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

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

113113
Maintainers
114114
-----------

account_invoice_inter_company/models/account_move.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ def action_post(self):
5151
dest_company = src_invoice._find_company_from_invoice_partner()
5252
if not dest_company:
5353
continue
54+
# If one of the involved companies have the intercompany
55+
# setting disabled, skip
56+
if (
57+
not dest_company.intercompany_invoicing
58+
or not src_invoice.company_id.intercompany_invoicing
59+
):
60+
continue
5461
intercompany_user = dest_company.intercompany_invoice_user_id
5562
if intercompany_user:
5663
src_invoice = src_invoice.with_user(intercompany_user).sudo()

account_invoice_inter_company/models/res_company.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class ResCompany(models.Model):
1717
help="Responsible user for creation of invoices triggered by "
1818
"intercompany rules.",
1919
)
20+
intercompany_invoicing = fields.Boolean(
21+
string="Generate Inter company Invoices",
22+
help="Enable intercompany invoicing: "
23+
"\n* Generate a Customer Invoice when a bill with this company is created."
24+
"\n* Generate a Vendor Bill when an invoice with this company as a customer"
25+
" is created.",
26+
default=True,
27+
)
2028

2129
def _get_user_domain(self):
2230
self.ensure_one()

account_invoice_inter_company/models/res_config_settings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ class ResConfigSettings(models.TransientModel):
2020
"intercompany rules. If not set the user initiating the"
2121
"transaction will be used",
2222
)
23+
intercompany_invoicing = fields.Boolean(
24+
string="Generate Inter company Invoices",
25+
related="company_id.intercompany_invoicing",
26+
help="Enable intercompany invoicing: "
27+
"\n * Generate a Customer Invoice when a bill with this company is created."
28+
"\n * Generate a Vendor Bill when an invoice with this company as a customer"
29+
" is created.",
30+
readonly=False,
31+
)

account_invoice_inter_company/readme/CONFIGURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ To configure this module, you need to go to the menu *Settings \>
22
General Settings*, go to the tab *Companies / Inter Company OCA
33
features*
44

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

88
To customize products sharing don't hesitate to override

account_invoice_inter_company/static/description/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ <h1 class="title">Inter Company Invoices</h1>
397397
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
398398
<p>To configure this module, you need to go to the menu <em>Settings &gt; General
399399
Settings</em>, go to the tab <em>Companies / Inter Company OCA features</em></p>
400-
<p>You now have access to other options <em>Intercompany user for invoices</em>
401-
and <em>Invoice Auto Validation</em>.</p>
400+
<p>You now have access to other options <em>Generate Intercompany Invoices</em>,
401+
<em>Intercompany user for invoices</em> and <em>Invoice Auto Validation</em>.</p>
402402
<p>To customize products sharing don’t hesitate to override
403403
_compute_share_product() in res.company model.</p>
404404
</div>

account_invoice_inter_company/tests/test_inter_company_invoice.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def setUpClass(cls):
2020
{
2121
"name": "Company A",
2222
"invoice_auto_validation": True,
23+
"intercompany_invoicing": True,
2324
}
2425
)
2526
cls.partner_company_a = cls.env["res.partner"].create(
@@ -30,6 +31,7 @@ def setUpClass(cls):
3031
{
3132
"name": "Company B",
3233
"invoice_auto_validation": True,
34+
"intercompany_invoicing": True,
3335
}
3436
)
3537
cls.partner_company_b = cls.env["res.partner"].create(
@@ -575,3 +577,16 @@ def _confirm_invoice_with_product(self):
575577
)
576578
self.assertEqual(len(invoices), 1)
577579
return invoices
580+
581+
def test_confirm_invoice_intercompany_disabled(self):
582+
# ensure the catalog is shared
583+
self.env.ref("product.product_comp_rule").write({"active": False})
584+
# Disable the configuration in company A
585+
self.company_a.intercompany_invoicing = False
586+
# Confirm the invoice of company A
587+
self.invoice_company_a.with_user(self.user_company_a.id).action_post()
588+
# Check that no destination invoice has been created in company B
589+
invoices = self.account_move_obj.with_user(self.user_company_b.id).search(
590+
[("auto_invoice_id", "=", self.invoice_company_a.id)]
591+
)
592+
self.assertFalse(invoices)

account_invoice_inter_company/views/res_config_settings_view.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
>
1818
<div class="text-decoration-underline mt8 mb8">Invoice</div>
1919
<div class="content-group" string="Invoice">
20-
<div>
20+
<div id="intercompany_invoicing">
21+
<label
22+
string="Generate Intercompany Invoices"
23+
for="intercompany_invoicing"
24+
class="o_light_label mr8"
25+
/>
26+
<field name="intercompany_invoicing" class="oe_inline" />
27+
</div>
28+
<div invisible="not intercompany_invoicing">
2129
<label
2230
for="intercompany_invoice_user_id"
2331
string="Invoices User"
@@ -28,7 +36,7 @@
2836
class="oe_inline"
2937
/>
3038
</div>
31-
<div>
39+
<div invisible="not intercompany_invoicing">
3240
<label
3341
for="invoice_auto_validation"
3442
class="o_light_label mr8"

0 commit comments

Comments
 (0)