Advertisement
rht_odoo

[4031666] 3rd option - Get the contacts that are relevant to this BANDI

Oct 7th, 2024 (edited)
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.48 KB | None | 0 0
  1. # Done by RHT on the 07/10/2024
  2. # Review: https://pastebin.com/4zAEqd6p
  3. # Need: Get the contacts that are relevant to this BANDI
  4. # Task: https://www.odoo.com/odoo/project.task/4031666?cids=1
  5.  
  6.  
  7.  
  8. for bandi in records:
  9.     #first pre-selection : contact must be in company; its legal type should be the same as the bandi must have the Tag Attivo, Faro or Speciale - or its parent should - ; its - or its children - state should be in the Area di Intervento
  10.     contacts = env["res.partner"].search(["&", "&","&",('is_company','=', True),("x_studio_x_studio_id_legal_type_2", "in", bandi.x_studio_forma_giuridica_da_definire.ids), "|",("category_id", 'in', [198,206,207]),("parent_id.category_id", 'in', [198,206,207]),"|",('state_id','in',bandi.x_studio_many2many_field_7v3_1hssiq3f0.ids),('child_ids.state_id','in',bandi.x_studio_many2many_field_7v3_1hssiq3f0.ids)])
  11.     # if the bando has a legal form - Categoria Forma Giuridica - "Imprese" (ID = 1),
  12.     if bandi.x_studio_forma_giuridica_da_definire.x_studio_categoria_forma_giuridica.ids in [1]:
  13.         # The company size and the primary or secondary Ateco code should be the same between the contact and the bandi
  14.         contacts = contacts.search([
  15.         "&",
  16.         ('x_studio_dimensione_aziendale', 'in', bandi.x_studio_dimensione_aziendale.ids),
  17.         "|",
  18.         ('x_studio_codice_ateco_primario', 'in', bandi.x_studio_ateco.ids),
  19.         ('x_studio_code_ateco_second_level', 'in', bandi.x_studio_ateco.ids)
  20.         ])
  21.         # if the interprofessional fund is set to "Sì" on the bandi, then only take the contacts that have the same funds t
  22.         if bandi.x_studio_fondi_inteprofessionali_coinvolti == "Sì":
  23.             contacts = contacts.search([('x_studio_many2many_field_eo_1hpe5mirs', 'in', bandi.x_studio_many2many_field_eo_1hpe5mirs.ids)])
  24.         # if the Mandatory Business Register Years is set to "Sì" on the bandi, then only take the contacts for which the differecene between the deadline year and the numbers od years of registration of the bandi is bigieer or year to the year of registration of the contac
  25.         if bandi.x_studio_anni_registro_imprese_obbligatorio == "Sì" :
  26.             contacts = contacts.search([('x_studio_company_year_birth' <= bandi.x_studio_scadenza_al_1.year - bandi.x_studio_anni_registro_imprese_numero)])
  27.         # if the bandi craftsmanship business is set to "Sì", then the contacts should have the Special Section of the Business Register set as value "Sì, azienda artigiana" (name = Imprese Artigiane)
  28.         if bandi.x_studio_impresa_artigiana == "Sì":
  29.             contacts = contacts.search([('x_studio_azienda_artigiana', '=', 'Sì, azienda artigiana')])
  30.         # if the bandi Start Up Innovativa is set to "Sì", then the contacts should have the Subsection of the special section of the Business Register with the value = 'Startup Innovativa'
  31.         if bandi.x_studio_start_up_innovativa == "Sì":
  32.             contacts = contacts.search([('x_studio_sottosezione_sezione_speciale_registro_imprese', '=', 'Startup Innovativa')])
  33.         # if the bandi PMI innovativa - Innovative SME - is set to "Sì", then the contacts should have the  with the value = 'PMI Innovativa'
  34.         if bandi.x_studio_esclusivamente_per_pmi_innovativa == "Sì":
  35.             contacts = contacts.search([('x_studio_sottosezione_sezione_speciale_registro_imprese', '=', 'PMI Innovativa')])
  36.     contact_ids = contacts.ids
  37.     for contact in contact_ids:
  38.         bandi['x_studio_contatti_assegnati'] = [(4, contact)]
  39.  
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement