diff --git a/bemade_sethy_configuration/__init__.py b/bemade_sethy_configuration/__init__.py new file mode 100644 index 0000000..95dfc91 --- /dev/null +++ b/bemade_sethy_configuration/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/bemade_sethy_configuration/__manifest__.py b/bemade_sethy_configuration/__manifest__.py new file mode 100644 index 0000000..da5c4cf --- /dev/null +++ b/bemade_sethy_configuration/__manifest__.py @@ -0,0 +1,54 @@ + +# -*- coding: utf-8 -*- +{ + 'name': 'Bemade Sethy', + 'version': '1.0', + 'category': 'Specific Module Category', # Specify your module's category here + 'summary': "This module is developed by Bemade to instantiate the Sethy's Odoo", + 'author': 'Bemade', + 'website': 'https://bemade.org', + 'email': 'it@bemade.org', + 'license': 'GPL-3', + 'depends': [ + # List of module dependencies + 'base', + 'contacts', + 'crm', + 'document_knowledge', + 'document_page', + 'document_page_approval', + 'attachment_indexation', + 'l10n_ca', + 'membership_variable_period', + 'membership_delegated_partner', + 'partner_multi_relation', + 'sale_management' + ], + 'data': [ + # Reference to XML, CSV, and other data files + 'data/membership_category_data.xml', + 'data/product_template_data.xml', + 'data/partner_category_data.xml', + 'data/partner_relation_type_data.xml', + 'data/company_data.xml', + 'views/res_partner_relation_views.xml', +# 'views/membership_membership_line.xml', + 'views/res_partner_views.xml', + + ], + 'demo': [ + # Reference to demo data files + ], + 'installable': True, + 'auto_install': False, + 'application': False, # Set to True if the module is an app + 'description': """ +Main module for Fondation Séthy +================================== +This module installs base components and will also set up default values according to the Fondation Séthy. + +This will allow us to put all the customization here and add other modules from Oca or our repos if needed. + +Only code specific to Fondation Sethy resides in this module, the reusable stuff should be put in other small dedicated modules elsewhere +""", +} diff --git a/bemade_sethy_configuration/data/company_data.xml b/bemade_sethy_configuration/data/company_data.xml new file mode 100644 index 0000000..3ab45b6 --- /dev/null +++ b/bemade_sethy_configuration/data/company_data.xml @@ -0,0 +1,20 @@ + + + + + + Fondation Séthy + https://fondationsethy.org + info@fondationsethy.org + 164, rue Cowie + local 335 + Granby + + J2G 3V3 + + 450 994-3173 + + + + + diff --git a/bemade_sethy_configuration/data/membership_category_data.xml b/bemade_sethy_configuration/data/membership_category_data.xml new file mode 100644 index 0000000..0070139 --- /dev/null +++ b/bemade_sethy_configuration/data/membership_category_data.xml @@ -0,0 +1,11 @@ + + + + + Perpetual Membership + + + Annual Membership + + + diff --git a/bemade_sethy_configuration/data/partner_category_data.xml b/bemade_sethy_configuration/data/partner_category_data.xml new file mode 100644 index 0000000..b71dae6 --- /dev/null +++ b/bemade_sethy_configuration/data/partner_category_data.xml @@ -0,0 +1,13 @@ + + + + + Property + 7 + + + Owner + 4 + + + diff --git a/bemade_sethy_configuration/data/partner_relation_type_data.xml b/bemade_sethy_configuration/data/partner_relation_type_data.xml new file mode 100644 index 0000000..46080a3 --- /dev/null +++ b/bemade_sethy_configuration/data/partner_relation_type_data.xml @@ -0,0 +1,11 @@ + + + + + Owner + Property + c + + + + diff --git a/bemade_sethy_configuration/data/product_template_data.xml b/bemade_sethy_configuration/data/product_template_data.xml new file mode 100644 index 0000000..a1a2b36 --- /dev/null +++ b/bemade_sethy_configuration/data/product_template_data.xml @@ -0,0 +1,35 @@ + + + + + + + + Perpetual Membership + + service + 2000-01-01 + 2100-01-01 + 225.0 + + + MBRAV + + + + + Annual Membership + + service + 20.0 + + + MBRAN + variable + + + + + + + diff --git a/bemade_sethy_configuration/models/__init__.py b/bemade_sethy_configuration/models/__init__.py new file mode 100644 index 0000000..91fed54 --- /dev/null +++ b/bemade_sethy_configuration/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/bemade_sethy_configuration/models/res_partner.py b/bemade_sethy_configuration/models/res_partner.py new file mode 100644 index 0000000..aa31830 --- /dev/null +++ b/bemade_sethy_configuration/models/res_partner.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.addons.website.models import ir_http + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + surface = fields.Float(string='Surface (ha)') # terrain + lot_number = fields.Text(string='Lot Number') # terrain + + ref_project = fields.Text(string='Project No') # proprio + intent_signing = fields.Boolean(string='Intent to sign') # proprio + cyberimpact = fields.Boolean(string='Cyberimpact') # proprio + specification_date = fields.Date(string='Specification date') # proprio + crm_stage_activity = fields.Text(string='Activity Stage') # proprio + + property_count = fields.Integer(string='Property count', compute='_compute_property_count', store=True) + is_owner = fields.Boolean(string='Is Owner', compute='_compute_property_count', store=True) + + sethy_first_date = fields.Date(string='First membership date') # member + sethy_last_date = fields.Date(string='Last membership date') # member + sethy_renew_date = fields.Date(string='Next renew date date') # member + sethy_certification_date = fields.Date(string='Certification date date') # member + sethy_payment_type = fields.Text(string='Payment Type') # member + sethy_amount = fields.Float(string='Payment amount') # Member + + is_property = fields.Boolean( + string='Is Property', + default=False + ) # True if property, False if not + + interest_level = fields.Selection( + selection=[ + ('1', 'None'), + ('2', 'Low'), + ('3', 'Average'), + ('4', 'High')], + string='Interest Level') # proprio + + company_use = fields.Text(string='Company related') # proprio + + relation_owner_ids = fields.One2many( + "res.partner.relation.all", + compute="_compute_owner_ids", + string="Owner ids" + ) + + relation_property_ids = fields.One2many( + "res.partner.relation.all", + compute="_compute_property_ids", + string="Property ids" + ) + + @api.depends('relation_all_ids') + def _compute_owner_ids(self): + for record in self: + record.relation_owner_ids = record.relation_all_ids.filtered( + lambda line: ( + line.type_id.name == 'Owner' and not line.is_inverse) + ) + + @api.depends('relation_all_ids') + def _compute_property_ids(self): + for record in self: + record.relation_property_ids = record.relation_all_ids.filtered( + lambda line: ( + line.type_id.name == 'Owner' and line.is_inverse) + ) + + @api.onchange('is_property') + def _onchange_is_property(self): + """ Set is_company to True when is_property is set to True. """ + if self.is_property: + self.is_company = True + + @api.onchange('is_company') + def _onchange_is_company(self): + """ Set is_property to False when is_company is set to False. """ + if not self.is_company: + self.is_property = False + + @api.onchange('lot_number') + def _onchange_lot_number(self): + for lot in self: + if lot.lot_number: + lot.name = "Lot " + str(lot.lot_number) + + @api.depends('relation_property_ids') + def _compute_property_count(self): + for record in self: + record.property_count = len(record.relation_property_ids) + record.is_owner = record.property_count > 0 + + def write(self, vals): + property_tag = self.env.ref('bemade_sethy_configuration.partner_tag_property', raise_if_not_found=False) + owner_tag = self.env.ref('bemade_sethy_configuration.partner_tag_owner', raise_if_not_found=False) + if 'is_property' in vals: + if vals['is_property'] and property_tag: + vals['category_id'] = [(4, property_tag.id)] + elif not vals['is_property'] and property_tag: + vals['category_id'] = [(3, property_tag.id)] + if len(self.relation_owner_ids) > 0: + vals['category_id'] = [(4, owner_tag.id)] + else: + vals['category_id'] = [(3, owner_tag.id)] + return super(ResPartner, self).write(vals) + + @api.model_create_multi + def create(self, vals_list): + # Get the property tag reference outside the loop to avoid repeated searches. + property_tag = self.env.ref('bemade_sethy_configuration.partner_tag_property', raise_if_not_found=False) + # Iterate over each set of values in the list. + for vals in vals_list: + # Check if 'is_property' is in the values of the current record. + if 'is_property' in vals: + if vals['is_property'] and property_tag: + # Add the tag to category_id if is_property is True. + vals['category_id'] = [(4, property_tag.id)] + elif not vals['is_property'] and property_tag: + # Remove the tag from category_id if is_property is False. + vals['category_id'] = [(3, property_tag.id)] + # Call super and pass the modified vals_list. + return super(ResPartner, self).create(vals_list) + + @api.onchange('is_property') + def _inverse_is_property(self): + property_tag = self.env.ref('bemade_sethy_configuration.partner_tag_property', raise_if_not_found=False) + for partner in self: + if partner.is_property: + partner.category_id |= property_tag + else: + partner.category_id -= property_tag + diff --git a/bemade_sethy_configuration/static/icon.png b/bemade_sethy_configuration/static/icon.png new file mode 100644 index 0000000..3ee5128 Binary files /dev/null and b/bemade_sethy_configuration/static/icon.png differ diff --git a/bemade_sethy_configuration/views/membership_membership_line.xml b/bemade_sethy_configuration/views/membership_membership_line.xml new file mode 100644 index 0000000..db49d54 --- /dev/null +++ b/bemade_sethy_configuration/views/membership_membership_line.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Membership line + membership.membership_line + tree + + + + +

+ Record and track your partners'membership +

+
+
+ + +
diff --git a/bemade_sethy_configuration/views/res_partner_relation_views.xml b/bemade_sethy_configuration/views/res_partner_relation_views.xml new file mode 100644 index 0000000..f3a45a5 --- /dev/null +++ b/bemade_sethy_configuration/views/res_partner_relation_views.xml @@ -0,0 +1,92 @@ + + + + res.partner.relation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Relations - relation + res.partner.relation + tree + + + + +

+ Record and track your partners' relations. Relations may + be linked to other partners with a type either directly + or inversely. +

+
+
+ + +
diff --git a/bemade_sethy_configuration/views/res_partner_views.xml b/bemade_sethy_configuration/views/res_partner_views.xml new file mode 100644 index 0000000..afa7588 --- /dev/null +++ b/bemade_sethy_configuration/views/res_partner_views.xml @@ -0,0 +1,130 @@ + + + + + bemade_sethy_configuration.res_partner.defaults.form + res.partner + + + + + + + + + + + + + + + + + + + + \ No newline at end of file