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

Odoo v14 - creates sequential values in a custom field of the order tree view existing

Suscribirse

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

Se marcó esta pregunta
confirmsales.order
2 Respuestas
2652 Vistas
Avatar
agung siswono

I'm new to odoo and trying to add a new module to sales.
I have added a module and a field called job_no, it is placed in the sales order tree view.
my goal is to automatically generate sequential values in the job_no field when the confirm button is pressed.

but I'm having trouble connecting the confirmation button that is already in odoo.
here is the code i have made:
this is a .py file

from odoo import api, fields, models, _

class sale_warisan(models.Model):
_inherit = 'sale.order'

jenis_pekerjaan = fields.Selection([
('jasa', 'Jasa'),
('proyek', 'Proyek'),
('belt', 'Belt'),
('aksesoris', 'Aksesoris'),
], required=True, default='aksesoris', tracking=True)

job_no = fields.Char(string='Job Number', tracking=True, copy=False, readonly=True,
default=lambda self: _('New'))

# ignore this one, because I'm still looking for tutorials on the web and youtube, but I haven't been able to get it working
# def create(self, vals):
# if vals.get('job_no', _('New')) == _('New'):
# vals['job_no'] = self.env['ir.sequence'].next_by_code('sales.order') or _('New')
# res = super(sale_warisan, self).create(vals)
# return res


and this .xml

xml version="1.0" encoding="UTF-8" ?>



id="tampilan_quotation_form_warisan" model="ir.ui.view">
name="name">tampilan.quotation.warisan
name="model">sale.order
name="inherit_id" ref="sale.view_order_form"/>
name="arch" type="xml">
expr="//field[@name='partner_id']" position="after">
name="jenis_pekerjaan"/>





id="tampilan_quotation_tree_warisan" model="ir.ui.view">
name="name">tampilan.quotation.warisan
name="model">sale.order
name="inherit_id" ref="sale.view_quotation_tree"/>
name="arch" type="xml">
expr="//field[@name='partner_id']" position="after">
name="jenis_pekerjaan"/>






id="urutan_job_no" model="ir.sequence">
name="name">Job Number
name="code">sale.order
name="padding">4




id="tampilan_order_tree_warisan" model="ir.ui.view">
name="name">tampilan.order.warisan
name="model">sale.order
name="inherit_id" ref="sale.view_order_tree"/>
name="arch" type="xml">
expr="//field[@name='name']" position="before">
name="job_no"/>





0
Avatar
Descartar
Avatar
agung siswono
Autor Mejor respuesta

Hi,

thanks for the answer, I've tried it but the message appears: TypeError: object 'bool' does not support item assignment.

0
Avatar
Descartar
agung siswono
Autor

after i tried again it worked.

with the following code:
def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
if self.env.su:
self = self.with_user(SUPERUSER_ID)

for jb in self:
if jb.job_no == _('Offer'):
jb.job_no = self.env['ir.sequence'].next_by_code('job.order') or _('Offer')
return res

Avatar
Niyas Raphy (Walnut Software Solutions)
Mejor respuesta

Hi,

If you are looking to generate the sequence number in the newly added field on confirming the sales order, instead of inheriting the create method, you have to inherit the function that get executed on clicking the confirm button.


In sale.order model on clicking the confirm button action_confirm method is getting executed, thus super this method in your module and add the logic to generate the sequence.


def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
res.job_no = self.env['ir.sequence'].next_by_code('sales.order') or _('New')
return res



Thanks

0
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
Transform Quotations to sales orders or invoices in a bulk action
sales.order
Avatar
Avatar
Avatar
3
feb 25
3247
Orden de venta borrada por error
sales.order
Avatar
Avatar
1
dic 24
2806
How to create a subsection in the product order line and make the main section sum the total of the subsections in Odoo? Resuelto
sales.order
Avatar
Avatar
2
mar 24
3174
Managing orders from repeat customers Resuelto
sales.order
Avatar
Avatar
Avatar
2
mar 24
3734
Sales order from customer order.
sales.order
Avatar
0
sept 23
2106
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