-
-
Notifications
You must be signed in to change notification settings - Fork 856
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by HaraldPanten
- Loading branch information
Showing
22 changed files
with
908 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,91 @@ | ||
=================== | ||
Contact's Age Range | ||
=================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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_contact_age_range | ||
: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_contact_age_range | ||
: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| | ||
|
||
This module allows to set up age ranges to categorize partners. | ||
|
||
The age range is computed based on the partner's age. | ||
|
||
The cron job will auto compute age range. | ||
|
||
.. image:: https://raw.githubusercontent.com/OCA/partner-contact/14.0/partner_contact_age_range/static/description/age_range.png | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Go to Contact / Configuration / Age Ranges | ||
|
||
Configure your Age Ranges | ||
|
||
.. image:: https://raw.githubusercontent.com/OCA/partner-contact/14.0/partner_contact_age_range/static/description/configure_age_range.png | ||
|
||
Contacts will automatically compute age range based on age. | ||
|
||
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 smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_contact_age_range%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Druidoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Druidoo (<https://www.druidoo.io>) | ||
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th> | ||
|
||
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/14.0/partner_contact_age_range>`_ 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,3 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
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,20 @@ | ||
# Copyright 2019-2020: Druidoo (<https://www.druidoo.io>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Contact's Age Range", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Druidoo, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/partner-contact", | ||
"category": "Customer Relationship Management", | ||
"summary": "Age Range for Contact's", | ||
"depends": ["contacts", "partner_contact_birthdate"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"data/age_range_cron.xml", | ||
"views/res_partner_view.xml", | ||
"views/res_partner_age_range_view.xml", | ||
], | ||
"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,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="ir_cron_partner_age_range" model="ir.cron"> | ||
<field name="name">Contact: Update Age Range</field> | ||
<field name="model_id" ref="model_res_partner" /> | ||
<field name="state">code</field> | ||
<field name="code">model._cron_update_age_range_id()</field> | ||
<field name="user_id" ref="base.user_root" /> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">days</field> | ||
<field name="numbercall">-1</field> | ||
<field name="doall" eval="False" /> | ||
</record> | ||
</odoo> |
119 changes: 119 additions & 0 deletions
119
partner_contact_age_range/i18n/partner_contact_age_range.pot
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,119 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_contact_age_range | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: partner_contact_age_range | ||
#: code:addons/partner_contact_age_range/models/res_partner_age_range.py:0 | ||
#, python-format | ||
msgid "%s is not a valid range (%s >= %s)" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: code:addons/partner_contact_age_range/models/res_partner_age_range.py:0 | ||
#, python-format | ||
msgid "%s is overalapping with range %s" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.constraint,message:partner_contact_age_range.constraint_res_partner_age_range_name_uniq | ||
msgid "A name must be unique !" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner__age_range_id | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_users__age_range_id | ||
msgid "Age Range" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.actions.act_window,name:partner_contact_age_range.action_partner_age_range | ||
#: model:ir.ui.menu,name:partner_contact_age_range.menu_partner_age_range | ||
msgid "Age Ranges" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model,name:partner_contact_age_range.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.actions.server,name:partner_contact_age_range.ir_cron_partner_age_range_ir_actions_server | ||
#: model:ir.cron,cron_name:partner_contact_age_range.ir_cron_partner_age_range | ||
#: model:ir.cron,name:partner_contact_age_range.ir_cron_partner_age_range | ||
msgid "Contact: Update Age Range" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__create_uid | ||
msgid "Created by" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__create_date | ||
msgid "Created on" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__age_from | ||
msgid "From" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__write_uid | ||
msgid "Last Updated by" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__write_date | ||
msgid "Last Updated on" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model_terms:ir.actions.act_window,help:partner_contact_age_range.action_partner_age_range | ||
msgid "" | ||
"Manage the contact age range you want to have available in your system.\n" | ||
" For eg: 0-10, 11-20" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__name | ||
msgid "Name" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model,name:partner_contact_age_range.model_res_partner_age_range | ||
#: model_terms:ir.ui.view,arch_db:partner_contact_age_range.view_partner_age-range_tree | ||
#: model_terms:ir.ui.view,arch_db:partner_contact_age_range.view_partner_age_range_form | ||
msgid "Partner Age Range" | ||
msgstr "" | ||
|
||
#. module: partner_contact_age_range | ||
#: model:ir.model.fields,field_description:partner_contact_age_range.field_res_partner_age_range__age_to | ||
msgid "To" | ||
msgstr "" |
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 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import res_partner_age_range | ||
from . import res_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,42 @@ | ||
# Copyright 2019-2020: Druidoo (<https://www.druidoo.io>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
age_range_id = fields.Many2one( | ||
"res.partner.age.range", | ||
"Age Range", | ||
compute="_compute_age_range_id", | ||
store=True, | ||
) | ||
|
||
@api.depends("age") | ||
def _compute_age_range_id(self): | ||
age_ranges = self.env["res.partner.age.range"].search([]) | ||
for record in self: | ||
if not record.age: | ||
age_range = False | ||
else: | ||
age_range = ( | ||
age_ranges.filtered( | ||
lambda age_range: age_range.age_from | ||
<= record.age | ||
<= age_range.age_to | ||
) | ||
or False | ||
) | ||
if record.age_range_id != age_range: | ||
record.age_range_id = age_range and age_range.id or age_range | ||
|
||
@api.model | ||
def _cron_update_age_range_id(self): | ||
""" | ||
This method is called from a cron job. | ||
It is used to update age range on contact | ||
""" | ||
partners = self.search([("birthdate_date", "!=", False)]) | ||
partners._compute_age_range_id() |
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,48 @@ | ||
# Copyright 2019-2020: Druidoo (<https://www.druidoo.io>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class ResPartnerDateRange(models.Model): | ||
_name = "res.partner.age.range" | ||
_description = "Partner Age Range" | ||
|
||
def _default_age_from(self): | ||
age_from = 0 | ||
last_age_range = self.env["res.partner.age.range"].search( | ||
[], order="age_to desc", limit=1 | ||
) | ||
if last_age_range: | ||
age_from = last_age_range.age_to + 1 | ||
return age_from | ||
|
||
name = fields.Char(string="Name", required=True) | ||
age_from = fields.Integer( | ||
string="From", required=True, default=lambda self: self._default_age_from() | ||
) | ||
age_to = fields.Integer(string="To", required=True) | ||
|
||
_sql_constraints = [("name_uniq", "unique (name)", "A name must be unique !")] | ||
|
||
@api.constrains("age_from", "age_to") | ||
def _validate_range(self): | ||
for rec in self: | ||
if rec.age_from >= rec.age_to: | ||
raise ValidationError( | ||
_("%s is not a valid range (%s >= %s)") | ||
% (rec.name, rec.age_from, rec.age_to) | ||
) | ||
range_id = rec.search( | ||
[ | ||
("age_from", "<=", rec.age_to), | ||
("age_to", ">=", rec.age_from), | ||
("id", "!=", rec.id), | ||
], | ||
limit=1, | ||
) | ||
if range_id: | ||
raise ValidationError( | ||
_("%s is overalapping with range %s") % (rec.name, range_id.name) | ||
) |
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 @@ | ||
* Druidoo (<https://www.druidoo.io>) | ||
* Tharathip Chaweewongphan <tharathipc@ecosoft.co.th> |
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,7 @@ | ||
This module allows to set up age ranges to categorize partners. | ||
|
||
The age range is computed based on the partner's age. | ||
|
||
The cron job will auto compute age range. | ||
|
||
.. image:: ../static/description/age_range.png |
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,7 @@ | ||
Go to Contact / Configuration / Age Ranges | ||
|
||
Configure your Age Ranges | ||
|
||
.. image:: ../static/description/configure_age_range.png | ||
|
||
Contacts will automatically compute age range based on age. |
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 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_res_partner_age_range_admin,access_res_partner_age_range_admin,model_res_partner_age_range,base.group_partner_manager,1,1,1,1 | ||
access_res_partner_age_range_user,access_res_partner_age_range_user,model_res_partner_age_range,base.group_user,1,0,0,0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.