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
    • Discuss
    • 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
    • Manajemen Properti
    • 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
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

Journal Entry

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
developmenttechnicalodoo16features
1 Balas
3400 Tampilan
Avatar
klRZ

I have set Costing method as average cost and Inventory Valuation as Automated, I created a landed cost the cost changes and I changed the price manually and caused a Stock Valuation Layer and Journal entries has been created,

I want to delete these entries using code how?

0
Avatar
Buang
klRZ
Penulis

i created a button in landed cost to cancel i tried something like this so when i change the product price 2 entries are created one 'stock.valuation.layer' and one Journal entree

stock valuation contatins a description saying Product value manually modified from 1000 to 200

i tried it using like this

if product.cost_method == 'average':
original_price = product.standard_price
new_price = product.standard_price - line.additional_landed_cost
product.write({'standard_price': new_price})
stock_valuation_layer = self.env['stock.valuation.layer'] \
.search([('product_id', '=', product.id),
('description', '=', f'Product value manually '
f'modified (from {original_price} to {new_price})')],
limit=1)
if stock_valuation_layer:
stock_valuation_layer.account_move_id.button_draft()
stock_valuation_layer.account_move_id.sudo().unlink()
stock_valuation_layer.sudo().unlink()

 
This works but  i want to search that stock.valuation.layer instead of seaching using description ,any other way? for this 

self.env['stock.valuation.layer'] \
.search([('product_id', '=', product.id),
('description', '=', f'Product value manually '
f'modified (from {
original_price} to {new_price})')],
limit
=1) or should i keep it like this

ANY IDEAS  

Avatar
shubham shiroya
Jawaban Terbai

you can achieve it using code. Here's an example of how you can delete these entries programmatically:

# Import necessary models
from odoo import api, models

class StockValuationEntryDeletion(models.Model):
_inherit = 'stock.valuation.layer'

@api.model
def delete_entries(self, product_id):
# Retrieve the Stock Valuation Layer entries for the given product
valuation_entries = self.search([('product_id', '=', product_id)])

# Delete the Stock Valuation Layer entries
valuation_entries.unlink()

class JournalEntryDeletion(models.Model):
_inherit = 'account.move'

@api.model
def delete_entries(self, product_id):
# Retrieve the Journal entries for the given product
journal_entries = self.env['account.move'].search([('stock_valuation_layer_ids.product_id', '=', product_id)])

# Delete the Journal entries
journal_entries.unlink()


You can then use these methods to delete the entries. For example:

product_id = 123 # Replace with the actual product ID
StockValuationEntryDeletion.delete_entries(product_id)
JournalEntryDeletion.delete_entries(product_id)

Make sure you run this code with the necessary access rights and proper validation to ensure the correct entries are deleted. It's recommended to test this code in a development environment first and take proper backups before running it in a production environment.


0
Avatar
Buang
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
Odoo Server Error when opening Hospital Module?
development odoo16features
Avatar
Avatar
1
Sep 23
3500
how to populate a new field in odoo on old records
development fields odoo16features
Avatar
Avatar
1
Agu 25
4208
What are the fields ending with "_signed" in the model account_move for? Diselesaikan
development invoicing odoo16features
Avatar
Avatar
1
Apr 24
4125
Can i Integrate Erply POS website to Odoo Enterprise 16.3 online (Saas) .. ??
development implementation odoo16features
Avatar
0
Okt 23
3215
Why I can't see my Custom Model in Apps? Diselesaikan
development documentation odoo16features
Avatar
Avatar
Avatar
2
Sep 23
4923
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 Svenska ภาษาไทย 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