Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Action to create Project from sales order

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
actionprojectsales.order
4 Respuestas
1780 Vistas
Avatar
Phred

I want to be able to create a project from the sales order. Odoo seems to only allow this for a sales order with 'service' products, but I want to create a project for any sales order, regardless of the product.


The only way I can work out to achieve this is with an 'execute code' server action, as below.


This seems to achieve what I want, however as I am on an enterprise license I have to pay extra to use the code, so I am hoping there is a simpler solution to this. Also my python experience is quite limited and I am unsure if I have coded this in a reliable way...


Does anyone know of a better solution to this problem? any help is much appreciated.

if record.project_id:
    raise UserError("This Sales Order already has a linked project.")
   
# Get sequence number
seq = env['ir.sequence'].next_by_code('project.seq')

# Combine with opportunity name if available
if record.opportunity_id:
    opp_name = record.opportunity_id.name
else:
    opp_name = ""

if opp_name:
    project_name = f"{seq} | {opp_name}"
else:
    project_name = seq

# Create project
project = env['project.project'].create({
    'name': project_name,
    'partner_id': record.partner_id.id,
    'use_documents': False,
})

record.write({'project_id': project.id})


0
Avatar
Descartar
Avatar
JB
Mejor respuesta

Hello,

Please Refer the code:

1.Python code:

from odoo import models, fields, api


class SaleOrder(models.Model):

    _inherit = "sale.order"


    project_id = fields.Many2one("project.project", string="Project")


    def action_create_project(self):

        Project = self.env["project.project"]

        for order in self:

            if not order.project_id:

                project = Project.create({

                    "name": order.name,

                    "partner_id": project.id

        return True


2. Xml Code

<record id="view_order_form_inherit_project" model="ir.ui.view">

    <field name="name">sale.order.form.inherit.project</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

    <field name="arch" type="xml">

        <header position="inside">

            <button name="action_create_project"

                    type="object"

                    string="Create Project"

                    class="btn-primary"

                    attrs="{'invisible': [('project_id','!=',False)]}"/>

        </header>

        <sheet position="after">

            <field name="project_id"/>

        </sheet>

    </field>

</record>


0
Avatar
Descartar
Chris TRINGHAM

This isn't an answer to the question that has been asked!

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,

Please refer to the code:


from odoo import api, fields, models

from odoo.exceptions import UserError


class SaleOrder(models.Model):

    _inherit = "sale.order"


    project_id = fields.Many2one('project.project', string="Project")


    def action_create_project(self):

        for order in self:

            if order.project_id:

                raise UserError("This Sales Order already has a linked project.")


            seq = self.env['ir.sequence'].next_by_code('project.seq') or order.name

            opp_name = order.opportunity_id.name if order.opportunity_id else ""

            project_name = f"{seq} | {opp_name}" if opp_name else seq


            project = self.env['project.project'].create({

                'name': project_name,

                'partner_id': order.partner_id.id,

            })

            order.project_id = project.id


Hope it helps.

0
Avatar
Descartar
Avatar
D Enterprise
Mejor respuesta

Hi,

if record. project_id:

    raise UserError("This Sales Order already has a linked project.")


# Get sequence value or fallback

seq = env['ir.sequence'].next_by_code('project.seq') or 'NEW/PROJECT'


# Get opportunity name if exists

opp_name = record.opportunity_id.name if record.opportunity_id else ''


# Build project name

project_name = f"{seq} | {opp_name}" if opp_name else seq


# Create new project

project = env['project.project'].create({

    'name': project_name,

    'partner_id': project.id })

try this 
i hope it is use full

0
Avatar
Descartar
Avatar
Ruchita
Mejor respuesta

In Odoo, a project is typically created from a Sales Order when you sell a service product that is configured to trigger project creation.

✅ Steps:

  1. Go to Sales > Products and open the service product.
  2. Set:
    • Product Type: Service
    • Service Invoicing Policy: Based on Milestones or Timesheets on Tasks
    • Service Tracking: Choose one of the following:
      • Create a task in an existing project
      • Create a new project but no task
      • Create a new project and task
  3. When you confirm a Sales Order containing that product, Odoo will automatically create the project or task depending on your selection.

You can then manage the project from the Projects module.

-1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Lifemiles teléfono ¿Cómo puedo llamar al soporte de Lifemiles?
action project
Avatar
0
oct 25
3
How to show sales order data in the projects module Resuelto
project sales.order related_fields
Avatar
1
jun 22
6939
Set project_id on new tasks automatically
action project automated
Avatar
3
feb 20
4363
How to make a new save button? Resuelto
action project custom
Avatar
Avatar
1
jul 19
15851
How to access my DNS?
action project chrome service
Avatar
0
nov 25
40
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now