Maintainers
+Maintainers
This module is maintained by the OCA.

diff --git a/sale_partner_address_restrict/README.rst b/sale_partner_address_restrict/README.rst index 113233026a0d..cb1dbd6c4983 100644 --- a/sale_partner_address_restrict/README.rst +++ b/sale_partner_address_restrict/README.rst @@ -7,7 +7,7 @@ Sale Partner Address Restrict !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:026c9b3f140a8467f57aa94ea7d898de824516f18656d2d7e750a60246399e3b + !! source digest: sha256:8861897ace83b8b0b2d9fea26ce71f146cc21b0b46a00ea4fb331af9a2dcf963 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -36,6 +36,15 @@ to only addresses of the selected customer. .. contents:: :local: +Configuration +============= + +- Go to Sales > Configuration > Settings > Quotation & Orders > Sale + Partner Address Restriction +- Check the box if you want to restrict available partners for Delivery + and Invoicing addresses to partners that belong to the selected + Customer. + Bug Tracker =========== diff --git a/sale_partner_address_restrict/__manifest__.py b/sale_partner_address_restrict/__manifest__.py index 11cff40f3269..8bfc4d4c76b2 100644 --- a/sale_partner_address_restrict/__manifest__.py +++ b/sale_partner_address_restrict/__manifest__.py @@ -14,5 +14,5 @@ "depends": [ "sale", ], - "data": ["views/sale_order_view.xml"], + "data": ["views/sale_order_view.xml", "views/res_config_settings.xml"], } diff --git a/sale_partner_address_restrict/models/__init__.py b/sale_partner_address_restrict/models/__init__.py index 6aacb753131f..20972a4c7d29 100644 --- a/sale_partner_address_restrict/models/__init__.py +++ b/sale_partner_address_restrict/models/__init__.py @@ -1 +1,3 @@ from . import sale_order +from . import res_company +from . import res_config_settings diff --git a/sale_partner_address_restrict/models/res_company.py b/sale_partner_address_restrict/models/res_company.py new file mode 100644 index 000000000000..ac0b000eb3da --- /dev/null +++ b/sale_partner_address_restrict/models/res_company.py @@ -0,0 +1,13 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + sale_partner_address_restriction = fields.Boolean( + help="Check this box if you want to restrict partner addresses selection " + "in sale orders. They should depends on the Customer filled in." + ) diff --git a/sale_partner_address_restrict/models/res_config_settings.py b/sale_partner_address_restrict/models/res_config_settings.py new file mode 100644 index 000000000000..d354e3aaa456 --- /dev/null +++ b/sale_partner_address_restrict/models/res_config_settings.py @@ -0,0 +1,13 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + sale_partner_address_restriction = fields.Boolean( + related="company_id.sale_partner_address_restriction", + readonly=False, + ) diff --git a/sale_partner_address_restrict/models/sale_order.py b/sale_partner_address_restrict/models/sale_order.py index 1e77c7de028f..29a65077dcd0 100644 --- a/sale_partner_address_restrict/models/sale_order.py +++ b/sale_partner_address_restrict/models/sale_order.py @@ -8,9 +8,16 @@ class SaleOrder(models.Model): @api.constrains("partner_id", "partner_invoice_id", "partner_shipping_id") def _check_partner_addresses(self): for order in self: - if order.partner_id and ( - (order.partner_invoice_id.commercial_partner_id != order.partner_id) - or (order.partner_shipping_id.commercial_partner_id != order.partner_id) + if ( + order.company_id.sale_partner_address_restriction + and order.partner_id + and ( + (order.partner_invoice_id.commercial_partner_id != order.partner_id) + or ( + order.partner_shipping_id.commercial_partner_id + != order.partner_id + ) + ) ): raise ValidationError( _( diff --git a/sale_partner_address_restrict/readme/CONFIGURE.md b/sale_partner_address_restrict/readme/CONFIGURE.md new file mode 100644 index 000000000000..3cc2274d7515 --- /dev/null +++ b/sale_partner_address_restrict/readme/CONFIGURE.md @@ -0,0 +1,3 @@ +- Go to Sales \> Configuration \> Settings \> Quotation & Orders \> Sale Partner Address Restriction +- Check the box if you want to restrict available partners for Delivery and Invoicing addresses to + partners that belong to the selected Customer. diff --git a/sale_partner_address_restrict/static/description/index.html b/sale_partner_address_restrict/static/description/index.html index f3ef289a5655..05dc65bde274 100644 --- a/sale_partner_address_restrict/static/description/index.html +++ b/sale_partner_address_restrict/static/description/index.html @@ -367,7 +367,7 @@
This module restricts the addresses to be used in the sales order form @@ -375,17 +375,28 @@
Table of contents
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 @@ -393,21 +404,21 @@
Do not contact contributors directly about support or help with technical issues.
This module is maintained by the OCA.