Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

Pass Many2many field from Sale Order Line to Invoice Order Line?

Suscribirse

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

Se marcó esta pregunta
v8sale.order.linemany2manyinvoice.line
6295 Vistas
Avatar
Gill Potter

Odoo Version 8

I have written a module to add Suppliers as a Many2many field onto the Saleorder Line and the Invoice Order Line. I want to pass the suppliers from the sale to the invoice, but I am struggling to get the correct code.

With the code below I can successfully add multiple suppliers on the Saleorder line, but "(0 records)" is displayed in the Suppliers field on the invoice I created. I can add the Suppliers into the field on the Invoice, but I need them to be passed on invoice creation. I think I somehow need to iterate over the records in supplier_from_so_ids and I have searched Google for inspiration to little avail. Help will be much appreciated.


 

My sale.py module is this:-

from openerp import models, fields, api

class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'

 

    supplier_ids = fields.Many2many(

        comodel_name='res.partner', string='Supplier',

        domain=[('supplier', '=', True)],)

 

    @api.model

    def _prepare_order_line_invoice_line(self, line, account_id=False):

        res = super(SaleOrderLine, self)._prepare_order_line_invoice_line(

            line, account_id=account_id)

 

        if line.supplier_ids:

            res.update({

                'supplier_from_so_ids': line.supplier_ids.ids,

                })

        return res

My account.py module is this:-

from openerp import models, fields

class account_invoice(models.Model):

    _inherit = 'account.invoice.line'

 

    supplier_from_so_ids = fields.Many2many(

        comodel_name='res.partner',

        readonly=False, string='Supplier',

        domain=[('supplier', '=', True)],

My sale_view.xml is this:-

<?xml version="1.0" encoding="utf-8"?>

<openerp>

    <data>

<!--

Add Suppliers to Sale Order Line Form and Tree -->

 

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

            <field name="name">hhh.custom.view_order_form</field>

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

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

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

               <xpath expr="//field[@name='order_line']/form//field[@name='address_allotment_id']" position="after">

                   <field name="supplier_ids"/>

               </xpath>

               <xpath expr="//field[@name='order_line']/tree/field[@name='tax_id']" position="before">

                   <field name="supplier_ids"/>

               </xpath>

            </field>

        </record>

    </data>

</openerp>

My account_invoice_view.xml is this:-

<?xml version="1.0" encoding="utf-8"?>

<openerp>

    <data>

<!--

Add Suppliers to Invoice Line Tree and Form-->

 

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

            <field name="name">hhh.custom.invoice_form</field>

            <field name="model">account.invoice</field>

            <field name="inherit_id" ref="account.invoice_form"/>

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

               <xpath expr="//field[@name='invoice_line']/tree/field[@name='price_unit']" position="after">

                   <field name="supplier_from_so_ids" readonly="0"/>

               </xpath>

 

            </field>

        </record>

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

            <field name="name">hhh.custom.invoice_line_form</field>

            <field name="model">account.invoice.line</field>

            <field name="inherit_id" ref="account.view_invoice_line_form"/>

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

               <field name="invoice_line_tax_id" position="after">

                   <field name="supplier_from_so_ids" readonly="0"/>

               </field>

            </field>

        </record>

    </data>

</openerp>

Thank you, Gill

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Add a line on invoice which it's not on delivery order lines
v8 invoice.line
Avatar
0
oct 15
4021
How to copy sale order line's one field in to invoice
sale.order.line invoice.line
Avatar
0
mar 15
4436
Sort widget="many2many_checkboxes" items Resuelto
v8 many2many checkbox
Avatar
Avatar
1
may 19
10869
How to get a recordset from a One2many or Many2many field in a python file?
v8 one2many many2many
Avatar
Avatar
1
abr 17
20337
invoicing lines from multiple sale orders?
v8 invoice sale.order.line
Avatar
Avatar
Avatar
Avatar
Avatar
10
jul 16
15387
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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