diff --git a/account_banking_fr_lcr/__manifest__.py b/account_banking_fr_lcr/__manifest__.py
index 33f0be8bf..3d9eca958 100644
--- a/account_banking_fr_lcr/__manifest__.py
+++ b/account_banking_fr_lcr/__manifest__.py
@@ -16,11 +16,10 @@
"external_dependencies": {"python": ["unidecode", "pypdf>=3.1.0"]},
"data": [
"data/account_payment_method.xml",
- "views/account_payment_mode.xml",
+ "views/account_payment_method_line.xml",
"views/account_payment_order.xml",
"views/account_move.xml",
],
- "demo": ["demo/lcr_demo.xml"],
"post_init_hook": "lcr_set_unece",
"installable": True,
}
diff --git a/account_banking_fr_lcr/demo/lcr_demo.xml b/account_banking_fr_lcr/demo/lcr_demo.xml
deleted file mode 100644
index f859a6d2d..000000000
--- a/account_banking_fr_lcr/demo/lcr_demo.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- LCR
-
- variable
-
-
-
-
diff --git a/account_banking_fr_lcr/models/__init__.py b/account_banking_fr_lcr/models/__init__.py
index 66a161100..a4cbe39d6 100644
--- a/account_banking_fr_lcr/models/__init__.py
+++ b/account_banking_fr_lcr/models/__init__.py
@@ -1,5 +1,5 @@
from . import account_payment_method
-from . import account_payment_mode
+from . import account_payment_method_line
from . import account_payment_order
from . import account_payment_line
from . import account_payment
diff --git a/account_banking_fr_lcr/models/account_move.py b/account_banking_fr_lcr/models/account_move.py
index 6bf7e3539..f8ddb4bd8 100644
--- a/account_banking_fr_lcr/models/account_move.py
+++ b/account_banking_fr_lcr/models/account_move.py
@@ -26,8 +26,8 @@
class AccountMove(models.Model):
_inherit = "account.move"
- payment_mode_fr_lcr_type = fields.Selection(
- related="payment_mode_id.fr_lcr_type", store=True
+ payment_method_line_fr_lcr_type = fields.Selection(
+ related="preferred_payment_method_line_id.fr_lcr_type", store=True
)
fr_lcr_attachment_id = fields.Many2one(
"ir.attachment", string="Bill of Exchange Attachment"
@@ -42,8 +42,7 @@ class AccountMove(models.Model):
"res.partner.bank",
compute="_compute_fr_lcr_partner_bank_id",
store=True,
- precompute=True,
- states={"draft": [("readonly", False)]},
+ readonly=False,
string="Bill of Exchange Bank Account",
help="Bank account of the customer that will be debited by "
"the bill of exchange. By default, Odoo selects the first French "
@@ -53,7 +52,7 @@ class AccountMove(models.Model):
domain="[('partner_id', '=', commercial_partner_id)]",
)
- @api.depends("partner_id", "payment_mode_id")
+ @api.depends("partner_id", "preferred_payment_method_line_id")
def _compute_fr_lcr_partner_bank_id(self):
for move in self:
partner_bank_id = False
@@ -84,16 +83,16 @@ def _post(self, soft=True):
# not for promissory note (we may only know the bank account when
# receiving it)
if (
- move.payment_mode_fr_lcr_type in ("accepted", "not_accepted")
+ move.payment_method_line_fr_lcr_type in ("accepted", "not_accepted")
and not move.fr_lcr_partner_bank_id
):
raise UserError(
_(
"Customer invoice '%(move)s' is configured with "
- "payment mode '%(payment_mode)s' which require "
+ "payment mode '%(payment_method_line)s' which require "
"a bill of exchange bank account.",
move=move.display_name,
- payment_mode=move.payment_mode_id.display_name,
+ payment_method_line=move.preferred_payment_method_line_id.display_name,
)
)
if move.fr_lcr_partner_bank_id:
@@ -105,7 +104,7 @@ def fr_lcr_print(self):
assert self.state == "posted"
assert self.move_type == "out_invoice"
assert self.payment_method_code == "fr_lcr"
- assert self.payment_mode_fr_lcr_type == "accepted"
+ assert self.payment_method_line_fr_lcr_type == "accepted"
if self.fr_lcr_attachment_id and self.payment_state not in (
"in_payment",
"paid",
diff --git a/account_banking_fr_lcr/models/account_payment.py b/account_banking_fr_lcr/models/account_payment.py
index cee8e05d2..5bd385367 100644
--- a/account_banking_fr_lcr/models/account_payment.py
+++ b/account_banking_fr_lcr/models/account_payment.py
@@ -38,7 +38,7 @@ def _prepare_cfonb_line(self, transactions_count):
)
else:
nom_banque = " " * 24
- code_acceptation = LCR_TYPE_CODES[order.payment_mode_id.fr_lcr_type]
+ code_acceptation = LCR_TYPE_CODES[order.payment_method_line_id.fr_lcr_type]
montant_centimes = str(round(self.amount * 100))
zero_montant_centimes = montant_centimes.zfill(12)
if payment_line.move_line_id and payment_line.move_line_id.move_id.invoice_date:
diff --git a/account_banking_fr_lcr/models/account_payment_line.py b/account_banking_fr_lcr/models/account_payment_line.py
index 4da5c5c93..c9b6cdf44 100644
--- a/account_banking_fr_lcr/models/account_payment_line.py
+++ b/account_banking_fr_lcr/models/account_payment_line.py
@@ -13,7 +13,7 @@ def _compute_payment_line(self):
res = super()._compute_payment_line()
for line in self:
if (
- line.order_id.payment_mode_id.payment_method_id.code == "fr_lcr"
+ line.order_id.payment_method_line_id.payment_method_id.code == "fr_lcr"
and line.move_line_id
and line.move_line_id.move_id.fr_lcr_partner_bank_id
):
diff --git a/account_banking_fr_lcr/models/account_payment_mode.py b/account_banking_fr_lcr/models/account_payment_method_line.py
similarity index 87%
rename from account_banking_fr_lcr/models/account_payment_mode.py
rename to account_banking_fr_lcr/models/account_payment_method_line.py
index cc4577ace..c85e9fa23 100644
--- a/account_banking_fr_lcr/models/account_payment_mode.py
+++ b/account_banking_fr_lcr/models/account_payment_method_line.py
@@ -6,8 +6,8 @@
from odoo.exceptions import ValidationError
-class AccountPaymentMode(models.Model):
- _inherit = "account.payment.mode"
+class AccountPaymentMethodLine(models.Model):
+ _inherit = "account.payment.method.line"
fr_lcr_type = fields.Selection(
[
@@ -71,24 +71,24 @@ def _fr_lcr_dailly_option_selection(self):
@api.depends("payment_method_id")
def _compute_fr_lcr_type(self):
- for mode in self:
+ for line in self:
fr_lcr_type = False
- if mode.payment_method_id and mode.payment_method_id.code == "fr_lcr":
+ if line.payment_method_id and line.payment_method_id.code == "fr_lcr":
fr_lcr_type = "not_accepted"
- mode.fr_lcr_type = fr_lcr_type
+ line.fr_lcr_type = fr_lcr_type
@api.constrains("payment_method_id", "fr_lcr_type")
def _check_fr_lcr(self):
- for mode in self:
+ for line in self:
if (
- mode.payment_method_id
- and mode.payment_method_id.code == "fr_lcr"
- and not mode.fr_lcr_type
+ line.payment_method_id
+ and line.payment_method_id.code == "fr_lcr"
+ and not line.fr_lcr_type
):
raise ValidationError(
_(
"The field 'Bill of Exchange Type' must be set on "
"payment mode '%s'."
)
- % mode.display_name
+ % line.display_name
)
diff --git a/account_banking_fr_lcr/models/account_payment_order.py b/account_banking_fr_lcr/models/account_payment_order.py
index 06d2d283d..156bbd25c 100644
--- a/account_banking_fr_lcr/models/account_payment_order.py
+++ b/account_banking_fr_lcr/models/account_payment_order.py
@@ -43,12 +43,12 @@ class AccountPaymentOrder(models.Model):
fr_lcr_collection_option = fields.Selection(
lambda self: self.env[
- "account.payment.mode"
+ "account.payment.method.line"
]._fr_lcr_collection_option_selection(),
compute="_compute_fr_lcr_fields",
store=True,
precompute=True,
- states={"draft": [("readonly", False)]},
+ readonly=False,
string="Collection Option",
)
# if fr_lcr_value_date is also used for Dailly, we'll have to change
@@ -62,25 +62,27 @@ class AccountPaymentOrder(models.Model):
precompute=True,
)
fr_lcr_dailly_option = fields.Selection(
- lambda self: self.env["account.payment.mode"]._fr_lcr_dailly_option_selection(),
+ lambda self: self.env[
+ "account.payment.method.line"
+ ]._fr_lcr_dailly_option_selection(),
compute="_compute_fr_lcr_fields",
store=True,
precompute=True,
- states={"draft": [("readonly", False)]},
+ readonly=False,
string="Dailly Option",
)
- @api.depends("payment_mode_id")
+ @api.depends("payment_method_line_id")
def _compute_fr_lcr_fields(self):
for order in self:
fr_lcr_collection_option = False
fr_lcr_dailly = False
fr_lcr_dailly_option = False
- if order.payment_mode_id.payment_method_id.code == "fr_lcr":
- mode = order.payment_mode_id
- fr_lcr_collection_option = mode.fr_lcr_default_collection_option
- fr_lcr_dailly = mode.fr_lcr_dailly
- fr_lcr_dailly_option = mode.fr_lcr_default_dailly_option
+ if order.payment_method_line_id.payment_method_id.code == "fr_lcr":
+ method_line = order.payment_method_line_id
+ fr_lcr_collection_option = method_line.fr_lcr_default_collection_option
+ fr_lcr_dailly = method_line.fr_lcr_dailly
+ fr_lcr_dailly_option = method_line.fr_lcr_default_dailly_option
order.fr_lcr_collection_option = fr_lcr_collection_option
order.fr_lcr_dailly = fr_lcr_dailly
order.fr_lcr_dailly_option = fr_lcr_dailly_option
@@ -178,10 +180,10 @@ def _prepare_first_cfonb_line(self):
code_operation = "60"
numero_enregistrement = "00000001"
numero_emetteur = "000000" # It is not needed for LCR
- if self.payment_mode_id.fr_lcr_convention_type:
+ if self.payment_method_line_id.fr_lcr_convention_type:
type_convention = self._prepare_lcr_field(
"Type de convention",
- self.payment_mode_id.fr_lcr_convention_type,
+ self.payment_method_line_id.fr_lcr_convention_type,
6,
)
else:
@@ -291,7 +293,7 @@ def generate_payment_file(self):
cfonb_lines.append(
self._prepare_final_cfonb_line(total_amount, transactions_count)
)
- if self.payment_mode_id.fr_lcr_type == "promissory_note":
+ if self.payment_method_line_id.fr_lcr_type == "promissory_note":
file_prefix = "BOR"
else:
file_prefix = "LCR"
diff --git a/account_banking_fr_lcr/post_install.py b/account_banking_fr_lcr/post_install.py
index 7b3faab21..6a77c79f1 100644
--- a/account_banking_fr_lcr/post_install.py
+++ b/account_banking_fr_lcr/post_install.py
@@ -2,11 +2,8 @@
# @author: Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import SUPERUSER_ID, api
-
-def lcr_set_unece(cr, registry):
- env = api.Environment(cr, SUPERUSER_ID, {})
+def lcr_set_unece(env):
lcr = env.ref("account_banking_fr_lcr.fr_lcr")
if lcr:
# This module doesn't depend on account_payment_unece
diff --git a/account_banking_fr_lcr/tests/test_fr_lcr.py b/account_banking_fr_lcr/tests/test_fr_lcr.py
index 8306c80fe..2a8cbf6de 100644
--- a/account_banking_fr_lcr/tests/test_fr_lcr.py
+++ b/account_banking_fr_lcr/tests/test_fr_lcr.py
@@ -8,11 +8,12 @@
from odoo import Command, fields
from odoo.exceptions import UserError
from odoo.tests import tagged
-from odoo.tests.common import TransactionCase
+
+from odoo.addons.account.tests.common import AccountTestInvoicingCommon
@tagged("post_install", "-at_install")
-class TestFrLcr(TransactionCase):
+class TestFrLcr(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
@@ -21,33 +22,19 @@ def setUpClass(cls):
cls.eur_currency = cls.env.ref("base.EUR")
cls.today = fields.Date.today()
cls.today_plus2 = cls.today + timedelta(days=2)
- cls.company = cls.env["res.company"].create(
- {"name": "LCR Company", "currency_id": cls.eur_currency.id}
+ cls.test_company_dict = cls.setup_other_company(
+ name="LCR Company",
+ currency_id=cls.eur_currency.id,
)
- cls.account_payable = cls.env["account.account"].create(
+ cls.company = cls.test_company_dict["company"]
+ cls.env.user.write(
{
- "code": "401100XX",
- "name": "Test Payable Account",
- "account_type": "liability_payable",
- "reconcile": True,
- "company_id": cls.company.id,
- }
- )
- cls.account_receivable = cls.env["account.account"].create(
- {
- "code": "411100XX",
- "name": "Test Receivable Account",
- "account_type": "asset_receivable",
- "reconcile": True,
- "company_id": cls.company.id,
- }
- )
- cls.income_account = cls.env["account.account"].create(
- {
- "code": "707000XX",
- "name": "Test Income Account",
- "account_type": "income",
- "company_id": cls.company.id,
+ "groups_id": [
+ Command.link(
+ cls.env.ref("account_payment_order.group_account_payment").id
+ )
+ ],
+ "company_ids": [Command.link(cls.company.id)],
}
)
cls.in_payment_account = cls.env["account.account"].create(
@@ -56,10 +43,9 @@ def setUpClass(cls):
"name": "Test Incoming Payment Account",
"account_type": "asset_current",
"reconcile": True,
- "company_id": cls.company.id,
+ "company_ids": [Command.link(cls.company.id)],
}
)
- cls.company.account_journal_payment_debit_account_id = cls.in_payment_account.id
cls.partner1 = cls.env["res.partner"].create(
{
@@ -117,7 +103,7 @@ def setUpClass(cls):
"company_id": cls.company.id,
"partner_id": cls.company.partner_id.id,
"bank_id": (
- cls.env.ref("account_payment_mode.bank_la_banque_postale").id
+ cls.env.ref("account_payment_base_oca.bank_la_banque_postale").id
),
"acc_number": "FR10 1212 2323 3434 4545 4747 676",
}
@@ -133,23 +119,16 @@ def setUpClass(cls):
"bank_id": cls.company_bank.bank_id.id,
}
)
- cls.sale_journal = cls.env["account.journal"].create(
- {
- "name": "Sale Journal Test",
- "code": "SALE",
- "type": "sale",
- "company_id": cls.company.id,
- "default_account_id": cls.income_account.id,
- }
- )
- cls.payment_mode = cls.env["account.payment.mode"].create(
+ cls.payment_method_line = cls.env["account.payment.method.line"].create(
{
"name": "LCR client",
"company_id": cls.company.id,
"payment_method_id": cls.env.ref("account_banking_fr_lcr.fr_lcr").id,
"bank_account_link": "fixed",
- "fixed_journal_id": cls.bank_journal.id,
+ "journal_id": cls.bank_journal.id,
"fr_lcr_type": "not_accepted",
+ "payment_account_id": cls.in_payment_account.id,
+ "selectable": True,
}
)
@@ -157,7 +136,6 @@ def create_invoice(self, partner_id, price_unit, inv_type="out_invoice", post=Tr
line_vals = {
"name": "Great service",
"quantity": 1,
- "account_id": self.income_account.id,
"price_unit": price_unit,
}
invoice = self.env["account.move"].create(
@@ -165,10 +143,10 @@ def create_invoice(self, partner_id, price_unit, inv_type="out_invoice", post=Tr
"partner_id": partner_id,
"reference_type": "free",
"currency_id": self.eur_currency.id,
+ "company_id": self.company.id,
"move_type": inv_type,
- "journal_id": self.sale_journal.id,
"date": self.today,
- "payment_mode_id": self.payment_mode.id,
+ "preferred_payment_method_line_id": self.payment_method_line.id,
"invoice_line_ids": [Command.create(line_vals)],
}
)
@@ -237,25 +215,26 @@ def lcr_full_scenario(self):
invoice2 = self.create_invoice(self.partner2.id, 42.0)
self.assertEqual(invoice2.fr_lcr_partner_bank_id, self.partner2_bank1)
for inv in [invoice1, invoice2]:
- if inv.payment_mode_fr_lcr_type == "accepted":
+ if inv.payment_method_line_fr_lcr_type == "accepted":
inv.fr_lcr_print()
self.assertTrue(inv.fr_lcr_attachment_id)
action = inv.create_account_payment_line()
self.assertEqual(action["res_model"], "account.payment.order")
payment_order = self.order_obj.browse(action["res_id"])
self.assertEqual(payment_order.payment_type, "inbound")
- self.assertEqual(payment_order.payment_mode_id, self.payment_mode)
+ self.assertEqual(payment_order.payment_method_line_id, self.payment_method_line)
self.assertEqual(payment_order.journal_id, self.bank_journal)
self.assertEqual(
payment_order.fr_lcr_collection_option,
- payment_order.payment_mode_id.fr_lcr_default_collection_option,
+ payment_order.payment_method_line_id.fr_lcr_default_collection_option,
)
self.assertEqual(
- payment_order.fr_lcr_dailly, payment_order.payment_mode_id.fr_lcr_dailly
+ payment_order.fr_lcr_dailly,
+ payment_order.payment_method_line_id.fr_lcr_dailly,
)
self.assertEqual(
payment_order.fr_lcr_dailly_option,
- payment_order.payment_mode_id.fr_lcr_default_dailly_option,
+ payment_order.payment_method_line_id.fr_lcr_default_dailly_option,
)
for line in payment_order.payment_line_ids:
self.assertEqual(
@@ -280,7 +259,7 @@ def lcr_full_scenario(self):
return cfonb_lines
def test_lcr_not_accepted(self):
- self.payment_mode.write(
+ self.payment_method_line.write(
{
"fr_lcr_type": "not_accepted",
"fr_lcr_default_collection_option": "due_date",
@@ -297,7 +276,7 @@ def test_lcr_not_accepted(self):
self.assertEqual(content_line[78], "0") # lcr type
def test_lcr_accepted(self):
- self.payment_mode.write(
+ self.payment_method_line.write(
{
"fr_lcr_type": "accepted",
"fr_lcr_default_collection_option": "cash_discount",
@@ -314,7 +293,7 @@ def test_lcr_accepted(self):
self.assertEqual(content_line[78], "1") # lcr type
def test_lcr_accepted_dailly(self):
- self.payment_mode.write(
+ self.payment_method_line.write(
{
"fr_lcr_type": "accepted",
"fr_lcr_default_collection_option": "due_date",
@@ -333,7 +312,7 @@ def test_lcr_accepted_dailly(self):
self.assertEqual(content_line[78], "1") # lcr type
def test_promissory_note(self):
- self.payment_mode.write(
+ self.payment_method_line.write(
{
"fr_lcr_type": "promissory_note",
"fr_lcr_default_collection_option": "value_cash_discount",
diff --git a/account_banking_fr_lcr/views/account_move.xml b/account_banking_fr_lcr/views/account_move.xml
index 6bd8f211c..a2c674b67 100644
--- a/account_banking_fr_lcr/views/account_move.xml
+++ b/account_banking_fr_lcr/views/account_move.xml
@@ -15,16 +15,17 @@
name="fr_lcr_print"
type="object"
string="Print Bill of Exchange"
- attrs="{'invisible': ['|', '|', '|', ('payment_mode_fr_lcr_type', '!=', 'accepted'), ('state', '!=', 'posted'), ('payment_state', 'not in', ('partial', 'not_paid')), ('move_type', '!=', 'out_invoice')]}"
+ invisible="payment_method_line_fr_lcr_type != 'accepted' or state != 'posted' or payment_state not in ('partial', 'not_paid') or move_type != 'out_invoice'"
/>
-
+
-
+
diff --git a/account_banking_fr_lcr/views/account_payment_mode.xml b/account_banking_fr_lcr/views/account_payment_method_line.xml
similarity index 58%
rename from account_banking_fr_lcr/views/account_payment_mode.xml
rename to account_banking_fr_lcr/views/account_payment_method_line.xml
index f8206c864..a24c459fc 100644
--- a/account_banking_fr_lcr/views/account_payment_mode.xml
+++ b/account_banking_fr_lcr/views/account_payment_method_line.xml
@@ -5,33 +5,30 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
-
- fr_lcr.account.payment.mode.form
- account.payment.mode
+
+ fr_lcr.account.payment.method.line.form
+ account.payment.method.line
-
+
diff --git a/account_banking_fr_lcr/views/account_payment_order.xml b/account_banking_fr_lcr/views/account_payment_order.xml
index 112b1283a..778738971 100644
--- a/account_banking_fr_lcr/views/account_payment_order.xml
+++ b/account_banking_fr_lcr/views/account_payment_order.xml
@@ -15,16 +15,19 @@