Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
v8sale.order.linemany2manyinvoice.line
6316 Zobrazenia
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Add a line on invoice which it's not on delivery order lines
v8 invoice.line
Avatar
0
okt 15
4036
How to copy sale order line's one field in to invoice
sale.order.line invoice.line
Avatar
0
mar 15
4446
Sort widget="many2many_checkboxes" items Solved
v8 many2many checkbox
Avatar
Avatar
1
máj 19
10879
How to get a recordset from a One2many or Many2many field in a python file?
v8 one2many many2many
Avatar
Avatar
1
apr 17
20340
invoicing lines from multiple sale orders?
v8 invoice sale.order.line
Avatar
Avatar
Avatar
Avatar
Avatar
10
júl 16
15399
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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