Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
odooodooV8
2 Odpowiedzi
23288 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Mohammed Amal N
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Synodica Solutions Pvt. Ltd.
Najlepsza odpowiedź

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

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Add a button to a ValidationError
odoo odooV8
Awatar
Awatar
1
lis 22
4255
How to get values of one record of a many2many relation displayed in a tree view when clicking on a button
odoo odooV8
Awatar
0
cze 21
6814
How to pass string in wizard context
odoo odooV8
Awatar
0
mar 21
3626
How to replace invoice number sequence by invoice id from database
odoo odooV8
Awatar
Awatar
2
maj 18
4916
Writing value to One2many Field odoo 8
odoo odooV8
Awatar
Awatar
3
maj 18
5941
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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