Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
viewsfieldsproduct.productpurchase.orderproduct.template
3 Replies
5592 Views
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
Discard
Avatar
Nikhil Krishnan
Best Answer

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
Discard
Avatar
mauro anelli
Author Best Answer

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
Discard
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
Author

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
Author

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
Best Answer

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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
isn't standard_price must be depend on the product.product?
fields product.product prices product.template
Avatar
Avatar
1
दिस॰ 15
4713
Add purchase order field to product template
fields odoo api.depends purchase.order product.template
Avatar
Avatar
1
अग॰ 23
2979
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
नव॰ 15
12212
What is the way that product.product and product.template synchronize data? Solved
product.product product.template
Avatar
Avatar
Avatar
2
अग॰ 23
6108
Making a variantproduct from existing product templates
product.product product.template
Avatar
0
अक्तू॰ 21
2364
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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