diff --git a/contract_delivery_zone/README.rst b/contract_delivery_zone/README.rst new file mode 100644 index 000000000..e15ee5c0b --- /dev/null +++ b/contract_delivery_zone/README.rst @@ -0,0 +1,73 @@ +====================== +Contract Delivery Zone +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_delivery_zone + :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_delivery_zone + :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 display the partner delivery zone on contract level. + +**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. + +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_delivery_zone/__init__.py b/contract_delivery_zone/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/contract_delivery_zone/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/contract_delivery_zone/__manifest__.py b/contract_delivery_zone/__manifest__.py new file mode 100644 index 000000000..352552918 --- /dev/null +++ b/contract_delivery_zone/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Contract Delivery Zone", + "summary": """ + Allows to remind the delivery zone defined on the partner on contract level.""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/contract", + "depends": [ + "contract", + "partner_delivery_zone", + ], + "data": ["views/contract_contract.xml"], +} diff --git a/contract_delivery_zone/models/__init__.py b/contract_delivery_zone/models/__init__.py new file mode 100644 index 000000000..acc8a06b7 --- /dev/null +++ b/contract_delivery_zone/models/__init__.py @@ -0,0 +1 @@ +from . import contract_contract diff --git a/contract_delivery_zone/models/contract_contract.py b/contract_delivery_zone/models/contract_contract.py new file mode 100644 index 000000000..8a41cad1d --- /dev/null +++ b/contract_delivery_zone/models/contract_contract.py @@ -0,0 +1,25 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ContractContract(models.Model): + + _inherit = "contract.contract" + + partner_delivery_zone_id = fields.Many2one( + comodel_name="partner.delivery.zone", + index=True, + help="This is the partner delivery zone. If you modify this here, it" + "will be modified on partner too.", + ) + + @api.onchange("partner_id") + def _onchange_partner_id_contract_delivery_zone(self): + for contract in self: + if ( + not contract.partner_delivery_zone_id + and contract.partner_id.delivery_zone_id + ): + contract.partner_delivery_zone_id = contract.partner_id.delivery_zone_id diff --git a/contract_delivery_zone/readme/CONTRIBUTORS.rst b/contract_delivery_zone/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9179ee4b8 --- /dev/null +++ b/contract_delivery_zone/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Denis Roussel diff --git a/contract_delivery_zone/readme/DESCRIPTION.rst b/contract_delivery_zone/readme/DESCRIPTION.rst new file mode 100644 index 000000000..ef2b02dce --- /dev/null +++ b/contract_delivery_zone/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to display the partner delivery zone on contract level. diff --git a/contract_delivery_zone/static/description/icon.png b/contract_delivery_zone/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/contract_delivery_zone/static/description/icon.png differ diff --git a/contract_delivery_zone/static/description/index.html b/contract_delivery_zone/static/description/index.html new file mode 100644 index 000000000..a7cb80a14 --- /dev/null +++ b/contract_delivery_zone/static/description/index.html @@ -0,0 +1,419 @@ + + + + + + +Contract Delivery Zone + + + +
+

Contract Delivery Zone

+ + +

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

+

This module allows to display the partner delivery zone on contract level.

+

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.

+

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_delivery_zone/tests/__init__.py b/contract_delivery_zone/tests/__init__.py new file mode 100644 index 000000000..b07691a12 --- /dev/null +++ b/contract_delivery_zone/tests/__init__.py @@ -0,0 +1 @@ +from . import test_contract_delivery_zone diff --git a/contract_delivery_zone/tests/test_contract_delivery_zone.py b/contract_delivery_zone/tests/test_contract_delivery_zone.py new file mode 100644 index 000000000..7ded7143c --- /dev/null +++ b/contract_delivery_zone/tests/test_contract_delivery_zone.py @@ -0,0 +1,39 @@ +# Copyright 2022 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import Form +from odoo.tests.common import SavepointCase + + +class TestContractBase(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.delivery_zone = cls.env["partner.delivery.zone"].create( + {"name": "Delivery Zone", "code": "10"} + ) + cls.delivery_zone_b = cls.env["partner.delivery.zone"].create( + {"name": "Delivery Zone B", "code": "20"} + ) + cls.partner = cls.env["res.partner"].create( + { + "name": "Contract Delivery Zone Contact", + "email": "demo@demo.com", + "delivery_zone_id": cls.delivery_zone.id, + } + ) + + def test_contract_delivery_zone(self): + # Create a contract with partner + # A default delivery zone should come from him + # Change the zone, it should be well changed + with Form(self.env["contract.contract"]) as contract_form: + contract_form.name = "Contract" + contract_form.partner_id = self.partner + contract = contract_form.save() + self.assertEqual(contract.partner_delivery_zone_id, self.delivery_zone) + + with Form(contract) as contract_form: + contract_form.partner_delivery_zone_id = self.delivery_zone_b + + self.assertEqual(contract.partner_delivery_zone_id, self.delivery_zone_b) diff --git a/contract_delivery_zone/views/contract_contract.xml b/contract_delivery_zone/views/contract_contract.xml new file mode 100644 index 000000000..e8c6d40d4 --- /dev/null +++ b/contract_delivery_zone/views/contract_contract.xml @@ -0,0 +1,53 @@ + + + + + contract.contract form view (in contract_delivery_zone) + contract.contract + + + + + + + + + + contract.contract tree view (in contract_delivery_zone) + contract.contract + + + + + + + + + + contract.contract search view (in contract_delivery_zone) + contract.contract + + + + + + + + + + + + + diff --git a/setup/contract_delivery_zone/odoo/addons/contract_delivery_zone b/setup/contract_delivery_zone/odoo/addons/contract_delivery_zone new file mode 120000 index 000000000..5df7a5d64 --- /dev/null +++ b/setup/contract_delivery_zone/odoo/addons/contract_delivery_zone @@ -0,0 +1 @@ +../../../../contract_delivery_zone \ No newline at end of file diff --git a/setup/contract_delivery_zone/setup.py b/setup/contract_delivery_zone/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/contract_delivery_zone/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)