Search code examples
odoo-11

How to store company_dependent field in odoo?


I want to store standard_price field of prodct.product table to use this field value in sql query.

Code is here:

# -*- coding: utf-8 -*-
from odoo import fields, models
from odoo.addons import decimal_precision as dp

    class Product(models.Model):
        _inherit = "product.product"

        standard_price = fields.Float(
            'Cost', company_dependent=True,
            digits=dp.get_precision('Product Price'),
            groups="base.group_user",store=True,
            help = "Cost used for stock valuation in standard price and as a first price to set in average/fifo. "
                   "Also used as a base price for pricelists. "
                   "Expressed in the default unit of measure of the product.")

Solution

  • You can not store company_dependent field in a database. Because when the company is change then company_depedent field value is also changed.

    This field data is stored in ir.property object in odoo which name is Company Properties in odoo.

    enter image description here