diff --git a/morpheus_contacts/__manifest__.py b/morpheus_contacts/__manifest__.py index 78a0d5b..0532117 100644 --- a/morpheus_contacts/__manifest__.py +++ b/morpheus_contacts/__manifest__.py @@ -20,5 +20,5 @@ ], 'installable': True, 'application': False, - 'auto_install': False, + 'auto_install': True, } \ No newline at end of file diff --git a/morpheus_contacts/__pycache__/__init__.cpython-312.pyc b/morpheus_contacts/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 685f6fe..0000000 Binary files a/morpheus_contacts/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/morpheus_contacts/models/__pycache__/__init__.cpython-312.pyc b/morpheus_contacts/models/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 8d977ee..0000000 Binary files a/morpheus_contacts/models/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/morpheus_contacts/models/__pycache__/res_partner.cpython-312.pyc b/morpheus_contacts/models/__pycache__/res_partner.cpython-312.pyc deleted file mode 100644 index c48c2b9..0000000 Binary files a/morpheus_contacts/models/__pycache__/res_partner.cpython-312.pyc and /dev/null differ diff --git a/morpheus_contacts/models/res_partner.py b/morpheus_contacts/models/res_partner.py index 2c5c33b..5d86da8 100644 --- a/morpheus_contacts/models/res_partner.py +++ b/morpheus_contacts/models/res_partner.py @@ -71,6 +71,24 @@ class ResPartner(models.Model): 'fornitore.attuale.option', string="Fornitori Attuali dei Clienti" ) + + # Campo per identificare se è un agente + is_agent = fields.Boolean( + string="È un Agente", + help="Spunta questa casella se questo contatto è un agente" + ) + + # Campo Email 2 + email2 = fields.Char( + string="E-mail 2" , + help="Indirizzo email secondario" + ) + + # Campo Note Logistiche (simile alle note interne) + note_logistiche = fields.Html( + string="Note Logistiche", + help="Note logistiche interne con editor ricco" + ) class ResPartnerSector(models.Model): _name = 'res.partner.sector' # Nome tecnico corretto diff --git a/morpheus_contacts/views/res_partner_view.xml b/morpheus_contacts/views/res_partner_view.xml index 0f8418d..c7461a5 100644 --- a/morpheus_contacts/views/res_partner_view.xml +++ b/morpheus_contacts/views/res_partner_view.xml @@ -8,6 +8,12 @@ + + + + + + @@ -35,6 +41,11 @@ + + + + + diff --git a/morpheus_crm/__manifest__.py b/morpheus_crm/__manifest__.py index 783dba0..fc2fe79 100644 --- a/morpheus_crm/__manifest__.py +++ b/morpheus_crm/__manifest__.py @@ -14,4 +14,5 @@ ], 'installable': True, 'application': False, + 'auto_install': True, } diff --git a/morpheus_crm/__pycache__/__init__.cpython-312.pyc b/morpheus_crm/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index bf1f6b9..0000000 Binary files a/morpheus_crm/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/morpheus_crm/models/__pycache__/__init__.cpython-312.pyc b/morpheus_crm/models/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 805a587..0000000 Binary files a/morpheus_crm/models/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/morpheus_crm/models/__pycache__/crm_lead.cpython-312.pyc b/morpheus_crm/models/__pycache__/crm_lead.cpython-312.pyc deleted file mode 100644 index a580d6a..0000000 Binary files a/morpheus_crm/models/__pycache__/crm_lead.cpython-312.pyc and /dev/null differ diff --git a/morpheus_crm/models/__pycache__/crm_lead_category.cpython-312.pyc b/morpheus_crm/models/__pycache__/crm_lead_category.cpython-312.pyc deleted file mode 100644 index f22d021..0000000 Binary files a/morpheus_crm/models/__pycache__/crm_lead_category.cpython-312.pyc and /dev/null differ diff --git a/morpheus_crm/models/crm_lead.py b/morpheus_crm/models/crm_lead.py index 0c4d9e3..c686af8 100644 --- a/morpheus_crm/models/crm_lead.py +++ b/morpheus_crm/models/crm_lead.py @@ -43,7 +43,36 @@ class CrmLead(models.Model): # Questo messaggio potrebbe apparire se la condizione 'invisible' nell'XML non fosse perfetta # o se il metodo fosse chiamato da un'altra parte. raise UserError(_("L'opportunità deve essere nello stadio 'Nuova' per poterla inviare a 'Wishlist verificata'.")) - + + # --- Invio email agli addetti acquisti --- + emails = [] + if self.addetto_acquisti and self.addetto_acquisti.partner_id.email: + emails.append(self.addetto_acquisti.partner_id.email) + if self.addetto_acquisti_2 and self.addetto_acquisti_2.partner_id.email: + emails.append(self.addetto_acquisti_2.partner_id.email) + if not emails: + return True # Nessun destinatario, esci silenziosamente + + base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + opportunity_url = f"{base_url}/web#id={self.id}&model=crm.lead&view_type=form&page=wishlist_cliente" + button_html = f'Apri wishlist cliente' + body_html = f""" + Gentile Ufficio acquisti,

+ è stata verificata la wishlist presente nella seguente opportunità:

+ Nome cliente: {self.partner_id.name}
+ Nome opportunità: {self.name}

+ + {button_html} + """ + mail_values = { + 'subject': f"Wishlist verificata - {self.name}", + 'body_html': body_html, + 'email_to': ','.join(emails), + 'auto_delete': True, + 'model': 'crm.lead', + 'res_id': self.id, + } + self.env['mail.mail'].sudo().create(mail_values).send() return True @@ -75,15 +104,16 @@ class CrmLead(models.Model): self.agente_id = self.partner_id.agente_id self.percent_provvigioni = self.partner_id.percent_provvigioni - @api.model - def create(self, vals): - if vals.get('partner_id'): - partner = self.env['res.partner'].browse(vals['partner_id']) - if not vals.get('agente_id') and partner.agente_id: - vals['agente_id'] = partner.agente_id.id - if not vals.get('percent_provvigioni'): - vals['percent_provvigioni'] = partner.percent_provvigioni - return super(CrmLead, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('partner_id'): + partner = self.env['res.partner'].browse(vals['partner_id']) + if not vals.get('agente_id') and partner.agente_id: + vals['agente_id'] = partner.agente_id.id + if not vals.get('percent_provvigioni'): + vals['percent_provvigioni'] = partner.percent_provvigioni + return super(CrmLead, self).create(vals_list) # Campi per la Richiesta Offerta diff --git a/morpheus_crm/views/crm_wishlist_view.xml b/morpheus_crm/views/crm_wishlist_view.xml index 0496370..25bb6d6 100644 --- a/morpheus_crm/views/crm_wishlist_view.xml +++ b/morpheus_crm/views/crm_wishlist_view.xml @@ -27,7 +27,7 @@ - +