Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] crm_phonecall_lead: Convert to lead or opportunity button in ph… #87

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

Berezi
Copy link
Contributor

@Berezi Berezi commented Sep 21, 2021

…one call instead of only convert to opportunity.

@Berezi
Copy link
Contributor Author

Berezi commented Sep 21, 2021

@anajuaristi @oihane @Daniel-CA @alfredoavanzosc review please.

class CrmPhonecall(models.Model):
_inherit = 'crm.phonecall'

def create_lead_opportunity(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En crm.phonecall ya existe función

    def action_button_convert2opportunity(self):
        """Convert a phonecall into an opp and redirect to the opp view."""
        opportunity_dict = {}
        for call in self:
            opportunity_dict = call.convert_opportunity()
            return opportunity_dict[call.id].redirect_lead_opportunity_view()
        return opportunity_dict

Por tanto, como lo único que se quiere cambiar es el type, entiendo que con heredar esa función y cambiar el type en el diccionario, sería suficiente.
No hace falta nuevo botón, ni hacer un fork desde cero para crear el crm.lead. Con forkear la llamada al botón ya lo tendrías.
En todos los casos le pone "opportunity" al tipo. En nuestro caso si partner_id es nulo, tiene que cambiar justo ese dato. El resto ya estaría correcto.
Sería algo así (salvando las distancias y la sintaxis de código que no he probado)

    def action_button_convert2opportunity(self):
        """Convert a phonecall into an opp and redirect to the opp view."""
        opportunity_dict = {}
        for call in self:
            opportunity_dict = call.convert_opportunity()
            if not self.partner_id:
                 vals['type'] = 'lead'
            self.env['crm.lead'].write(vals)
            return opportunity_dict[call.id].redirect_lead_opportunity_view()
        return opportunity_dict

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oihane @alfredoavanzosc mirad a ver si esto que digo es así, porfa. O si existe forma mejor de hacerlo, por ejemplo con un super o heredando la función convert_opportunity() evitando de alguna forma el write.

@oihane oihane added this to the 14.0 milestone Oct 28, 2021
…one call instead of only convert to opportunity.
@oihane oihane force-pushed the crm-addons14-crm_phonecall_lead branch from d1ac0b5 to 29eca5c Compare July 23, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants