Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Field sales_count

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
salesproductenterprisev15
2 Replies
3747 Tampilan
Avatar
Kamran Lalehparvar

Hi

How can i have a filed like sales_count on product.product that showing sales on last 180 days and 90 days ago instead of 365 days ago ?

thank you in advance

0
Avatar
Buang
Avatar
Alexandre Sousa
Jawaban Terbai

Hi Kamran,

You can start by creating a new smart button in the product, for that, I suggest you extend the xml of the product. 

Here is the standard xml that creates the standard button (365 days) you can use it as a base to create your own button:


model="ir.ui.view" id="product_form_view_sale_order_button">
name="name">product.product.sale.order
name="model">product.product
name="inherit_id" ref="product.product_normal_form_view"/>
name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>
name="arch" type="xml">
name="button_box" position="inside">


name="description" position="after">
string="Warning when Selling this Product" groups="sale.group_warning_sale">
name="sale_line_warn" nolabel="1"/>
name="sale_line_warn_msg" colspan="3" nolabel="1"
attrs="{'required':[('sale_line_warn','!=','no-message')],'readonly':[('sale_line_warn','=','no-message')]}"/>





** of course you must create also your own custom field  sales_count and calculate it using a compute function

Then you just need to create a new action in the product by extending the py of the product.

Here is the standard action to open the sales of the last 365 days:


def action_view_sales(self):
action = self.env.ref('sale.report_all_channels_sales_action').read()[0]
action['domain'] = [('product_id', 'in', self.ids)]
action['context'] = {
'pivot_measures': ['product_uom_qty'],
'active_id'
: self._context.get('active_id'),
'search_default_Sales'
: 1,
'active_model'
: 'sale.report',
'time_ranges'
: {'field': 'date', 'range': 'last_365_days'},
}
return action


Here is the tricky part: if you don't calculate the domain in python you must create a new filter in the search portion of the xml, so then you can call this new filter in the action by passing its name by context.

Hope it helps you to get started.

1
Avatar
Buang
Kamran Lalehparvar
Penulis

Hi Alexander
Thank you for your reply unfortunately I’m not that much technical i was wondering if you make it a little more clear

Alexandre Sousa

Hi Kamran, I've included more details in the answer, hope that helps in giving you a better direction.

Kamran Lalehparvar
Penulis

Alexander
Thank you 🙏
Can i have the code for compute custom filed ? And one more thing can i use server action instead of extend py code ? If yes please kindly describe it a little more
Thank you in advance

Alexandre Sousa

Hi Kamran,
Here is the code for the field:
sales_count = fields.Float(compute='_compute_sales_count', string='Sold')
def _compute_sales_count(self):
r = {}
self.sales_count = 0
if not self.user_has_groups('sales_team.group_sale_salesman'):
return r
date_from = fields.Datetime.to_string(fields.datetime.combine(fields.datetime.now() - timedelta(days=365),
time.min))

done_states = self.env['sale.report']._get_done_states()

domain = [
('state', 'in', done_states),
('product_id', 'in', self.ids),
('date', '>=', date_from),
]
for group in self.env['sale.report'].read_group(domain, ['product_id', 'product_uom_qty'], ['product_id']):
r[group['product_id'][0]] = group['product_uom_qty']
for product in self:
if not product.id:
product.sales_count = 0.0
continue
product.sales_count = float_round(r.get(product.id, 0), precision_rounding=product.uom_id.rounding)
return r

If you are still having problems modifying this I suggest you get started with the tutorials on the Odoo website.

Avatar
Farooq Rajput
Jawaban Terbai

in product.template

sales_count_custom = fields.Float(compute='_compute_sales_count_custom',string='90 Days Sale')


@api.depends('product_variant_ids.sales_count_custom')    def_compute_sales_count_custom(self):        for product inself:            product.sales_count_custom =float_round(sum([p.sales_count_custom for p in product.with_context(active_test=False).product_variant_ids]),precision_rounding=product.uom_id.rounding)        defaction_view_sales_custom(self):        action =self.env["ir.actions.actions"]._for_xml_id("sale.report_all_channels_sales_action")        action['domain']=[('product_id','in',self.ids)]        action['context']={            'pivot_measures':['product_uom_qty'],            'active_id':self._context.get('active_id'),            'search_default_Sales':1,            'active_model':'sale.report',            'time_ranges':{'field':'date','range':'last_90_days'},        }        return action


in view 


  <xpathexpr="//div[@name='button_box']"position="inside">                    <buttonclass="oe_stat_button"name="action_view_sales_custom"                        type="object"icon="fa-bar-chart-o"groups="sales_team.group_sale_salesman"help="Sold in the last 90 days"attrs="{'invisible': [('sale_ok', '=', False)]}">                        <divclass="o_field_widget o_stat_info">                            <spanclass="o_stat_value">                                <fieldname="sales_count_custom"widget="statinfo"nolabel="1"class="mr4"/>                                <fieldname="uom_name"/>                            span>                            <spanclass="o_stat_text">90 Daysspan>                        div>                    button>                xpath>

0
Avatar
Buang
Farooq Rajput

it will work for 90 days. cheers . after looking at this , you can make 180 days one aswell.

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How do i edit odoo default product view?
sales product odoo v15
Avatar
Avatar
Avatar
2
Jan 24
4596
Conditionally show or hide product attributes (Odoo Online/Studio)
sales product
Avatar
Avatar
1
Okt 25
665
Hide the cost
sales product
Avatar
Avatar
Avatar
2
Mei 25
4501
Products in multi company
sales product
Avatar
0
Nov 24
1519
how to filter out all products which got no sales with the last 3 months or a specific period?
sales product
Avatar
Avatar
1
Agu 24
2336
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik 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