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

Calculate Product Cost Price through BoM

Subscribe

Get notified when there's activity on this post

This question has been flagged
v8mrpcost_pricebom
1 Reply
10265 Views
Avatar
Herman

I use Average pricing so that my raw materials' cost will be updated with each Purchase. But how do I make my Product's price with BoMs update according to materials/products price updates? I have over 200 000 thousand products, so this cant be done manually

0
Avatar
Discard
Avatar
E.R. Spada
Best Answer

We created a cron in v8 to update standard cost with bom, it is the only way. I have no idea why this is not built in. We extended the product_extended_module, here is the function:

class product_template(osv.osv):

_name = 'product.template'

_inherit = 'product.template'


Here is the wizard:

from openerp.exceptions import except_orm

from openerp.osv import fields, osv

from openerp.tools.translate import _

class wizard_price(osv.osv):

_name = "wizard.price"

_description = "Compute price wizard"

_columns = {

'info_field': fields.text('Info', readonly=True),

'real_time_accounting': fields.boolean("Generate accounting entries when real-time"),

'recursive': fields.boolean("Change prices of child BoMs too"),

}

def default_get(self, cr, uid, fields, context=None):

res = super(wizard_price, self).default_get(cr, uid, fields, context=context)

product_pool = self.pool.get('product.template')

product_obj = product_pool.browse(cr, uid, context.get('active_id', False))

if context is None:

context = {}

rec_id = context and context.get('active_id', False)

assert rec_id, _('Active ID is not set in Context.')

res['info_field'] = str(product_pool.compute_price(cr, uid, [], template_ids=[product_obj.id], test=True, context=context))

return res

def compute_from_bom(self, cr, uid, ids, context=None):

assert len(ids) == 1

if context is None:

context = {}

model = context.get('active_model')

if model != 'product.template':

raise except_orm(_('Wrong model!'), _('This wizard is build for product templates, while you are currently running it from a product variant.'))

rec_id = context and context.get('active_id', False)

assert rec_id, _('Active ID is not set in Context.')

prod_obj = self.pool.get('product.template')

res = self.browse(cr, uid, ids, context=context)

prod = prod_obj.browse(cr, uid, rec_id, context=context)

prod_obj.compute_price(cr, uid, [], template_ids=[prod.id], real_time_accounting=res[0].real_time_accounting, recursive=res[0].recursive, test=False, context=context)

def compute_price_schedular(self, cr, uid, context=None):

print "-------------------------------schedular calling-------------------------------------------"

template_ids = self.search(cr,uid, [("cost_method","=","standard")])

print "template_ids----",template_ids

if template_ids:

self.compute_price(cr, uid, [],template_ids=template_ids, recursive=True, test=False, real_time_accounting = False, context=None)

return True

def compute_price(self, cr, uid, product_ids, template_ids=False, recursive=False, test=False, real_time_accounting = False, context=None):

'''

Will return test dict when the test = False

Multiple ids at once?

testdict is used to inform the user about the changes to be made

'''

testdict = {}

if product_ids:

ids = product_ids

model = 'product.product'

else:

ids = template_ids

model = 'product.template'

if not ids:

return True

for prod_id in ids:

bom_obj = self.pool.get('mrp.bom')

if model == 'product.product':

bom_id = bom_obj._bom_find(cr, uid, product_id=prod_id, context=context)

else:

bom_id = bom_obj._bom_find(cr, uid, product_tmpl_id=prod_id, context=context)

if bom_id:

# In recursive mode, it will first compute the prices of child boms

if recursive:

#Search the products that are components of this bom of prod_id

bom = bom_obj.browse(cr, uid, bom_id, context=context)

#Call compute_price on these subproducts

prod_set = set([x.product_id.id for x in bom.bom_line_ids])

res = self.compute_price(cr, uid, list(prod_set), recursive=recursive, test=test, real_time_accounting = real_time_accounting, context=context)

if test:

testdict.update(res)

#Use calc price to calculate and put the price on the product of the BoM if necessary

price = self._calc_price(cr, uid, bom_obj.browse(cr, uid, bom_id, context=context), test=test, real_time_accounting = real_time_accounting, context=context)

if test:

testdict.update({prod_id : price})

if test:

return testdict

else:

return True

-1
Avatar
Discard
Emipro Technologies Pvt. Ltd.

No one can even understand your answer. Please use "Code" style from editor.

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
Subcontracting Product with multiple BoM
mrp bom
Avatar
0
Oct 25
1626
BOM with some item quantity which not depends of the whole quantity to produce Solved
mrp bom
Avatar
Avatar
1
Jun 25
5489
How to show BOM matrix with quantity of used product?
mrp bom
Avatar
0
Feb 19
4565
Discrepancy between MRP Cost Report and Compute From BOM Calculation
mrp bom
Avatar
0
Nov 18
4094
BOM cost - odoo 8 online -
cost_price bom
Avatar
Avatar
Avatar
3
Aug 17
6080
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