Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

[8] how to add field in a view from another?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
viewsfieldsproduct.productpurchase.orderproduct.template
3 Antworten
5588 Ansichten
Avatar
mauro anelli

hello,

1)i made some custom field in product.template, now i would like to get them in purchase order form view. any help?

2)it's possible to add the value of the field after another? for example i have product id, name, default_code ecc on product.template.product.form. now i would like that in purchase order, when i select a product , it fill the description with name+default_code


thanks

0
Avatar
Verwerfen
Avatar
Nikhil Krishnan
Beste Antwort

Hi aneli,
Its possible, 

In purchase module there is function

class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty,
uom_id, partner_id, date_order=False,
fiscal_position_id=False, date_planned=False,
name=False, price_unit=False, state='draft',
context=None):
res = super(PurchaseOrderLine, self).onchange_product_id(
cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id,
date_order=date_order, fiscal_position_id=fiscal_position_id,
date_planned=date_planned, name=name, price_unit=price_unit,
state=state, context=context)
         product_id = res['product_id']
         res['name'] = product_id.name + product_id.default_code
         # for addind  "x_IDfornitore" and x_IDfornitore2 fields
          res['name'] = product_id.name (if needed,) + product_id.x_IDfornitore + IDfornitore2
return res

** Please remove (if needed,) from code.

Please super this function and make what you want.

This is just a model, you can make it as you like. (Don't follow the exact code, its model)

If you need a correct code, you make your question more detailed.

Thank you, hope it will help you.

1
Avatar
Verwerfen
Avatar
mauro anelli
Autor Beste Antwort

thanks very much and sorry but i'm really newbi to programmin.


when i get to change the code i found that the code you gave me is for odoo 9. in odoo 8 i found this

class purchase_order_line(osv.osv):

    def _calc_line_base_price(self, cr, uid, line, context=None):

        """Return the base price of the line to be used for tax calculation.

        This function can be extended by other modules to modify this base

        price (adding a discount, for example).

        """

        return line.price_unit

    def _calc_line_quantity(self, cr, uid, line, context=None):

        """Return the base quantity of the line to be used for the subtotal.

        This function can be extended by other modules to modify this base

        quantity (adding for example offers 3x2 and so on).

        """

        return line.product_qty

    def _amount_line(self, cr, uid, ids, prop, arg, context=None):

        res = {}

        cur_obj=self.pool.get('res.currency')

        tax_obj = self.pool.get('account.tax')

        for line in self.browse(cr, uid, ids, context=context):

            line_price = self._calc_line_base_price(cr, uid, line,

                                                    context=context)

            line_qty = self._calc_line_quantity(cr, uid, line,

                                                context=context)

            taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line_price,

                                        line_qty, line.product_id,

                                        line.order_id.partner_id)

            cur = line.order_id.pricelist_id.currency_id

            res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])

        return res

    def _get_uom_id(self, cr, uid, context=None):

        try:

            proxy = self.pool.get('ir.model.data')

            result = proxy.get_object_reference(cr, uid, 'product', 'product_uom_unit')

            return result[1]

        except Exception, ex:

            return False

    _columns = {

        'name': fields.text('Description', required=True),

        'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),

        'date_planned': fields.date('Scheduled Date', required=True, select=True),

        'taxes_id': fields.many2many('account.tax', 'purchase_order_taxe', 'ord_id', 'tax_id', 'Taxes', domain=['|', ('active', '=', False), ('active', '=', True)]),

        'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),

        'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok','=',True)], change_default=True),

        'move_ids': fields.one2many('stock.move', 'purchase_line_id', 'Reservation', readonly=True, ondelete='set null'),

        'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),

        'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Account')),

        'order_id': fields.many2one('purchase.order', 'Order Reference', select=True, required=True, ondelete='cascade'),

        'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account',),

        'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),

        'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')],

ecc ecc


it's similar or i need to write a different code?


thank

0
Avatar
Verwerfen
Nikhil Krishnan

Hai friend, i think In the XML you did not make any change, so you need to add this 2 values( "x_IDfornitore" and x_IDfornitore2) in name field in purchase order,

So you just check my above answer once more, i will rewrite it for you, please check that this fields ( "x_IDfornitore" and x_IDfornitore2) defined in product.template. ok

mauro anelli
Autor

i'm sorry but the function you gave me is in the purchase.py from odoo 9. i change my answare with the code i found in odoo 8 versione of purchase.py. i don't if it's the same

mauro anelli
Autor

on odoo 8 this function "class PurchaseOrderLine(models.Model)" is different . it's purchase_order_line(osv.osv) ecc. the code still works or i need a different one?

thanks

Avatar
Rafael Aguero Baquero
Beste Antwort

Of course it's possible. You need to make an inheritance of purchase.order.line for rewrite the onchange_product_id method, in this method you can put into description field anything you want.

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
isn't standard_price must be depend on the product.product?
fields product.product prices product.template
Avatar
Avatar
1
Dez. 15
4710
Add purchase order field to product template
fields odoo api.depends purchase.order product.template
Avatar
Avatar
1
Aug. 23
2971
How to add a field in product.product after made some changes in product template ?
v8 fields inherit product.product product.template
Avatar
Avatar
1
Nov. 15
12195
What is the way that product.product and product.template synchronize data? Gelöst
product.product product.template
Avatar
Avatar
Avatar
2
Aug. 23
6081
Making a variantproduct from existing product templates
product.product product.template
Avatar
0
Okt. 21
2357
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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