diff --git a/partner_identification_notification/README.rst b/partner_identification_notification/README.rst new file mode 100644 index 000000000..b199c0358 --- /dev/null +++ b/partner_identification_notification/README.rst @@ -0,0 +1,76 @@ +============================================ +Partner Identification Notification +============================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fpartner--contact-lightgray.png?logo=github + :target: https://github.com/OCA/partner-contact/tree/14.0/partner_identification_notification + :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-14-0/partner-contact-14-0-partner_identification_notification + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/134/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +User can enable notifications on identification categories and specify a # of days to send notifications and what email template to use. + + + +**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 +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Chankya Soni +* Murtaza Mithaiwala + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_identification_notification/__init__.py b/partner_identification_notification/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_identification_notification/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_identification_notification/__manifest__.py b/partner_identification_notification/__manifest__.py new file mode 100644 index 000000000..2ec0dadc3 --- /dev/null +++ b/partner_identification_notification/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright (C) 2021 - TODAY, Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Partner Identification Notification", + "version": "14.0.1.0.0", + "category": "Contact", + "depends": [ + "partner_identification", + ], + "author": "Open Source Integrators," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/partner-contact", + "data": [ + "data/ir_cron_data.xml", + "views/res_partner_id_category_view.xml", + "views/res_partner_id_number_view.xml", + ], + "installable": True, + "application": False, +} diff --git a/partner_identification_notification/data/ir_cron_data.xml b/partner_identification_notification/data/ir_cron_data.xml new file mode 100644 index 000000000..d183598b9 --- /dev/null +++ b/partner_identification_notification/data/ir_cron_data.xml @@ -0,0 +1,13 @@ + + + Partner Identification Notification + 1 + days + -1 + + + + model.send_notification() + code + + diff --git a/partner_identification_notification/models/__init__.py b/partner_identification_notification/models/__init__.py new file mode 100644 index 000000000..6b74a01f9 --- /dev/null +++ b/partner_identification_notification/models/__init__.py @@ -0,0 +1,2 @@ +from . import res_partner_id_category +from . import res_partner_id_number diff --git a/partner_identification_notification/models/res_partner_id_category.py b/partner_identification_notification/models/res_partner_id_category.py new file mode 100644 index 000000000..1e711048c --- /dev/null +++ b/partner_identification_notification/models/res_partner_id_category.py @@ -0,0 +1,22 @@ +from odoo import fields, models + + +class ResPartnerIdCategory(models.Model): + _inherit = "res.partner.id_category" + + def _get_default_id_number_model(self): + return self.env.ref("partner_identification.model_res_partner_id_number").id + + send_notification = fields.Boolean( + string="Send Notification", + ) + days_before_expire = fields.Integer( + string="# of Days Before Expiration", + ) + email_template_id = fields.Many2one( + "mail.template", + string="Email Template", + ) + id_number_model_id = fields.Many2one( + "ir.model", default=_get_default_id_number_model + ) diff --git a/partner_identification_notification/models/res_partner_id_number.py b/partner_identification_notification/models/res_partner_id_number.py new file mode 100644 index 000000000..382b44ca8 --- /dev/null +++ b/partner_identification_notification/models/res_partner_id_number.py @@ -0,0 +1,37 @@ +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models + + +class ResPartnerIdNumber(models.Model): + _name = "res.partner.id_number" + _inherit = ["res.partner.id_number", "mail.thread", "mail.activity.mixin"] + + notification_date = fields.Date(string="Notification Date") + + @api.model + def send_notification(self): + today = fields.date.today() + rec_ids = self.search( + [ + ("category_id.send_notification", "=", True), + ("category_id.days_before_expire", ">", 0), + ("status", "in", ["open", "pending"]), + ] + ) + for rec in rec_ids: + days_before_expire = rec.category_id.days_before_expire + date_from = today - relativedelta(days=days_before_expire) + if ( + rec.valid_until + and days_before_expire + and rec.valid_until >= date_from + and rec.valid_until <= today + and rec.category_id.email_template_id + and not rec.notification_date + ): + rec.notification_date = today + rec.category_id.email_template_id.send_mail( + rec.id, + force_send=True, + ) diff --git a/partner_identification_notification/readme/CONTRIBUTORS.rst b/partner_identification_notification/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..15f5c7ae5 --- /dev/null +++ b/partner_identification_notification/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Chankya Soni +* Murtaza Mithaiwala diff --git a/partner_identification_notification/readme/DESCRIPTION.rst b/partner_identification_notification/readme/DESCRIPTION.rst new file mode 100644 index 000000000..57389da5f --- /dev/null +++ b/partner_identification_notification/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +User can enable notifications on identification categories and specify a # of days to send notifications and what email template to use. diff --git a/partner_identification_notification/static/description/icon.png b/partner_identification_notification/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_identification_notification/static/description/icon.png differ diff --git a/partner_identification_notification/static/description/index.html b/partner_identification_notification/static/description/index.html new file mode 100644 index 000000000..6df1befb0 --- /dev/null +++ b/partner_identification_notification/static/description/index.html @@ -0,0 +1,420 @@ + + + + + + +Partner Identification Notification + + + +
+

Partner Identification Notification

+ + +

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

+

User can enable notifications on identification categories and specify a # of days to send notifications and what email template to use.

+

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

+
    +
  • Open Source Integrators
  • +
+
+ +
+

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/partner-contact project on GitHub.

+

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

+
+
+
+ + diff --git a/partner_identification_notification/views/res_partner_id_category_view.xml b/partner_identification_notification/views/res_partner_id_category_view.xml new file mode 100644 index 000000000..68e3beed0 --- /dev/null +++ b/partner_identification_notification/views/res_partner_id_category_view.xml @@ -0,0 +1,25 @@ + + + res.partner.id_category.from.view.inherit + res.partner.id_category + + + + + + + + + + + diff --git a/partner_identification_notification/views/res_partner_id_number_view.xml b/partner_identification_notification/views/res_partner_id_number_view.xml new file mode 100644 index 000000000..6b5ee8119 --- /dev/null +++ b/partner_identification_notification/views/res_partner_id_number_view.xml @@ -0,0 +1,20 @@ + + + + view.partner.id.numbers.form.inherit.add.chatter + res.partner.id_number + + + +
+ + + +
+
+
+
+
diff --git a/setup/partner_identification_notification/odoo/addons/partner_identification_notification b/setup/partner_identification_notification/odoo/addons/partner_identification_notification new file mode 120000 index 000000000..7a3c92341 --- /dev/null +++ b/setup/partner_identification_notification/odoo/addons/partner_identification_notification @@ -0,0 +1 @@ +../../../../partner_identification_notification \ No newline at end of file diff --git a/setup/partner_identification_notification/setup.py b/setup/partner_identification_notification/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_identification_notification/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)