Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to transfer data from sale order to invoice when clicking on 'Create Invoice'?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
wizardinvoicequotationact_windowodoo8.0
3 Replies
15804 Rodiniai
Portretas
Yenthe Van Ginneken (Mainframe Monkey)

Hi guys,

I'm extending the sale and account module and added my custom fields in a custom module. I've added fields in both the sale.order.line model and the account.invoice.line model:

class custom_sale_order_line_fields(models.Model):
    _inherit = 'sale.order.line'
    hoogte = fields.Integer()
    breedte = fields.Integer()
    aantal = fields.Integer()
    #Checkboxes
    links = fields.Boolean()
    rechts = fields.Boolean()
    boven = fields.Boolean()
    onder = fields.Boolean()
    kleur = fields.Selection((('w','Wit'), ('z','Zwart'), ('g','Groen'),('r','Rood')))

class aa_invoice_custom_lines(models.Model):
    _inherit = 'account.invoice.line'
    hoogte = fields.Integer()
    breedte = fields.Integer()
    aantal = fields.Integer()
    #Checkboxes
    links = fields.Boolean()
    rechts = fields.Boolean()
    boven = fields.Boolean()
    onder = fields.Boolean()
    kleur = fields.Selection((('w','wit'), ('z','zwart'), ('g','groen'),('r','rood')))

The fields are added in both the view for a new sale order and the view for an invoice:

 <openerp>
    <data>
        <record id="sale.view_order_form_inherit" model="ir.ui.view">
            <field name="name">sale.order.form.inherit</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
 	    <field name="arch" type="xml">
	        <xpath expr="//tree[@string='Sales Order Lines']/field[@name='name']" position="after">
		    <field name="links"/>
		    <field name="rechts"/>
		    <field name="boven"/>
		    <field name="onder"/>
		    <field name="kleur"/>
                    <field name="hoogte" on_change="on_change_hoeveelheid_berekenen(hoogte,breedte,aantal)"/>
		    <field name="breedte" on_change="on_change_hoeveelheid_berekenen(hoogte,breedte,aantal)"/>
                    <field name="aantal" on_change="on_change_hoeveelheid_berekenen(hoogte,breedte,aantal)"/>
		</xpath>
	    </field>
        </record>

        <record id="account.invoice_form_inherit3" model="ir.ui.view">
            <field name="name">account.invoice.form.inherit3</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
 	    <field name="arch" type="xml">
	        <xpath expr="//tree[@string='Invoice Lines']/field[@name='name']" position="after">
		    <field name="links"/>
		    <field name="rechts"/>
		    <field name="boven"/>
		    <field name="onder"/>
		    <field name="kleur"/>
                    <field name="hoogte" on_change="on_change_hoeveelheid_factuur_berekenen(hoogte,breedte,aantal)"/>
		    <field name="breedte" on_change="on_change_hoeveelheid_factuur_berekenen(hoogte,breedte,aantal)"/>
                    <field name="aantal" on_change="on_change_hoeveelheid_factuur_berekenen(hoogte,breedte,aantal)"/>
		</xpath>
	    </field>
        </record>
    </data>
</openerp>

The next thing that I need is that when the user opens up a sales order and clicks on the button 'Create Invoice' that the filled in data from the sales order gets passed on to the invoice that is automatically generated.
The button 'Create Invoice' seems to come from /sale/wizard/sale_line_invoice.xml from this record:

 <record id="action_view_sale_order_line_make_invoice" model="ir.actions.act_window">
            <field name="name">Create Invoice</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.order.line.make.invoice</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_sale_order_line_make_invoice"/>
            <field name="target">new</field>
        </record>

