-
-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[17.0][ADD]: partner_contact_block_invoice_address
- Loading branch information
ilo
committed
Sep 24, 2024
1 parent
546003e
commit 9b9ed14
Showing
15 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
================================== | ||
Partner block invoice address type | ||
================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:a5227b4dd58736e4aa51cccff5d71349aecb02920b9fa021ad7193f5fccfd304 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fpartner--contact-lightgray.png?logo=github | ||
:target: https://github.com/OCA/partner-contact/tree/17.0/partner_contact_block_invoice_address | ||
:alt: OCA/partner-contact | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/partner-contact-17-0/partner-contact-17-0-partner_contact_block_invoice_address | ||
: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/partner-contact&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module was written to allow the user to block the creation of | ||
invoice address type. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module : | ||
|
||
1. Go to Settings > Configuration > General Settings | ||
2. Check the box "Partner Block Invoice Address" in the "Block Invoice | ||
Address Type" section | ||
3. Set the default type of address to set when creating a new partner | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_contact_block_invoice_address%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Camptocamp | ||
* Italo LOPES | ||
|
||
Contributors | ||
------------ | ||
|
||
- Italo LOPES <italo.lopes@camptocamp.com> | ||
|
||
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/partner-contact <https://github.com/OCA/partner-contact/tree/17.0/partner_contact_block_invoice_address>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
{ | ||
"name": "Partner block invoice address type", | ||
"summary": "Partner block invoice address type", | ||
"version": "17.0.1.0.0", | ||
"author": "Camptocamp, " "Italo LOPES, " "Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"maintainer": "Camptocamp", | ||
"category": "Extra Tools", | ||
"website": "https://github.com/OCA/partner-contact", | ||
"depends": ["base_setup"], | ||
"data": [ | ||
"views/base_config_view.xml", | ||
], | ||
"auto_install": False, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import base_config_settings | ||
from . import res_partner |
21 changes: 21 additions & 0 deletions
21
partner_contact_block_invoice_address/models/base_config_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
partner_block_invoice_address = fields.Boolean( | ||
config_parameter="partner_block_invoice_address" | ||
) | ||
partner_block_invoice_address_default_type = fields.Selection( | ||
[ | ||
("contact", "Contact"), | ||
("delivery", "Delivery Address"), | ||
("other", "Other Address"), | ||
], | ||
default="other", | ||
config_parameter="partner_block_invoice_address_default_type", | ||
) |
71 changes: 71 additions & 0 deletions
71
partner_contact_block_invoice_address/models/res_partner.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2024 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
|
||
from odoo import _, api, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
def _check_setting_block_invoice_address(self): | ||
partner_block_invoice_address = ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("partner_block_invoice_address") | ||
) | ||
if partner_block_invoice_address == "True": | ||
partner_block_invoice_address_default_type = ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param("partner_block_invoice_address_default_type") | ||
) | ||
return partner_block_invoice_address_default_type | ||
return False | ||
|
||
@api.onchange("type") | ||
def _onchange_contact_type(self): | ||
default_type = self._check_setting_block_invoice_address() | ||
if default_type and self.type == "invoice": | ||
self.type = default_type | ||
return { | ||
"warning": { | ||
"title": _("Warning"), | ||
"message": _( | ||
"You cannot set a contact as an invoice address. " | ||
"Check the settings." | ||
), | ||
}, | ||
} | ||
return {} | ||
|
||
def write(self, vals): | ||
if ( | ||
"type" in vals | ||
and vals["type"] == "invoice" | ||
and self._check_setting_block_invoice_address() | ||
): | ||
raise UserError( | ||
_( | ||
"You cannot set a contact as an invoice address. " | ||
"Check the settings." | ||
) | ||
) | ||
return super().write(vals) | ||
|
||
@api.model_create_multi | ||
def create(self, vals): | ||
for val in vals: | ||
if ( | ||
"type" in val | ||
and val["type"] == "invoice" | ||
and self._check_setting_block_invoice_address() | ||
): | ||
raise UserError( | ||
_( | ||
"You cannot set a contact as an invoice address. " | ||
"Check the settings." | ||
) | ||
) | ||
return super().create(vals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
To configure this module : | ||
1. Go to Settings > Configuration > General Settings | ||
2. Check the box "Partner Block Invoice Address" in the "Block Invoice Address Type" section | ||
3. Set the default type of address to set when creating a new partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Italo LOPES \<<italo.lopes@camptocamp.com>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module was written to allow the user to block the creation of invoice address type. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.