Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • Hotel
    Real Estate
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    Consulting
    • Accounting Firm
    • Odoo पार्टनर
    • Marketing Agency
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • 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

How to create sample sale order and sale order line in odoo?

Subscribe

Get notified when there's activity on this post

This question has been flagged
odooodooV8
2 Replies
23242 Views
Avatar
bhanukiran

I am trying to create a sample order in sales order.In the sample order form, products are sold to customers as complimentary copy(books in my case) without charging any money so I have created a separate sub-menu in sales menu.Here I take only product and quantity as input. Sample order number will be the next number from the sales order(like SO360).So I am fetching sales order number as parent_id in my inherited module.I am not able to create sale order line(data in order lines tab)

    class SaleOrder(models.Model):

    _inherit = 'sale.order'


    is_sample = fields.Boolean(string="Sample Order", default=False)

    parent_id = fields.Many2one('sale.order', string="Parent Sales Order")

    sample_ids = fields.One2many('sale.order', 'parent_id', string="Sample Orders")


    @api.model

    @api.returns('sale.order')

    def create(self, vals):

        if vals.get('is_sample', False) and vals.get('name', '/') == '/':

            IrSeq = self.env['ir.sequence']

            ref = IrSeq.next_by_code('sale.order.sample.ref') or '/'

            parent = self.search([('id', '=', vals.get('parent_id'))])

            vals['name'] = parent.name + ref

            vals['user_id'] = parent.user_id.id


        return super(SaleOrder, self).create(vals)


class SampleOrderWizard(models.TransientModel):

    _name = 'sale.order.sample.wizard'

    _description = 'Sample Sale Order Wizard'


    def _get_parent(self):

        res = False

        if self.env.context \

                and 'active_id' in list(self.env.context.iterkeys()):

            res = self.env.context['active_id']

            

        return res


    def _get_new_sale_line(self, orig_sale, orig_sale_line):

        """Internal function to get the fields of the sale order line. Modules

        enhancing this one should add their own fields to the return value."""


        res = {

            'order_id': orig_sale.id,

            'product_id': orig_sale_line.product.id,

            'name': orig_sale_line.name,

            'sequence': orig_sale_line.sequence,

            'price_unit': orig_sale_line.price_unit,

            'product_uom': orig_sale_line.product_uom.id,

            'product_uom_qty': orig_sale_line.qty or 1,

            'product_uos_qty': orig_sale_line.qty or 1,

        }

        self.env['sale.order.line'].create(res)


        return res


    def _get_order_lines(self, sale):

        res = []

        line_env = self.env['sale.order.sample.wizard.line']

        res = self._get_new_sale_line(sale, line_env)


        for line in sale.order_line:

            wizard_line = False

            for wzline in self.wizard_lines:

                if wzline.product == line.product_id:

                    wizard_line = wzline

                    break


            if wizard_line:

                res.append(

                    (0, 0, self._get_new_sale_line(sale, line, wizard_line))

                )


        return res


    def _get_wizard_lines(self):

        res = []

        if self._get_parent():

            SaleOrder = self.env['sale.order']

            parent = SaleOrder.search([('id', '=', self._get_parent())])

            for line in parent.order_line:

                res.append((0, 0,

                            {

                                'product': line.product_id,

                                'qty': 1,

                            }))

        return res


   


    @api.one

    def create_order(self):


        sale_vals = {

            'user_id': self.order.user_id.id,

            'partner_id': self.order.partner_id.id,

            'parent_id': self.order.id,

            'date_order': self.order_date,

            'client_order_ref': self.order.client_order_ref,

            'company_id': self.order.company_id.id,

            'is_sample': True,

            'order_line': self._get_order_lines(self.order)

        }

        self.env['sale.order'].create(sale_vals)


        return {'type': 'ir.actions.act_window_close'}


    order = fields.Many2one('sale.order', default=_get_parent, readonly=True)

    wizard_lines = fields.One2many('sale.order.sample.wizard.line', 'wizard', default=_get_wizard_lines)

    order_date = fields.Datetime(default=fields.Datetime.now())



class SampleOrderWizardLine(models.TransientModel):


    _name = 'sale.order.sample.wizard.line'

    _description = 'Sample Order Wizard Line'


    wizard = fields.Many2one('sale.order.sample.wizard')

    product = fields.Many2one('product.product',

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

    qty = fields.Float(string="Quantity", default=1.0, digits_compute=dp.get_precision('Product UoS'))

0
Avatar
Discard
Avatar
Mohammed Amal N
Best Answer

Existing order lines is a One2many relation to model sale.order.line, you can inherit it if you need to alter it
Or if you are trying to show another tree view below it you can add a One2many relation to that model in sale.order and from xml inherit sale order form view and add your one2many field

0
Avatar
Discard
Avatar
Synodica Solutions Pvt. Ltd.
Best Answer

\https://apps.odoo.com/apps/modules/13.0/pos_test_orders/

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
Add a button to a ValidationError
odoo odooV8
Avatar
Avatar
1
नव॰ 22
4222
How to get values of one record of a many2many relation displayed in a tree view when clicking on a button
odoo odooV8
Avatar
0
जून 21
6798
How to pass string in wizard context
odoo odooV8
Avatar
0
मार्च 21
3602
How to replace invoice number sequence by invoice id from database
odoo odooV8
Avatar
Avatar
2
मई 18
4900
Writing value to One2many Field odoo 8
odoo odooV8
Avatar
Avatar
3
मई 18
5920
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • 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