What I don't understand now is where I should add the logic to transfer data from my custom fields from a sales order to an invoice. How do I know which code this action triggers and how should I transfer the data from the sale order to the invoice? It looks like the data is transferred in the method make_invoice (addons/sale/wizard/sale_line_invoice.py in the following lines:

 #TODO: merge with sale.py/make_invoice
        def make_invoice(order, lines):
            """
                 To make invoices.

                 @param order:
                 @param lines:

                 @return:

            """
            a = order.partner_id.property_account_receivable.id
            if order.partner_id and order.partner_id.property_payment_term.id:
                pay_term = order.partner_id.property_payment_term.id
            else:
                pay_term = False
            inv = {
                'name': order.client_order_ref or '',
                'origin': order.name,
                'type': 'out_invoice',
                'reference': "P%dSO%d" % (order.partner_id.id, order.id),
                'account_id': a,
                'partner_id': order.partner_invoice_id.id,
                'invoice_line': [(6, 0, lines)],
                'currency_id' : order.pricelist_id.currency_id.id,
                'comment': order.note,
                'payment_term': pay_term,
          
                'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
                'user_id': order.user_id and order.user_id.id or False,
                'company_id': order.company_id and order.company_id.id or False,
                'date_invoice': fields.date.today(),
            }
            inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
            return inv_id
But how can I add my custom fields to be added on the invoice lines too?

Thanks,
Yenthe
1
Portretas
Atmesti
Portretas
Peter Alabaster
Best Answer

I have done this before when adding lots to all sale, purchase, and invoice lines. I had to pipe the data across all these forms.

You have to do a certain amount of rooting around in the source code to find the right place to hook in, but for your situation this should work:

class sale_order_line_your_extension(osv.osv):
_inherit = "sale.order.line"

def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
    ret = super(sale_order_line_your_extension, self)._prepare_order_line_invoice_line(cr, uid, line, account_id=False, context=context)
    if line.product_id:
        if line.field_name:
            ret['field_name'] = line.field_name
    return ret

Note: super has been used here to reduce impact on source code.

All we are doing is assigning all the default returned values in the source code to the variable `ret`.

We are then checking if line.product_id exists on the sale order.

Then checking if anything has been set on your field, and then appending your field name (as defined in account.invoice.line) to ret, and assigning the value stored in the field to it.

Finally the appended value is returned, along with all other values.

This can be used in many places when piping data across forms, and can be quite a useful template.

You can easily add more than one value:

ret['field_name2'] = line.field_name2

ret['field_name3'] = line.field_name3

Hope this helps

6
Portretas
Atmesti
Yenthe Van Ginneken (Mainframe Monkey)
Autorius

Thanks Peter! This is a really great answer which is also usuable for other cases. Upvoted & accepted, again thanks! :)

Portretas
Tintumon
Best Answer

 For creating "account.invoice" from "sale.order" there is four selection option

  • delivered

  • all

  • percentage

  • fixed

I tried a function "def action_invoice_create(self, grouped=False, final=False): " using super in inherited sale.order.

It works fine for sending a field value from sale.order to account.invoice, when the selection field is "delivered" or "all".

But it doesn't work for "percentage" and "fixed" selections.

So I used another function "def _create_invoice(self, order, so_line, amount):"  using super in inherited wizard/sale_make_invoice_advance.py

It propagated the field value from sale.order to account.invoice successfully.

I have tested it in debug also.

Does it right way to achieve? or any other way?

Note: I worked on ODOO9

0
Portretas
Atmesti
Coralie Cardon

Hello ! I did exactely what you say :-) but i have a problem So, I have a rate in my sale order and i would like take it to multiply to the amount of my invoice. (I put it in a field) But the amount doesn't take the down payment

Enjoying the discussion? Don't just read, join in!

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

Registracija
Related Posts Replies Rodiniai Veikla
Enlarge or change width of text in invoice/quotation reports Solved
invoice quotation
Portretas
Portretas
2
vas. 23
3385
Change invoice footer per country
invoice odoo8.0
Portretas
Portretas
Portretas
3
liep. 17
5146
How to make a new field and being integrated in 2 modules
invoice quotation
Portretas
Portretas
1
geg. 16
4191
How can modify the N° or the source of document for the quotation Solved
invoice quotation
Portretas
Portretas
2
bal. 16
4958
How can I edit Sales Tax so that it doesn't show the rate, just the word "Tax"? Solved
invoice tax quotation
Portretas
Portretas
1
spal. 25
3676
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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