Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 9f8e7a0

Browse files
committed
[MIG] purchase_sale_inter_company: migrate sync pickings for v15
1 parent 04009a4 commit 9f8e7a0

12 files changed

Lines changed: 90 additions & 219 deletions

File tree

account_invoice_inter_company/tests/test_inter_company_invoice.py

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
from odoo import _
77
from odoo.exceptions import UserError, ValidationError
8-
from odoo.tests import tagged
9-
from odoo.tests.common import Form, SavepointCase
8+
from odoo.tests.common import Form, TransactionCase
109

1110

12-
@tagged("post_install", "-at_install")
13-
class TestAccountInvoiceInterCompanyBase(SavepointCase):
11+
class TestAccountInvoiceInterCompanyBase(TransactionCase):
1412
@classmethod
1513
def setUpClass(cls):
1614
super().setUpClass()
@@ -32,7 +30,7 @@ def setUpClass(cls):
3230
"invoice_auto_validation": True,
3331
}
3432
)
35-
cls.chart.try_loading(cls.company_a)
33+
cls.chart.try_loading(company=cls.company_a, install_demo=False)
3634
cls.partner_company_a = cls.company_a.partner_id
3735
cls.company_b = cls.env["res.company"].create(
3836
{
@@ -43,7 +41,7 @@ def setUpClass(cls):
4341
"invoice_auto_validation": True,
4442
}
4543
)
46-
cls.chart.try_loading(cls.company_b)
44+
cls.chart.try_loading(company=cls.company_b, install_demo=False)
4745
cls.partner_company_b = cls.company_b.partner_id
4846
cls.child_partner_company_b = cls.env["res.partner"].create(
4947
{
@@ -53,6 +51,7 @@ def setUpClass(cls):
5351
"parent_id": cls.partner_company_b.id,
5452
}
5553
)
54+
# cls.partner_company_b = cls.company_b.parent_id.partner_id
5655
cls.user_company_a = cls.env["res.users"].create(
5756
{
5857
"name": "User A",
@@ -264,8 +263,7 @@ def setUpClass(cls):
264263
"code": "SAJ-A",
265264
"type": "sale",
266265
"secure_sequence_id": cls.sequence_sale_journal_company_a.id,
267-
"payment_credit_account_id": cls.a_sale_company_a.id,
268-
"payment_debit_account_id": cls.a_sale_company_a.id,
266+
"default_account_id": cls.a_sale_company_a.id,
269267
"company_id": cls.company_a.id,
270268
}
271269
)
@@ -275,8 +273,7 @@ def setUpClass(cls):
275273
"name": "Bank Journal - (Company A)",
276274
"code": "BNK-A",
277275
"type": "bank",
278-
"payment_credit_account_id": cls.a_sale_company_a.id,
279-
"payment_debit_account_id": cls.a_sale_company_a.id,
276+
"default_account_id": cls.a_sale_company_a.id,
280277
"company_id": cls.company_a.id,
281278
}
282279
)
@@ -295,8 +292,7 @@ def setUpClass(cls):
295292
"code": "EXJ-B",
296293
"type": "purchase",
297294
"secure_sequence_id": cls.sequence_purchase_journal_company_b.id,
298-
"payment_credit_account_id": cls.a_expense_company_b.id,
299-
"payment_debit_account_id": cls.a_expense_company_b.id,
295+
"default_account_id": cls.a_expense_company_b.id,
300296
"company_id": cls.company_b.id,
301297
}
302298
)
@@ -305,8 +301,7 @@ def setUpClass(cls):
305301
"name": "Bank Journal - (Company B)",
306302
"code": "BNK-B",
307303
"type": "bank",
308-
"payment_credit_account_id": cls.a_sale_company_b.id,
309-
"payment_debit_account_id": cls.a_sale_company_b.id,
304+
"default_account_id": cls.a_sale_company_b.id,
310305
"company_id": cls.company_b.id,
311306
}
312307
)
@@ -558,46 +553,6 @@ def test_confirm_invoice_with_native_product_rule_and_unshared_product(self):
558553
with self.assertRaises(UserError):
559554
self._confirm_invoice_with_product()
560555

