İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Yapay Zeka
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım
Toplulukla etkileşime geçmek için kayıtlı olmanız gerekir.
Tüm Gönderiler İnsanlar Rozetler
Etiketler (Tümünü göster)
odoo accounting v14 pos v15
Bu forum hakkında
Toplulukla etkileşime geçmek için kayıtlı olmanız gerekir.
Tüm Gönderiler İnsanlar Rozetler
Etiketler (Tümünü göster)
odoo accounting v14 pos v15
Bu forum hakkında
Yardım

Update the discount in POS order

Abone Ol

Bu gönderide etkinlik olduğunda bildirim alın

Bu soru işaretlendi
Odoo17
3028 Görünümler
Avatar
vision valley , jenan soliman

Hello,

I have membership model that have consumed discount ids having consumed times and remaining times  and discount in POS when add the product, and it has discount the discount applied based in the remain times however I update the remaining times when I create the payment not when I add line because if I add lines remove I can not retrieve it back I want to another logic to achieve this  here's my function 

class Partner(models.Model):
_inherit = 'res.partner'

customer_membership_ids = fields.One2many('customer.membership', 'partner_id', string='Customer Memberships')

def get_free_service_discount_for_product(self, product_id, categ_id, line_qty, pricelist_id,order_lines,appointment_id=None,):
product = self.env['product.product'].browse(int(product_id))
categ = self.env['product.category'].browse(int(categ_id))
pricelist = self.env['product.pricelist'].browse(int(pricelist_id))
order_lines = self.env['pos.order.line'].search([('product_id', '=', int(product_id))])
if not order_lines:
print(f"No order lines found for product {product_id}")
return False

order = order_lines[0].order_id

if not order:
print("Error: No order found for the provided product.")
return False

active_memberships = self.customer_membership_ids.filtered(lambda mem : mem.status=='active')
active_membership = False

pos_order_return = self.env.context.get('pos_order_return', False)
payment_created = self.env.context.get('payment_created', False)
discount = self.env.context.get('discount', False)
print(discount)

print(f"Context: {self.env.context}")
print(f"Received pos_order_return: {pos_order_return}, payment_created: {payment_created}")

print(f"Received appointment_id: {appointment_id}")


appointment=None
if appointment_id:
appointment = self.env['business.appointment'].browse(appointment_id)

if appointment:
membership= appointment.membership_id
print("mem",membership)
free_service_products = []
free_discount_products = []
free_discount_product_categs = []
options = {}
if appointment:
active_membership= appointment.membership_id
elif active_membership and active_memberships:
active_membership = active_memberships[0]

for membership in active_memberships:
free_discount_lines = membership.consumed_discount_ids.filtered(
lambda discount: (discount.times and discount.remaining_times) or (
not discount.times and not discount.remaining_times)
)
if free_discount_lines:
active_membership = membership
break


if appointment:
print("i got an appiotment")
active_membership= appointment.membership_id

elif active_membership and active_memberships:
print("no appiotment")
for membership in active_memberships:
valid_discount = membership.consumed_discount_ids.filtered(lambda discount: discount.remaining_times > 0)
if valid_discount:
active_membership = membership
break
else:
active_membership = active_memberships[0]


if active_membership:


free_service_lines = active_membership.consumed_service_ids.filtered(lambda service : (service.times and service.remaining_times) or (not service.times and not service.remaining_times))
free_service_products = free_service_lines.mapped('product_id')
free_discount_lines = active_membership.consumed_discount_ids.filtered(lambda discount : (discount.times and discount.remaining_times) or (not discount.times and not discount.remaining_times))
free_discount_products = free_discount_lines.mapped('product_id')
free_discount_product_categs = free_discount_lines.mapped('product_categ_id')
options['customer_membership_id'] = {'id': active_membership.id, 'name':active_membership.name, 'package_name':active_membership.membership_package_id.name}

for discount_line in free_discount_lines:
discount_line.remaining_times


if product in free_service_products:
options['price'] = 0
options['lst_price'] = 0
ser_prod_line = free_service_lines.filtered(lambda ser:ser.product_id == product)
options['consumed_service_id'] = ser_prod_line[0].id


elif product in free_discount_products:
dis_prod_line = free_discount_lines.filtered(lambda dis:dis.product_id == product)
options['discount'] = dis_prod_line[0].discount
options['consumed_discount_id'] = dis_prod_line[0].id
for order_line in order_lines:
print("discount",options['discount'])
print(
f"Discount found on product {product_id} in order {order.id}. Discount: {order_line.discount}%")

# dis_prod_line[0].consumed_times += 1
# dis_prod_line[0]._get_remaining()
if self.env.context.get('pos_order_state', 'draft') == 'draft':
if dis_prod_line[0].remaining_times > 0:
print("producuuuuuuuuuuuuuuuuuuuuuuuuct")
# dis_prod_line[0].consumed_times += 1
# dis_prod_line[0]._get_remaining()
update_applied = True

elif categ in free_discount_product_categs:
dis_categ_line = free_discount_lines.filtered(lambda dis:dis.product_categ_id == categ)
options['discount'] = dis_categ_line[0].discount
options['consumed_discount_id'] = dis_categ_line[0].id



else:
options['discount'] = 0
options['price'] = pricelist.sudo()._get_product_price(product, int(line_qty))
options['lst_price'] = pricelist.sudo()._get_product_price(product, int(line_qty))
options['customer_membership_id'] = False
options['consumed_service_id'] = False
options['consumed_discount_id'] = False
0
Avatar
Vazgeç
Tartışma hoşunuza mı gidiyor? Sadece okumakla kalmayın, katılın!

Özel özelliklerden yararlanmak ve harika topluluğumuzla etkileşime geçmek için bugün bir hesap oluşturun!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Displaying Many2one field on mobile devices identical to desktop view in Odoo 17
Odoo17
Avatar
Avatar
1
Tem 25
2747
New employee Button in POS
Odoo17
Avatar
0
Eki 24
3685
ADD new group under other
Odoo17
Avatar
Avatar
1
Eki 24
4243
Odoo 17 kanban second Progress bar
Odoo17
Avatar
0
Eki 24
2924
Time sheets - Non DB User Employees
Odoo17
Avatar
0
Eki 24
2484
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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