diff --git a/contract_sale_generation_payment_mode/README.rst b/contract_sale_generation_payment_mode/README.rst new file mode 100644 index 0000000000..48c36b8b2c --- /dev/null +++ b/contract_sale_generation_payment_mode/README.rst @@ -0,0 +1,71 @@ +====================================== +Contracts Sale Generation Payment Mode +====================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f86ca92372fb642d644f7a98d63c9db3ed81232c8ad02ef4afa66bddc64ec2f6 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github + :target: https://github.com/OCA/contract/tree/16.0/contract_sale_generation_payment_mode + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract_sale_generation_payment_mode + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Set the payment mode from the contract on sales orders created by the contract. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Coop IT Easy SC + +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/contract `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/contract_sale_generation_payment_mode/__init__.py b/contract_sale_generation_payment_mode/__init__.py new file mode 100644 index 0000000000..a6c9053e30 --- /dev/null +++ b/contract_sale_generation_payment_mode/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2025 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import models diff --git a/contract_sale_generation_payment_mode/__manifest__.py b/contract_sale_generation_payment_mode/__manifest__.py new file mode 100644 index 0000000000..bae018ffb7 --- /dev/null +++ b/contract_sale_generation_payment_mode/__manifest__.py @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2025 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ + "name": "Contracts Sale Generation Payment Mode", + "summary": "Set contract payment mode on contract-generated sales orders", + "version": "16.0.1.0.0", + "category": "Contract Management", + "license": "AGPL-3", + "author": "Coop IT Easy SC, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/contract", + "depends": [ + "contract_sale_generation", + "contract_payment_mode", + ], +} diff --git a/contract_sale_generation_payment_mode/models/__init__.py b/contract_sale_generation_payment_mode/models/__init__.py new file mode 100644 index 0000000000..ac9d6ef9c6 --- /dev/null +++ b/contract_sale_generation_payment_mode/models/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2025 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import contract diff --git a/contract_sale_generation_payment_mode/models/contract.py b/contract_sale_generation_payment_mode/models/contract.py new file mode 100644 index 0000000000..cf38705215 --- /dev/null +++ b/contract_sale_generation_payment_mode/models/contract.py @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2025 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo import models + + +class ContractContract(models.Model): + _inherit = "contract.contract" + + def _prepare_recurring_sales_values(self, date_ref=False): + res = super()._prepare_recurring_sales_values(date_ref) + if res: + res[0]["payment_mode_id"] = self.payment_mode_id.id + return res diff --git a/contract_sale_generation_payment_mode/readme/DESCRIPTION.rst b/contract_sale_generation_payment_mode/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..f416c198b2 --- /dev/null +++ b/contract_sale_generation_payment_mode/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Set the payment mode from the contract on sales orders created by the contract. diff --git a/contract_sale_generation_payment_mode/static/description/index.html b/contract_sale_generation_payment_mode/static/description/index.html new file mode 100644 index 0000000000..f8f93d1bcc --- /dev/null +++ b/contract_sale_generation_payment_mode/static/description/index.html @@ -0,0 +1,413 @@ + + + + + +Contracts Sale Generation Payment Mode + + + +
+

Contracts Sale Generation Payment Mode

+ + +

Beta License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

+

Set the payment mode from the contract on sales orders created by the contract.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Coop IT Easy SC
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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/contract project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/contract_sale_generation_payment_mode/tests/__init__.py b/contract_sale_generation_payment_mode/tests/__init__.py new file mode 100644 index 0000000000..e0cda5195f --- /dev/null +++ b/contract_sale_generation_payment_mode/tests/__init__.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2025 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from . import test_contract_payment diff --git a/contract_sale_generation_payment_mode/tests/test_contract_payment.py b/contract_sale_generation_payment_mode/tests/test_contract_payment.py new file mode 100644 index 0000000000..972efa09bd --- /dev/null +++ b/contract_sale_generation_payment_mode/tests/test_contract_payment.py @@ -0,0 +1,73 @@ +# SPDX-FileCopyrightText: 2025 Coop IT Easy SC +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + +from odoo.addons.contract_sale_generation.tests.common import ContractSaleCommon + + +@tagged("post_install", "-at_install") +class TestContractSaleGenerationPaymentMode(ContractSaleCommon, TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.payment_method = cls.env["account.payment.method"].create( + { + "name": "Test Payment Method", + "code": "Test", + "payment_type": "inbound", + } + ) + + cls.payment_mode = cls.env["account.payment.mode"].create( + { + "name": "Test payment mode", + "active": True, + "payment_method_id": cls.payment_method.id, + "bank_account_link": "variable", + } + ) + + cls.contract = cls.env["contract.contract"].create( + { + "name": "Test", + "partner_id": cls.partner.id, + "payment_mode_id": cls.payment_mode.id, + "line_recurrence": True, + "contract_type": "sale", + "recurring_interval": 1, + "recurring_rule_type": "monthly", + "date_start": "2018-01-15", + "contract_line_ids": [ + ( + 0, + 0, + { + "product_id": cls.product_1.id, + "name": "Database Administration 25", + "quantity": 2.0, + "uom_id": cls.product_1.uom_id.id, + "price_unit": 200.0, + }, + ) + ], + } + ) + + def test_contract_sale_generation_with_payment_mode(self): + order = self.contract.recurring_create_sale()[0] + self.assertEqual(self.payment_mode, order.payment_mode_id) + + def test_contract_sale_generation_without_payment_mode(self): + self.contract.payment_mode_id = False + order = self.contract.recurring_create_sale()[0] + self.assertFalse(self.contract.payment_mode_id) + self.assertFalse(order.payment_mode_id) + + def test_contract_sale_generation_generation_no_contract_line(self): + self.contract.contract_line_ids.cancel() + self.contract.contract_line_ids = False + order = self.contract.recurring_create_sale() + self.assertFalse(order) diff --git a/setup/contract_sale_generation_payment_mode/odoo/addons/contract_sale_generation_payment_mode b/setup/contract_sale_generation_payment_mode/odoo/addons/contract_sale_generation_payment_mode new file mode 120000 index 0000000000..5943ea8886 --- /dev/null +++ b/setup/contract_sale_generation_payment_mode/odoo/addons/contract_sale_generation_payment_mode @@ -0,0 +1 @@ +../../../../contract_sale_generation_payment_mode \ No newline at end of file diff --git a/setup/contract_sale_generation_payment_mode/setup.py b/setup/contract_sale_generation_payment_mode/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/contract_sale_generation_payment_mode/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)