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

developing my first app

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
developement
1 Odpowiedz
3173 Widoki
Awatar
Wombat

Hi,

I thought id challenge myself by creating an app to pull the previous sales quantities into the product template list view. After many, many hours, unfortunately it seems I cannot work out how to do it.

I have successfully put a float field on the product.template.

Here is my model:

from odoo import api, models, fields

class ProductsSold(models.Model):
_inherit = "product.template" # database table name.

sold = fields.Float(compute='_compute_avail', string="Avail")

def _compute_avail(self):
#sold = self.env['stock.quant'].search_count([])
# records_sum = sum(self.env["stock.quant"].search([]).mapped('inventory_quantity'))
records_sum = sum(self.env["sale.sale_order_line"].search([]).mapped('product_uom_qty'))
self.sold = records_sum

If anyone can offer any hints, I'd be grateful.




0
Awatar
Odrzuć
Wombat
Autor

Thank you for your response. Awesome!! It works perfectly.

Next challenge: I would then like to set some filters on this field to sum up the sales in the past month - which I think I can probably achieve now. 

Although, I am curious about your mention of uom. Is there something here I am overlooking?

Ray Carnes (ray)

If you ANSWER a question, the OP is notified, but nobody else. I can't convert your answer into a comment that @Fazle can see, so if you'd like to ping him, please comment on HIS answer.

Fazle Rabbi Ferdaus

Hi wombat, may I know which approach you followed?

Wombat
Autor

Hi Fazle, I when with the first version. I think the word "available" caused some confusion as I was looking for the quantity sold.
Thank you Ray. I am new to forums and their etiquette. I imagine from your response I must have hit answer instead of comment. Not sure what an OP is - or this karma thing that keeps popping up. I'll see what google can tell me.

Fazle Rabbi Ferdaus

wombat, I still advise you to go forward with the second approach

Awatar
Fazle Rabbi Ferdaus
Najlepsza odpowiedź

Hi Wombat, this should find the qty sold for a product. Also you have to add it to the view. Again I think you should also consider uom. Another thing is there is already a field in the product template form to show the sale qty. The field is called 'sales_count'. So this funtion or a new field should be redundent. 

from odoo import api, models, fields

class ProductsSold(models.Model):
_inherit = "product.product" # database table name.

def _compute_avail(self):
records_sum = sum(self.env["sale.order.line"].search([('product_id', '=', self.id), ('state', '=', 'sale')]).mapped('product_uom_qty'))
self.sold = records_sum sold = fields.Float(compute='_compute_avail', string="Avail")

instead this below should do want you want to achive. and no need to create any field or method. in words you need to inherit the tree view and just add the sales_count field. **Code section in comment does not let me include closing tags**


product_template_inherit_treefield>
product.templatefield>





xpath>

field>
record>


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ść
UI All over the place
developement
Awatar
Awatar
Awatar
3
cze 23
2868
How to set my test period account in my local odoo
developement
Awatar
Awatar
1
wrz 22
3305
How to read a record for each row
developement
Awatar
0
kwi 22
4190
How to disable the existing data suggestions when entering new one
developement
Awatar
Awatar
1
sty 22
5085
Begenning in odoo developement
developement
Awatar
Awatar
2
paź 16
3830
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