diff --git a/contract_sale_tag/README.rst b/contract_sale_tag/README.rst new file mode 100644 index 000000000..c38cfffc9 --- /dev/null +++ b/contract_sale_tag/README.rst @@ -0,0 +1,82 @@ +================= +Contract Sale Tag +================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/14.0/contract_sale_tag + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract_sale_tag + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/110/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to use contract tags when generating sale orders and +transmit them. + +**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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Denis Roussel + +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-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis + +Current `maintainer `__: + +|maintainer-rousseldenis| + +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_tag/__init__.py b/contract_sale_tag/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/contract_sale_tag/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/contract_sale_tag/__manifest__.py b/contract_sale_tag/__manifest__.py new file mode 100644 index 000000000..2ee2fd231 --- /dev/null +++ b/contract_sale_tag/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Contract Sale Tag", + "summary": """ + Allows to transmit contract tags to sale order (through sale_generation)""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/contract", + "maintainers": ["rousseldenis"], + "depends": [ + "contract_sale_generation", + ], + "data": [ + "views/sale_order.xml", + ], +} diff --git a/contract_sale_tag/models/__init__.py b/contract_sale_tag/models/__init__.py new file mode 100644 index 000000000..fffef4df2 --- /dev/null +++ b/contract_sale_tag/models/__init__.py @@ -0,0 +1,2 @@ +from . import sale_order +from . import contract_contract diff --git a/contract_sale_tag/models/contract_contract.py b/contract_sale_tag/models/contract_contract.py new file mode 100644 index 000000000..abd993800 --- /dev/null +++ b/contract_sale_tag/models/contract_contract.py @@ -0,0 +1,17 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class ContractContract(models.Model): + _inherit = "contract.contract" + + def _prepare_sale(self, date_ref): + """ + Fill in contract tag ids on sale order from contract values. + """ + res = super()._prepare_sale(date_ref=date_ref) + if self.tag_ids: + res.update({"contract_tag_ids": [(6, 0, self.tag_ids.ids)]}) + return res diff --git a/contract_sale_tag/models/sale_order.py b/contract_sale_tag/models/sale_order.py new file mode 100644 index 000000000..f338e73b2 --- /dev/null +++ b/contract_sale_tag/models/sale_order.py @@ -0,0 +1,17 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class SaleOrder(models.Model): + + _inherit = "sale.order" + + contract_tag_ids = fields.Many2many( + comodel_name="contract.tag", + relation="sale_order_contract_tag_rel", + column1="order_id", + column2="tag_id", + string="Contract tags", + ) diff --git a/contract_sale_tag/readme/CONTRIBUTORS.rst b/contract_sale_tag/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9179ee4b8 --- /dev/null +++ b/contract_sale_tag/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Roussel diff --git a/contract_sale_tag/readme/DESCRIPTION.rst b/contract_sale_tag/readme/DESCRIPTION.rst new file mode 100644 index 000000000..9c85857d4 --- /dev/null +++ b/contract_sale_tag/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to use contract tags when generating sale orders and +transmit them. diff --git a/contract_sale_tag/setup/.setuptools-odoo-make-default-ignore b/contract_sale_tag/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 000000000..207e61533 --- /dev/null +++ b/contract_sale_tag/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/contract_sale_tag/setup/README b/contract_sale_tag/setup/README new file mode 100644 index 000000000..a63d633e8 --- /dev/null +++ b/contract_sale_tag/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/contract_sale_tag/static/description/icon.png b/contract_sale_tag/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/contract_sale_tag/static/description/icon.png differ diff --git a/contract_sale_tag/static/description/index.html b/contract_sale_tag/static/description/index.html new file mode 100644 index 000000000..603ff0159 --- /dev/null +++ b/contract_sale_tag/static/description/index.html @@ -0,0 +1,422 @@ + + + + + + +Contract Sale Tag + + + +
+

Contract Sale Tag

+ + +

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

+

This module allows to use contract tags when generating sale orders and +transmit them.

+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

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 maintainer:

+

rousseldenis

+

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_tag/tests/__init__.py b/contract_sale_tag/tests/__init__.py new file mode 100644 index 000000000..622c26554 --- /dev/null +++ b/contract_sale_tag/tests/__init__.py @@ -0,0 +1 @@ +from . import test_contract_sale_tag diff --git a/contract_sale_tag/tests/common.py b/contract_sale_tag/tests/common.py new file mode 100644 index 000000000..7b0f6cf0b --- /dev/null +++ b/contract_sale_tag/tests/common.py @@ -0,0 +1,28 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.addons.contract_sale_generation.tests.common import ContractSaleCommon + + +class ContractSaleTagsCommon(ContractSaleCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + # Set Tag 1 and Tag 2 to contract + # Set Tag 3 to contract 2 + cls.contract_tag_obj = cls.env["contract.tag"] + vals = { + "name": "Tag 1", + } + cls.tag_1 = cls.contract_tag_obj.create(vals) + vals = { + "name": "Tag 2", + } + cls.tag_2 = cls.contract_tag_obj.create(vals) + + vals = { + "name": "Tag 3", + } + cls.tag_3 = cls.contract_tag_obj.create(vals) + + cls.contract.tag_ids = cls.tag_1 | cls.tag_2 + cls.contract2.tag_ids = cls.tag_1 diff --git a/contract_sale_tag/tests/test_contract_sale_tag.py b/contract_sale_tag/tests/test_contract_sale_tag.py new file mode 100644 index 000000000..6e6a9a376 --- /dev/null +++ b/contract_sale_tag/tests/test_contract_sale_tag.py @@ -0,0 +1,16 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests.common import SavepointCase + +from .common import ContractSaleTagsCommon + + +class TestContractTagsSale(ContractSaleTagsCommon, SavepointCase): + def test_contract(self): + self.contract.recurring_create_sale() + + sale = self.contract._get_related_sales() + self.assertEquals( + self.contract.tag_ids, + sale.contract_tag_ids, + ) diff --git a/contract_sale_tag/views/sale_order.xml b/contract_sale_tag/views/sale_order.xml new file mode 100644 index 000000000..388d9fa11 --- /dev/null +++ b/contract_sale_tag/views/sale_order.xml @@ -0,0 +1,15 @@ + + + + + sale.order.form (in contract_sale_tag) + sale.order + + + + + + + + diff --git a/setup/contract_sale_tag/odoo/addons/contract_sale_tag b/setup/contract_sale_tag/odoo/addons/contract_sale_tag new file mode 120000 index 000000000..4ac284e49 --- /dev/null +++ b/setup/contract_sale_tag/odoo/addons/contract_sale_tag @@ -0,0 +1 @@ +../../../../contract_sale_tag \ No newline at end of file diff --git a/setup/contract_sale_tag/setup.py b/setup/contract_sale_tag/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/contract_sale_tag/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)