|
| 1 | +# Part of OpenG2P. See LICENSE file for full copyright and licensing details. |
| 2 | +import logging |
| 3 | + |
| 4 | +from odoo import api, fields, models |
| 5 | + |
| 6 | +_logger = logging.getLogger(__name__) |
| 7 | + |
| 8 | + |
| 9 | +class G2PResPartnerInherited(models.Model): |
| 10 | + _inherit = "res.partner" |
| 11 | + |
| 12 | + ####################################################### |
| 13 | + ##### Social Status Information ##### |
| 14 | + ####################################################### |
| 15 | + |
| 16 | + num_preg_lact_women = fields.Integer() |
| 17 | + num_malnourished_children = fields.Integer() |
| 18 | + num_disabled = fields.Integer() |
| 19 | + type_of_disability = fields.Selection( |
| 20 | + [ |
| 21 | + ("visual_impairment", "Visual Impairment"), |
| 22 | + ("hearing_impairment", "Hearing Impairment"), |
| 23 | + ("physical_disability", "Physical Disability"), |
| 24 | + ("cognitive_disability", "Cognitive Disability"), |
| 25 | + ] |
| 26 | + ) |
| 27 | + caste_ethnic_group = fields.Selection( |
| 28 | + [ |
| 29 | + ("bantu", "Bantu"), |
| 30 | + ("nilotic", "Nilotic"), |
| 31 | + ("afro_asian", "Afro-Asiatic"), |
| 32 | + ("khoisan", "Khoisan"), |
| 33 | + ("pygmy", "Pygmy"), |
| 34 | + ("other", "Other"), |
| 35 | + ], |
| 36 | + ) |
| 37 | + belong_to_protected_groups = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 38 | + other_vulnerable_status = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 39 | + |
| 40 | + ####################################################### |
| 41 | + ##### Household Details ##### |
| 42 | + ####################################################### |
| 43 | + |
| 44 | + education_level = fields.Selection( |
| 45 | + [ |
| 46 | + ("primary", "Primary"), |
| 47 | + ("secondary", "Secondary"), |
| 48 | + ("higher_secondary", "Higher Secondary"), |
| 49 | + ("bachelors", "Bachelors"), |
| 50 | + ("masters", "Masters"), |
| 51 | + ] |
| 52 | + ) |
| 53 | + employment_status = fields.Selection( |
| 54 | + [ |
| 55 | + ("employed_full", "Employed - Full Time"), |
| 56 | + ("employed_part", "Employed - Part Time"), |
| 57 | + ("self_employed", "Self-employed"), |
| 58 | + ("unemployed", "Unemployed"), |
| 59 | + ] |
| 60 | + ) |
| 61 | + marital_status = fields.Selection( |
| 62 | + [("single", "Single"), ("married", "Married"), ("divorced", "divorced")] |
| 63 | + ) |
| 64 | + |
| 65 | + ####################################################### |
| 66 | + ##### Economic Status Information ##### |
| 67 | + ####################################################### |
| 68 | + |
| 69 | + income_sources = fields.Selection( |
| 70 | + [ |
| 71 | + ("agriculture", "Agriculture"), |
| 72 | + ("business", "Business"), |
| 73 | + ("mining", "Mining"), |
| 74 | + ("manufacturing", "Manufacturing"), |
| 75 | + ("construction", "Construction"), |
| 76 | + ] |
| 77 | + ) |
| 78 | + # Income field was of INT type and it has validation which will cause the errors. |
| 79 | + annual_income = fields.Selection( |
| 80 | + [("below_5000", "Below 5000"), ("5001_10000", "5001-10,000"), ("above_10000", "Above 10,000")], |
| 81 | + ) |
| 82 | + owns_two_wheeler = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 83 | + owns_three_wheeler = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 84 | + owns_four_wheeler = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 85 | + owns_cart = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 86 | + land_ownership = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 87 | + type_of_land_owned = fields.Selection( |
| 88 | + [ |
| 89 | + ("agricultural", "Agricultural Land"), |
| 90 | + ("residential", "Residential Land"), |
| 91 | + ("pastoral", "Pastoral Land"), |
| 92 | + ("forest", "Forest Land"), |
| 93 | + ("commercial", "Commercial Land"), |
| 94 | + ("communal", "Communal Land"), |
| 95 | + ("other", "Other"), |
| 96 | + ] |
| 97 | + ) |
| 98 | + land_size = fields.Float() |
| 99 | + owns_house = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 100 | + owns_livestock = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 101 | + |
| 102 | + ####################################################### |
| 103 | + ##### Housing Condition Information ##### |
| 104 | + ####################################################### |
| 105 | + |
| 106 | + housing_type = fields.Selection( |
| 107 | + [("permanent", "Permanent"), ("temporary", "Temporary")], "Type of Housing" |
| 108 | + ) |
| 109 | + house_condition = fields.Selection([("mud", "Mud"), ("cement", "Cement")]) |
| 110 | + sanitation_condition = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 111 | + water_access = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 112 | + electricity_access = fields.Selection([("yes", "Yes"), ("no", "No")]) |
| 113 | + |
| 114 | + ####################################################### |
| 115 | + ##### Computed Fields ##### |
| 116 | + ####################################################### |
| 117 | + |
| 118 | + is_hh_unemployed = fields.Boolean(compute="_compute_hh_is_unemployed", store=True) |
| 119 | + |
| 120 | + @api.constrains("group_membership_ids", "employment_status") |
| 121 | + def _compute_hh_is_unemployed(self): |
| 122 | + for rec in self: |
| 123 | + group_head = self.env["g2p.group.membership"].get_household_head(rec) |
| 124 | + if group_head: |
| 125 | + rec.is_hh_unemployed = group_head.employment_status == "unemployed" |
| 126 | + else: |
| 127 | + rec.is_hh_unemployed = False |
0 commit comments