Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Done by RHT on the 07/10/2024
- # Review: https://pastebin.com/4zAEqd6p
- # Need: Get the contacts that are relevant to this BANDI
- # Task: https://www.odoo.com/odoo/project.task/4031666?cids=1
- for bandi in records:
- #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
- 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)])
- # if the bando has a legal form - Categoria Forma Giuridica - "Imprese" (ID = 1),
- if bandi.x_studio_forma_giuridica_da_definire.x_studio_categoria_forma_giuridica.ids in [1]:
- # The company size and the primary or secondary Ateco code should be the same between the contact and the bandi
- contacts = contacts.search([
- "&",
- ('x_studio_dimensione_aziendale', 'in', bandi.x_studio_dimensione_aziendale.ids),
- "|",
- ('x_studio_codice_ateco_primario', 'in', bandi.x_studio_ateco.ids),
- ('x_studio_code_ateco_second_level', 'in', bandi.x_studio_ateco.ids)
- ])
- # if the interprofessional fund is set to "Sì" on the bandi, then only take the contacts that have the same funds t
- if bandi.x_studio_fondi_inteprofessionali_coinvolti == "Sì":
- contacts = contacts.search([('x_studio_many2many_field_eo_1hpe5mirs', 'in', bandi.x_studio_many2many_field_eo_1hpe5mirs.ids)])
- # 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
- if bandi.x_studio_anni_registro_imprese_obbligatorio == "Sì" :
- contacts = contacts.search([('x_studio_company_year_birth' <= bandi.x_studio_scadenza_al_1.year - bandi.x_studio_anni_registro_imprese_numero)])
- # 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)
- if bandi.x_studio_impresa_artigiana == "Sì":
- contacts = contacts.search([('x_studio_azienda_artigiana', '=', 'Sì, azienda artigiana')])
- # 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'
- if bandi.x_studio_start_up_innovativa == "Sì":
- contacts = contacts.search([('x_studio_sottosezione_sezione_speciale_registro_imprese', '=', 'Startup Innovativa')])
- # if the bandi PMI innovativa - Innovative SME - is set to "Sì", then the contacts should have the with the value = 'PMI Innovativa'
- if bandi.x_studio_esclusivamente_per_pmi_innovativa == "Sì":
- contacts = contacts.search([('x_studio_sottosezione_sezione_speciale_registro_imprese', '=', 'PMI Innovativa')])
- contact_ids = contacts.ids
- for contact in contact_ids:
- bandi['x_studio_contatti_assegnati'] = [(4, contact)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement