From 2a71564f5bd2afdfe44c802e904cbad1c16e2610 Mon Sep 17 00:00:00 2001 From: Franco Leyes Date: Mon, 8 Jul 2024 17:21:47 -0300 Subject: [PATCH] [ADD] academic_partner_code: add new module --- academic_partner_code/README.rst | 70 +++++++++++++++++++ academic_partner_code/__init__.py | 5 ++ academic_partner_code/__manifest__.py | 38 ++++++++++ .../data/ir_sequence_data.xml | 8 +++ academic_partner_code/models/__init__.py | 5 ++ academic_partner_code/models/res_partner.py | 26 +++++++ .../views/res_partner_views.xml | 25 +++++++ 7 files changed, 177 insertions(+) create mode 100644 academic_partner_code/README.rst create mode 100644 academic_partner_code/__init__.py create mode 100644 academic_partner_code/__manifest__.py create mode 100644 academic_partner_code/data/ir_sequence_data.xml create mode 100644 academic_partner_code/models/__init__.py create mode 100644 academic_partner_code/models/res_partner.py create mode 100644 academic_partner_code/views/res_partner_views.xml diff --git a/academic_partner_code/README.rst b/academic_partner_code/README.rst new file mode 100644 index 00000000..469f1237 --- /dev/null +++ b/academic_partner_code/README.rst @@ -0,0 +1,70 @@ +.. |company| replace:: ADHOC SA + +.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png + :alt: ADHOC SA + :target: https://www.adhoc.com.ar + +.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png + +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +===================== +Academic Partner Code +===================== + +#. This module automatically generates a unique academic code for partners with partner_type set to 'family' using a sequence. By default, a single sequence is created and shared across all companies. To use different sequences for different companies, duplicate the existing sequence or create new ones and define the company field + +Installation +============ + +To install this module, you need to: + +#. Only need to install the module. + +Configuration +============= + +To configure this module, you need to: + +#. Nothing to configure. + +Usage +===== + +To use this module, you need to: + +#. Just use. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: http://runbot.adhoc.com.ar/ + +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. + +Credits +======= + +Images +------ + +* |company| |icon| + +Contributors +------------ + +Maintainer +---------- + +|company_logo| + +This module is maintained by the |company|. + +To contribute to this module, please visit https://www.adhoc.com.ar. diff --git a/academic_partner_code/__init__.py b/academic_partner_code/__init__.py new file mode 100644 index 00000000..d0337769 --- /dev/null +++ b/academic_partner_code/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import models diff --git a/academic_partner_code/__manifest__.py b/academic_partner_code/__manifest__.py new file mode 100644 index 00000000..f5afeaa8 --- /dev/null +++ b/academic_partner_code/__manifest__.py @@ -0,0 +1,38 @@ +############################################################################## +# +# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar) +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Academic Partner Code', + 'version': "17.0.1.0.0", + 'sequence': 14, + 'summary': '', + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'depends': [ + 'academic' + ], + 'data': [ + 'data/ir_sequence_data.xml', + 'views/res_partner_views.xml' + ], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/academic_partner_code/data/ir_sequence_data.xml b/academic_partner_code/data/ir_sequence_data.xml new file mode 100644 index 00000000..2975cfee --- /dev/null +++ b/academic_partner_code/data/ir_sequence_data.xml @@ -0,0 +1,8 @@ + + + Partner academic code + partner.academic.code + 4 + + + diff --git a/academic_partner_code/models/__init__.py b/academic_partner_code/models/__init__.py new file mode 100644 index 00000000..e1331ea4 --- /dev/null +++ b/academic_partner_code/models/__init__.py @@ -0,0 +1,5 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from . import res_partner diff --git a/academic_partner_code/models/res_partner.py b/academic_partner_code/models/res_partner.py new file mode 100644 index 00000000..283f022d --- /dev/null +++ b/academic_partner_code/models/res_partner.py @@ -0,0 +1,26 @@ +############################################################################## +# For copyright and license notices, see __manifest__.py file in module root +# directory +############################################################################## +from odoo import fields, models, api + + +class Partner(models.Model): + _inherit = 'res.partner' + + academic_code = fields.Char( + 'Academic Code', + copy=False, + ) + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('partner_type') == 'family': + vals['academic_code'] = self.env['ir.sequence'].next_by_code('partner.academic.code') + return super().create(vals_list) + + _sql_constraints = { + ('academic_code_uniq', 'unique(academic_code)', + 'Academic Code must be unique!') + } diff --git a/academic_partner_code/views/res_partner_views.xml b/academic_partner_code/views/res_partner_views.xml new file mode 100644 index 00000000..43a89d4f --- /dev/null +++ b/academic_partner_code/views/res_partner_views.xml @@ -0,0 +1,25 @@ + + + academic.partner.form + res.partner + + + + + + + + + + + + academic.partner.search + res.partner + + + + + + + +