Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How to domain product variant based on pricelist in sale order

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
sale.order.linesale.order.formOdoo13.0
1 Răspunde
6853 Vizualizări
Imagine profil
Hoang

Hi everyone,

I'm trying to domain product_id in sale.order.line based on pricelist in sale.order form.

I'm using a dynamic domain for it but it's not working. Here is my code in sale.order:

@api.onchange('pricelist_id')   

 def onchange_pricelist_id(self):        

product_id = self.order_line.product_id  

product_ids = []        

if self.pricelist_id:            

for rec in self.pricelist_id.item_ids:                

product_ids.append(rec.id)                        

return {'domain': {'product_id': [('id', 'in', product_ids)]}}


I'm also trying to use name_get() in product.product:

def name_get(self):        

if self._context.get('temp'):            

return super(ProductProduct, self).name_get()        

product_list = []        

pricelist = self.env['product.pricelist'].browse(self._context.get('pricelist'))        

if pricelist:            

for rec in pricelist.item_ids:                

if rec.applied_on == '0_product_variant':                    

product_list.append(rec.product_id.id)        

if product_list:            

self = self.browse(product_list)        

result = super(ProductProduct, self).name_get()        

return result

but it throws :

Error:
Odoo Server Error

Traceback (most recent call last):
File "/opt/odoo13/odoo/odoo/loglevels.py", line 92, in ustr
return text_type(value)
File "/opt/odoo13/odoo/odoo/tools/func.py", line 150, in __str__
def __str__(self): return str(self._value)
File "/opt/odoo13/odoo/odoo/tools/func.py", line 137, in _value
value = self._func(*self._args, **self._kwargs)
File "/opt/odoo13/odoo/odoo/tools/func.py", line 167, in __getitem__
def __getitem__(self, key): return self._value[key]
KeyError: 36

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/odoo13/odoo/odoo/http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo13/odoo/odoo/http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo13/odoo/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/opt/odoo13/odoo/odoo/http.py", line 678, in dispatch
return self._json_response(result)
File "/opt/odoo13/odoo/odoo/http.py", line 607, in _json_response
body = json.dumps(response, default=date_utils.json_default)
File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/opt/odoo13/odoo/odoo/tools/date_utils.py", line 211, in json_default
return ustr(obj)
File "/opt/odoo13/odoo/odoo/loglevels.py", line 94, in ustr
raise UnicodeError('unable to convert %r' % (value,))
UnicodeError: unable to convert <odoo.tools.func.lazy object at 0x7fbec8aa6900>


Is anyone have solutions for this? Please help me.

Best regards

0
Imagine profil
Abandonează
Imagine profil
Sylvain Michel Ratsarafahatra
Cel mai bun răspuns

Hi,

I suggest you to add only a dynamic domain depending of pricelist selected when you choose a product in the order lines.

e.g.:

class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

@api.onchange('product_id')
def onchange_product_id(self):
if self.order_id.pricelist_id:
product_template_ids = self.env['product.template'].search([]).filtered(
lambda x: self.order_id.pricelist_id.id in x.item_ids.mapped('pricelist_id').ids)
product_ids = self.env['product.product'].search([('product_tmpl_id', 'in', product_template_ids.ids)])
return {'domain': {'product_id': [('id', 'in', product_ids.ids)]}}
Best regards!
1
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Odoo 13: How do you switch from inline adding of products to the detail window? Rezolvat
sale.order.line Odoo13.0
Imagine profil
Imagine profil
2
aug. 20
3404
Section and Note is not adding in order line
sale.order.line Odoo13.0
Imagine profil
0
feb. 20
4655
Tax Calculation in Sales Module(Sales.Order.Line ) Rezolvat
sale.order.line sale.order.form
Imagine profil
Imagine profil
2
oct. 16
9639
Modificación Lista de Productos en una Orden de Venta Rezolvat
sale.order.line sale.order.form sale.order
Imagine profil
Imagine profil
2
apr. 25
1547
Sales Order From Excel Sheets Rezolvat
sales sale.order.line sale.order.form
Imagine profil
Imagine profil
1
nov. 24
2668
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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