Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How can I convert the value of a BOM line from the product name to its internal code when importing a product's BOM?

Odoberať

Get notified when there's activity on this post

This question has been flagged
bom_import
2 Replies
3244 Zobrazenia
Avatar
TTN SOLUTION

My product codes are unique, and I want to use them for importing instead of using names. How can I accomplish this? I greatly appreciate any assistance.

0
Avatar
Zrušiť
Avatar
shubham shiroya
Best Answer
  1. Create a Python function that performs the conversion. This function will take the product name as a parameter, search for the product based on its name, and return its internal code.
    from odoo import api, models

    class YourBOMImportModel(models.Model):
    _name = 'your.bom.import.model'

    @api.model
    def convert_product_name_to_code(self, product_name):
    product = self.env['product.product'].search([('name', '=', product_name)], limit=1)
    if product:
    return product.default_code
    return False


    In your import logic, call the convert_product_name_to_code function for each BOM line to convert the product name to its internal code.

# Assuming you have a list of BOM lines with product names

bom_lines = [{'product_name': 'Product A'}, {'product_name': 'Product B'}] bom_import_model = self.env['your.bom.import.model']

for line in bom_lines:
product_name = line['product_name']
product_code = bom_import_model.convert_product_name_to_code(product_name)

if product_code:
# Use the product code in your import logic
line['product_code'] = product_code
else:
# Handle the case when the product name doesn't exist or conversion fails
line['product_code'] = ''

In the above code, convert_product_name_to_code method performs a search on the product.product model based on the product name. It retrieves the first product that matches the name and returns its default_code field value (the internal code). If no product is found, it returns False.
You can then integrate this code into your BOM import process, where you iterate through each BOM line and call the convert_product_name_to_code function to convert the product name to its internal code. Update your BOM line data with the product code accordingly.

0
Avatar
Zrušiť
TTN SOLUTION
Autor

Thank you for your support, it means a lot to me. However, as a beginner programmer, I have limited knowledge of the Excel import process. I'm unsure about how to override the default Excel import process in Odoo. I want to import data using the 'default_code' field, but Odoo requires 'externalId' and the product name, which doesn't align with my requirements.

Avatar
Thuy Ngoc
Best Answer

Hi  TTN SOLUTION,

I think this video can help you: https://www.youtube.com/watch?v=UOBxxnYDIsM&list=PLSKcWRTtEl5qzvRaI-VTGavfReiHS_EEb&index=1

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Issue with Importing Child Components in BOM Using Database IDs in Odoo 18
bom_import
Avatar
Avatar
1
jan 25
2141
Import bill of materials from excel or csv files
bom_import
Avatar
Avatar
Avatar
3
júl 18
11942
Is it possible to enable "Manual Consumption" when importing a Bill of Materials (BoM) in Odoo?
bom_import BOM
Avatar
0
apr 25
13
BoM Import Add Instead of Replace Components
bom_import BOM
Avatar
Avatar
1
mar 25
2229
BOM Components Variant
bom_import bom_lines
Avatar
Avatar
Avatar
3
feb 25
1718
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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