diff --git a/agreement_sale_account/README.rst b/agreement_sale_account/README.rst new file mode 100644 index 00000000..8db859b4 --- /dev/null +++ b/agreement_sale_account/README.rst @@ -0,0 +1,93 @@ +====================== +Agreement Sale Account +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4190903fa5a937c32269f83707f5174b8b40393059f6da70e527eebdfd5cdec1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fagreement-lightgray.png?logo=github + :target: https://github.com/OCA/agreement/tree/17.0/agreement_sale_account + :alt: OCA/agreement +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/agreement-17-0/agreement-17-0-agreement_sale_account + :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/agreement&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allow to propagate the ``agreement_id`` from the sale order +to the invoice. This is useful when you want to use an agreement in the +sale order and you want to keep the same agreement in the invoice. + +**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 +------- + +* Camptocamp SA +* Italo Lopes + +Contributors +------------ + +- Italo LOPES + +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. + +.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px + :target: https://github.com/alexis-via + :alt: alexis-via +.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px + :target: https://github.com/bealdav + :alt: bealdav +.. |maintainer-imlopes| image:: https://github.com/imlopes.png?size=40px + :target: https://github.com/imlopes + :alt: imlopes + +Current `maintainers `__: + +|maintainer-alexis-via| |maintainer-bealdav| |maintainer-imlopes| + +This module is part of the `OCA/agreement `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/agreement_sale_account/__init__.py b/agreement_sale_account/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/agreement_sale_account/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/agreement_sale_account/__manifest__.py b/agreement_sale_account/__manifest__.py new file mode 100644 index 00000000..9998d6cd --- /dev/null +++ b/agreement_sale_account/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# @author: Italo Lopes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Agreement Sale Account", + "summary": "Bridge between sales and account", + "version": "17.0.1.0.0", + "category": "Contract", + "author": "Camptocamp SA, Italo Lopes, " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/agreement", + "license": "AGPL-3", + "depends": ["agreement_account", "agreement_sale"], + "data": [], + "development_status": "Beta", + "maintainers": ["alexis-via", "bealdav", "imlopes"], + "installable": True, +} diff --git a/agreement_sale_account/models/__init__.py b/agreement_sale_account/models/__init__.py new file mode 100644 index 00000000..8a0dc04e --- /dev/null +++ b/agreement_sale_account/models/__init__.py @@ -0,0 +1 @@ +from . import sale diff --git a/agreement_sale_account/models/sale.py b/agreement_sale_account/models/sale.py new file mode 100644 index 00000000..4af25bff --- /dev/null +++ b/agreement_sale_account/models/sale.py @@ -0,0 +1,16 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# @author: Italo Lopes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _prepare_invoice(self): + res = super()._prepare_invoice() + if self.agreement_id: + res["agreement_id"] = self.agreement_id.id + return res diff --git a/agreement_sale_account/pyproject.toml b/agreement_sale_account/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/agreement_sale_account/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/agreement_sale_account/readme/CONTRIBUTORS.md b/agreement_sale_account/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..0b564563 --- /dev/null +++ b/agreement_sale_account/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Italo LOPES \<\> diff --git a/agreement_sale_account/readme/DESCRIPTION.md b/agreement_sale_account/readme/DESCRIPTION.md new file mode 100644 index 00000000..96d70557 --- /dev/null +++ b/agreement_sale_account/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module allow to propagate the ``agreement_id`` from the sale order to the invoice. +This is useful when you want to use an agreement in the sale order and you want to keep +the same agreement in the invoice. diff --git a/agreement_sale_account/static/description/icon.png b/agreement_sale_account/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/agreement_sale_account/static/description/icon.png differ diff --git a/agreement_sale_account/static/description/index.html b/agreement_sale_account/static/description/index.html new file mode 100644 index 00000000..862897b7 --- /dev/null +++ b/agreement_sale_account/static/description/index.html @@ -0,0 +1,425 @@ + + + + + +Agreement Sale Account + + + +
+

Agreement Sale Account

+ + +

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

+

This module allow to propagate the agreement_id from the sale order +to the invoice. This is useful when you want to use an agreement in the +sale order and you want to keep the same agreement in the invoice.

+

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

+
    +
  • Camptocamp SA
  • +
  • Italo Lopes
  • +
+
+ +
+

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.

+

Current maintainers:

+

alexis-via bealdav imlopes

+

This module is part of the OCA/agreement project on GitHub.

+

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

+
+
+
+ + diff --git a/agreement_sale_account/tests/__init__.py b/agreement_sale_account/tests/__init__.py new file mode 100644 index 00000000..b636caa9 --- /dev/null +++ b/agreement_sale_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_agreement diff --git a/agreement_sale_account/tests/test_agreement.py b/agreement_sale_account/tests/test_agreement.py new file mode 100644 index 00000000..81271cea --- /dev/null +++ b/agreement_sale_account/tests/test_agreement.py @@ -0,0 +1,47 @@ +# Copyright 2024 Camptocamp SA (https://www.camptocamp.com). +# @author: Italo Lopes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestAgreement(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.test_customer = cls.env["res.partner"].create( + {"name": "Agreement Customer"} + ) + cls.test_agreement_to_propagate = cls.env["agreement"].create( + { + "name": "Test Agreement To Propagate", + "code": "SALE", + "partner_id": cls.test_customer.id, + "domain": "sale", + } + ) + cls.product = cls.env["product.product"].create({"name": "Test product"}) + cls.test_sale_order = cls.env["sale.order"].create( + { + "partner_id": cls.test_customer.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": cls.product.id, + "product_uom_qty": 1, + "price_unit": 100, + }, + ), + ], + } + ) + + def test_01_agreement_propagate(self): + self.test_sale_order.agreement_id = self.test_agreement_to_propagate + self.test_sale_order.action_confirm() + invoice = self.test_sale_order._create_invoices() + + self.assertEqual(invoice.agreement_id, self.test_sale_order.agreement_id) + self.assertEqual(invoice.agreement_id, self.test_agreement_to_propagate)