Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

inherit sale.order.line, get bill of materials for product

Subscribe

Get notified when there's activity on this post

This question has been flagged
productinheritreportbom
2 Replies
8691 Views
Avatar
Wolfgang Steuer

I just started to develop for openerp and I'm stuck already for hours on this one:

I want to display all bill of materials with all products in the sale order for each product.

This is my class which inherits from "sale.order.line" which resides in my own module.

class sale_order_line(osv.osv):
    _inherit = "sale.order.line"

    def _get_bom(self, cr, uid, ids, field_name, arg, context=None):
         result = {}
         result[ids] = self.pool.get('product.bom_ids').browse(cr, uid, ids, context=context)
         result[boms] = self.pool.get('mrp.bom').browse(cr, uid, ids, context=context)
         return result 

    _columns = {
        'bom': fields.function(_get_bom, method=True, string='Bill of Materials', type='text', store=False)
    }

sale_order_line()

But when I use now [[ line.bom ]] in sale_order.rml I get the error message: Cannot eval 'line.bom' AttributeError: 'str' object has no attribute 'get'

What am I doing wrong? I guess it is just a simple programming mistake :(

0
Avatar
Discard
Avatar
patrick
Best Answer

The line with self.pool.get('product.bom_ids') doesn't look good.

it should be like self.pool.get(model.name), so self.pool.get('product.bom'), if product.bom is the name of the class/object for the Bill of Material.

Further, on which line does the error happen? It might be noted in the log-file.

0
Avatar
Discard
Avatar
Wolfgang Steuer
Author Best Answer

I managed to solve it myself :)

It was actually very easy without doing any code. Since a order.line contains the actual product, and a product has a reference to its boms, it looks like this: (show_bom and show_discounts are custom fields I added by inheriting "sale.order")

<section>
  <para style="terp_default_1">[[repeatIn(o.order_line,'line')]]</para>
  <blockTable colWidths="250.0,80.0,70.0,50.0,85.0" style="Table5">
    <tr>
      <td>
        <para style="terp_default_9"><b>[[ format(line.name) ]]</b></para>
        <para style="terp_default_9">[[ format(line.product_id.description) or removeParentNode('para') ]]</para>
        <section>
            <para style="terp_default_9">[[ o.show_bom and repeatIn(line.product_id.bom_ids,'bom') ]]</para>
            <para style="terp_default_9"> </para>
            <para style="terp_default_9">Stückliste: [[ format(bom.name) ]]</para>
            <section>
                <para style="terp_default_9">[[ repeatIn(bom.bom_lines,'bomline') ]]</para>
                <blockTable style="Table3" colWidths="220.0,60.0,60.0">
                    <tr>
                        <td>[[ format(bomline.product_id.name) ]]</td>
                        <td>[[ bomline.product_qty ]]</td>
                        <td>[[ o.show_bom and formatLang(bomline.product_id.list_price, digits=get_digits(dp='Product Price')) ]]</td>
                    </tr>
                </blockTable>
            </section>
        </section>
      </td>
      <td>
        <para style="terp_default_Right_9">[[ formatLang(line.product_uos and line.product_uos_qty or line.product_uom_qty) ]] [[ line.product_uos and line.product_uos.name or line.product_uom.name ]]</para>
      </td>
      <td>
        <para style="terp_default_Right_9">[[ not o.show_discounts and formatLang(line.price_unit * (1 - line.discount / 100) , digits=get_digits(dp='Product Price')) or formatLang(line.price_unit , digits=get_digits(dp='Product Price'))]]</para>
      </td>
      <td>
        <para style="terp_default_Centre_9">[[ o.show_discounts and formatLang(line.discount, digits=get_digits(dp='Discount')) or '']]</para>
      </td>
      <td>
        <para style="terp_default_Right_9">[[ formatLang(line.price_subtotal, digits=get_digits(dp='Account'), currency_obj=o.pricelist_id.currency_id) ]] </para>
      </td>
    </tr>
  </blockTable>
</section>
0
Avatar
Discard
a

hi this looks nice, but where did you place this code ?

Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
How to get Virtual Stock and Real Stock in Report
product report
Avatar
0
Mar 15
5142
Cost Break Up Solved
product bom Odoo17
Avatar
Avatar
2
May 24
2053
How to restrict the number of BoM per product ? Solved
product bom nomenclature
Avatar
Avatar
3
Jan 24
2289
Cost by BoM can be automated?
product mrp bom
Avatar
0
Sep 23
2571
BOM not calculating correctly in Product
manufacturing product bom
Avatar
Avatar
1
May 23
3501
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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