# -*- coding: utf-8 -*- from odoo import models, fields, api class ResPartner(models.Model): _inherit = "res.partner" association = fields.Boolean(string="Is an association") is_french = fields.Boolean( string="French partner", related="country_id.is_french", store=True, ) constituent_ga_date = fields.Date( string="Consitutent GA", tracking="80", help="Constituent General Assembly date", ) prefecture_date = fields.Date( string="Declaration date", tracking="82", help="Prefecture declaration date", ) prefecture = fields.Char( string="Prefecture", tracking="81", help="Prefecture (city) of declaration", ) official_journal_date = fields.Date( string="Official Journal", tracking="83", help="Official Journal publication date", ) official_journal_dept_id = fields.Many2one( comodel_name="res.country.department", string="OJ department", tracking="81", help="Official Journal publication department", domain=[ ( "country_id.code", "in", ( "FR", "GP", "MQ", "GF", "RE", "YT", ), ) ], ) official_journal = fields.Char( string="OJ reference", tracking="81", help="Official Journal reference", ) company_registry_date = fields.Date( string="Registration date", help="Association National Register declaration date", tracking="83", ) company_registry = fields.Char(tracking="83") naf_ape = fields.Char(string="NAF/APE code", tracking="83") last_ga_date = fields.Date(string="Last general assembly", tracking="81") # Documents fields statuses_file = fields.Binary("Statuses file") statuses_filename = fields.Char("Statuses filename", tracking="83") statuses_update_date = fields.Date("Statuses update", tracking="83") internal_regul_file = fields.Binary("Internal Regulations file") internal_regul_filename = fields.Char( "Internal Regulations filename", tracking="83" ) internal_regul_update_date = fields.Date("Internal Reg. update", tracking="85") asso_project_file = fields.Binary("Assocation project") asso_project_filename = fields.Char("Assocation project filename", tracking="83") asso_project_update_date = fields.Date("Project update", tracking="83") @api.onchange("is_company", "country_id") def onchange_asso_is_french_company(self): if self.association and (not self.is_company or not self.is_french): self.association = False # @api.onchange("association") # def onchange_association(self): # if not self.association: # values = {} # if self.statuses_file: # values.update( # { # "statuses_file": False, # "statuses_filename": False, # "statuses_update_date": False, # } # ) # if self.internal_regul_file: # values.update( # { # "internal_regul_file": False, # "internal_regul_filename": False, # "internal_regul_update_date": False, # } # ) # for field in [ # "association", # "asso_creation_date", # "prefecture_date", # "prefecture", # "official_journal_date", # "company_registry_date", # "company_registry", # "naf_ape", # "last_ga_date", # ]: # if getattr(self, field) != False: # values.update({field: False}) # if values: # self.update(values)