561-
def test_purchase_attachement_out_invoice(self):
562-
# Sale Invoice PDF appears as attachment in the purchase invoice form.
563-
# From a Sale Invoice.
564-
self.invoice_company_a.action_post()
565-
invoice_company_b = self.account_move_obj.with_user(
566-
self.user_company_b.id
567-
).search([("auto_invoice_id", "=", self.invoice_company_a.id)])
568-
invoice_b_pdf = self.env["ir.attachment"].search(
569-
[("res_model", "=", "account.move"), ("res_id", "=", invoice_company_b.id)]
570-
)
571-
self.assertEqual(len(invoice_b_pdf), 1)
572-
self.assertEqual(invoice_b_pdf.name, self.invoice_company_a.name + ".pdf")
573-
574-
def test_purchase_attachement_in_invoice(self):
575-
# Sale Invoice PDF appears as attachment in the purchase invoice form.
576-
# From a Purchase Invoice.
577-
bill_company_a = Form(
578-
self.account_move_obj.with_company(self.company_a.id).with_context(
579-
default_move_type="in_invoice",
580-
)
581-
)
582-
bill_company_a.partner_id = self.partner_company_b
583-
bill_company_a.invoice_date = bill_company_a.date
584-
with bill_company_a.invoice_line_ids.new() as line_form:
585-
line_form.product_id = self.product_consultant_multi_company
586-
line_form.quantity = 1
587-
line_form.product_uom_id = self.env.ref("uom.product_uom_hour")
588-
line_form.price_unit = 450.0
589-
bill_company_a = bill_company_a.save()
590-
bill_company_a.action_post()
591-
592-
invoice_company_b = self.account_move_obj.with_user(
593-
self.user_company_b.id
594-
).search([("auto_invoice_id", "=", bill_company_a.id)])
595-
bill_a_pdf = self.env["ir.attachment"].search(
596-
[("res_model", "=", "account.move"), ("res_id", "=", bill_company_a.id)]
597-
)
598-
self.assertEqual(len(bill_a_pdf), 1)
599-
self.assertEqual(bill_a_pdf.name, invoice_company_b.name + ".pdf")
600-
601556
def _confirm_invoice_with_product(self):
602557
# Confirm the invoice of company A
603558
self.invoice_company_a.with_user(self.user_company_a.id).action_post()
@@ -607,21 +562,3 @@ def _confirm_invoice_with_product(self):
607562
)
608563
self.assertEqual(len(invoices), 1)
609564
return invoices
610-
611-
def test_confirm_invoice_and_full_refund(self):
612-
self.env.ref("product.product_comp_rule").write({"active": False})
613-
self._confirm_invoice_with_product()
614-
wizard = self.env["account.move.reversal"].create(
615-
{
616-
"refund_method": "cancel",
617-
"move_ids": [(6, 0, self.invoice_company_a.ids)],
618-
}
619-
)
620-
action = wizard.reverse_moves()
621-
refund_company_a = self.account_move_obj.browse(action["res_id"])
622-
623-
# Check destination refund created in company B
624-
refund = self.account_move_obj.with_user(self.user_company_b.id).search(
625-
[("auto_invoice_id", "=", refund_company_a.id)]
626-
)
627-
self.assertEqual(len(refund), 1)

purchase_sale_inter_company/README.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ Imagine you have company A and company B in the same Odoo database:
4242
.. contents::
4343
:local:
4444

45+
Use Cases / Context
46+
===================
47+
48+
Imagine you have company A and company B in the same Odoo database:
49+
50+
51+
Company A purchases goods from company B.
52+
53+
Company A will create a purchase order with company B as supplier.
54+
55+
This module automates the creation of the sale order in company B with company A as customer.
56+
57+
Receipt picking(s) created from Company A purchase are synced with quantities delivered in picking(s) by Company B sale.
58+
4559
Installation
4660
============
4761

@@ -56,6 +70,16 @@ To configure this module, you need to:
5670
#. Go to the tab *Inter-Company* then the group *Purchase To Sale*.
5771
#. If you check the option *Sale Auto Validation* in the configuration of company B, then when you validate a *Purchase Order* in company A with company B as supplier, the *Sale Order* will be automatically validated in company B with company A as customer.
5872

73+
Usage
74+
=====
75+
76+
Create a purchase with Company A, setting Company B as vendor > confirm PO > a SO for Company B with customer Company A is created automatically.
77+
78+
79+
Validate SO for Company B > validate delivery picking > in PO for Company A, receipt picking is validated with quantities from Company B delivery picking.
80+
81+
If backorders have been created from delivery picking, they will be synchronized to receipt picking.
82+
5983
Known issues / Roadmap
6084
======================
6185

purchase_sale_inter_company/models/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@
33
from . import res_company
44
from . import res_config
55
from . import sale_order
6-
<<<<<<< HEAD
7-
=======
8-
from . import stock_picking
9-
from . import stock_move
10-
>>>>>>> 5026d8f7 ([FIX] purchase_sale_inter_company: consider moves that contain same products)

purchase_sale_inter_company/models/res_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ class InterCompanyRulesConfig(models.TransientModel):
3333
"order in another company.",
3434
readonly=False,
3535
)
36-

purchase_sale_inter_company/models/sale_order.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@ def action_confirm(self):
2323
line.auto_purchase_line_id.price_unit = line.price_unit
2424
return super().action_confirm()
2525

26-
27-
def action_cancel(self):
28-
purchase_orders = (
29-
self.env["purchase.order"]
30-
.sudo()
31-
.search([("auto_sale_order_id", "in", self.ids)])
32-
)
33-
for po in purchase_orders:
34-
if po.state not in ["draft", "sent", "cancel"]:
35-
raise UserError(_("You can't cancel an order that is %s") % po.state)
36-
if purchase_orders:
37-
purchase_orders.button_cancel()
38-
return super().action_cancel()
3926

4027
class SaleOrderLine(models.Model):
4128
_inherit = "sale.order.line"

0 commit comments

Comments
 (0)