-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '17.0-develop' of https://github.com/OpenG2P/openg2p-soc…
…ial-registry into 17.0-sr-dashboard
- Loading branch information
Showing
15 changed files
with
561 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
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 @@ | ||
# G2P Social Registry: PMT | ||
|
||
Refer to https://docs.openg2p.org. |
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 @@ | ||
# Part of OpenG2P. See LICENSE file for full copyright and licensing details. | ||
|
||
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,23 @@ | ||
# Part of OpenG2P. See LICENSE file for full copyright and licensing details. | ||
{ | ||
"name": "G2P Social Registry: PMT", | ||
"category": "G2P", | ||
"version": "17.0.0.0.0", | ||
"sequence": 1, | ||
"author": "OpenG2P", | ||
"website": "https://openg2p.org", | ||
"license": "LGPL-3", | ||
"depends": ["base", "web", "g2p_registry_base", "g2p_social_registry"], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/pmt_config_view.xml", | ||
"views/individual_view.xml", | ||
"views/group_view.xml", | ||
], | ||
"assets": {}, | ||
"demo": [], | ||
"images": [], | ||
"application": True, | ||
"installable": True, | ||
"auto_install": False, | ||
} |
162 changes: 162 additions & 0 deletions
162
g2p_social_registry_proxy_means_test/i18n/g2p_social_registry_proxy_means_test.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,162 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * g2p_social_registry_proxy_means_test | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.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: g2p_social_registry_proxy_means_test | ||
#. odoo-python | ||
#: code:addons/g2p_social_registry_proxy_means_test/models/proxy_means_test_params.py:0 | ||
#: code:addons/g2p_social_registry_proxy_means_test/models/proxy_means_test_params.py:0 | ||
#: code:addons/g2p_social_registry_proxy_means_test/models/proxy_means_test_params.py:0 | ||
#: code:addons/g2p_social_registry_proxy_means_test/models/proxy_means_test_params.py:0 | ||
#, python-format | ||
msgid "A Proxy Means Test for this kind and target already exists." | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model,name:g2p_social_registry_proxy_means_test.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model_terms:ir.actions.act_window,help:g2p_social_registry_proxy_means_test.action_pmt_config | ||
msgid "Create a new PMT!" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__create_uid | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__create_uid | ||
msgid "Created by" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__create_date | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__create_date | ||
msgid "Created on" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__display_name | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__pmt_field | ||
msgid "Field" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields.selection,name:g2p_social_registry_proxy_means_test.selection__sr_proxy_means_test_params__target__group | ||
msgid "Group" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__id | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields.selection,name:g2p_social_registry_proxy_means_test.selection__sr_proxy_means_test_params__target__individual | ||
msgid "Individual" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__kind | ||
msgid "Kind" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__write_uid | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__write_uid | ||
msgid "Last Updated by" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__write_date | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__write_date | ||
msgid "Last Updated on" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.actions.act_window,name:g2p_social_registry_proxy_means_test.action_pmt_config | ||
#: model:ir.ui.menu,name:g2p_social_registry_proxy_means_test.menu_pmt_config | ||
#: model_terms:ir.ui.view,arch_db:g2p_social_registry_proxy_means_test.view_pmt_config_form | ||
msgid "PMT Config" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__pmt_name | ||
msgid "PMT Name" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model_terms:ir.ui.view,arch_db:g2p_social_registry_proxy_means_test.view_pmt_config_form | ||
msgid "PMT Params" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_res_partner__pmt_score | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_res_users__pmt_score | ||
#: model_terms:ir.ui.view,arch_db:g2p_social_registry_proxy_means_test.view_group_form_inherit | ||
msgid "PMT Score" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model_terms:ir.ui.view,arch_db:g2p_social_registry_proxy_means_test.view_group_form_inherit | ||
#: model_terms:ir.ui.view,arch_db:g2p_social_registry_proxy_means_test.view_individual_form_inherit | ||
msgid "PMT Score:" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__pmt_id | ||
msgid "Proxy Means Test" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model,name:g2p_social_registry_proxy_means_test.model_sr_proxy_means_test_line | ||
msgid "Proxy Means Test Line" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__pmt_line_ids | ||
msgid "Proxy Means Test Lines" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model,name:g2p_social_registry_proxy_means_test.model_sr_proxy_means_test_params | ||
msgid "Proxy Means Test Params" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__target | ||
msgid "Target" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_params__target_name | ||
msgid "Target Name" | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#. odoo-python | ||
#: code:addons/g2p_social_registry_proxy_means_test/models/proxy_means_test_line.py:0 | ||
#, python-format | ||
msgid "The combination of PMT field and weightage already exist." | ||
msgstr "" | ||
|
||
#. module: g2p_social_registry_proxy_means_test | ||
#: model:ir.model.fields,field_description:g2p_social_registry_proxy_means_test.field_sr_proxy_means_test_line__pmt_weightage | ||
msgid "Weightage" | ||
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 @@ | ||
# Part of OpenG2P. See LICENSE file for full copyright and licensing details. | ||
from . import proxy_means_test_line | ||
from . import proxy_means_test_params | ||
from . import res_partner |
70 changes: 70 additions & 0 deletions
70
g2p_social_registry_proxy_means_test/models/proxy_means_test_line.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,70 @@ | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class SRProxyMeanTestLine(models.Model): | ||
_name = "sr.proxy.means.test.line" | ||
_description = "Proxy Means Test Line" | ||
|
||
pmt_id = fields.Many2one("sr.proxy.means.test.params", string="Proxy Means Test") | ||
pmt_field = fields.Selection(selection="get_fields_label", string="Field") | ||
pmt_weightage = fields.Float(string="Weightage") | ||
|
||
@api.constrains("pmt_id", "pmt_field") | ||
def _check_unique_field_weightage(self): | ||
for line in self: | ||
duplicate = self.search_count( | ||
[("pmt_id", "=", line.pmt_id.id), ("pmt_field", "=", line.pmt_field), ("id", "!=", line.id)] | ||
) | ||
if duplicate: | ||
raise ValidationError(_("The combination of PMT field and weightage already exist.")) | ||
|
||
def get_fields_label(self): | ||
reg_info = self.env["res.partner"] | ||
ir_model_obj = self.env["ir.model.fields"] | ||
excluded_fields = { | ||
"pmt_score", | ||
"message_needaction_counter", | ||
"message_has_error_counter", | ||
"message_attachment_count", | ||
"message_bounce", | ||
"active_lang_count", | ||
"partner_latitude", | ||
"partner_longitude", | ||
"color", | ||
"id", | ||
"meeting_count", | ||
"employees_count", | ||
"partner_gid", | ||
"certifications_count", | ||
"certifications_company_count", | ||
"event_count", | ||
"payment_token_count", | ||
"days_sales_outstanding", | ||
"journal_item_count", | ||
"bank_account_count", | ||
"supplier_rank", | ||
"customer_rank", | ||
"duplicated_bank_account_partners_count", | ||
"task_count", | ||
"z_ind_grp_num_individuals", | ||
"program_membership_count", | ||
"entitlements_count", | ||
"cycles_count", | ||
"inkind_entitlements_count", | ||
"credit_limit", | ||
} | ||
|
||
choice = [] | ||
for field in reg_info._fields.items(): | ||
ir_model_field = ir_model_obj.search([("model", "=", "res.partner"), ("name", "=", field[0])]) | ||
field_type = ir_model_field.ttype | ||
if field_type in ["integer", "float"] and field[0] not in excluded_fields: | ||
choice.append((field[0], field[0])) | ||
return choice | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
for line in self: | ||
line.pmt_id.compute_related_partners_pmt_score() | ||
return res |
92 changes: 92 additions & 0 deletions
92
g2p_social_registry_proxy_means_test/models/proxy_means_test_params.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,92 @@ | ||
from odoo import _, api, fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class SRProxyMeanTestParams(models.Model): | ||
_name = "sr.proxy.means.test.params" | ||
_description = "Proxy Means Test Params" | ||
_rec_name = "pmt_name" | ||
|
||
pmt_name = fields.Char( | ||
string="PMT Name", | ||
) | ||
target = fields.Selection( | ||
[("individual", "Individual"), ("group", "Group")], | ||
) | ||
kind = fields.Many2one( | ||
"g2p.group.kind", | ||
) | ||
|
||
pmt_line_ids = fields.One2many("sr.proxy.means.test.line", "pmt_id", string="Proxy Means Test Lines") | ||
|
||
target_name = fields.Boolean(default=True) | ||
|
||
@api.onchange("target") | ||
def _onchange_target(self): | ||
if self.target == "group": | ||
self.write({"target_name": False}) | ||
else: | ||
self.write({"target_name": True}) | ||
|
||
@api.constrains("target", "kind") | ||
def _check_unique_pmt(self): | ||
for rec in self: | ||
existing_pmt = self.search_count( | ||
[("target", "=", rec.target), ("kind", "=", rec.kind.id), ("id", "!=", rec.id)] | ||
) | ||
|
||
if existing_pmt > 0: | ||
raise ValidationError(_("A Proxy Means Test for this kind and target already exists.")) | ||
|
||
@api.model | ||
def create(self, vals): | ||
if "target" in vals and "kind" in vals: | ||
existing_pmt = self.search_count([("target", "=", vals["target"]), ("kind", "=", vals["kind"])]) | ||
if existing_pmt > 0: | ||
raise ValidationError(_("A Proxy Means Test for this kind and target already exists.")) | ||
|
||
rec = super().create(vals) | ||
rec.compute_related_partners_pmt_score() | ||
return rec | ||
|
||
def write(self, vals): | ||
for rec in self: | ||
if "target" in vals and vals["target"] != rec.target: | ||
existing_pmt = self.search_count( | ||
[("target", "=", vals["target"]), ("kind", "=", rec.kind.id), ("id", "!=", rec.id)] | ||
) | ||
if existing_pmt > 0: | ||
raise ValidationError(_("A Proxy Means Test for this kind and target already exists.")) | ||
|
||
if "kind" in vals and vals["kind"] != rec.kind.id: | ||
existing_pmt = self.search_count( | ||
[("target", "=", rec.target), ("kind", "=", vals["kind"]), ("id", "!=", rec.id)] | ||
) | ||
if existing_pmt > 0: | ||
raise ValidationError(_("A Proxy Means Test for this kind and target already exists.")) | ||
|
||
rec = super().write(vals) | ||
for record in self: | ||
record.compute_related_partners_pmt_score() | ||
return rec | ||
|
||
def unlink(self): | ||
for rec in self: | ||
partners = self.env["res.partner"].search([("kind", "=", rec.kind.id)]) | ||
for partner in partners: | ||
partner.pmt_score = 0 | ||
|
||
rec.pmt_line_ids.unlink() | ||
return super().unlink() | ||
|
||
def compute_related_partners_pmt_score(self): | ||
if ( | ||
not self.target | ||
or not self.pmt_name | ||
or not self.pmt_line_ids | ||
or (self.target == "group" and not self.kind) | ||
): | ||
return | ||
partners = self.env["res.partner"].search([("kind", "=", self.kind.id)]) | ||
for partner in partners: | ||
partner._compute_pmt_score() |
Oops, something went wrong.