Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Default value for a field not works

By
José
on 1/30/15, 1:38 PM 1,078 views

Hello, I have Odoo 8. I want to set the default cost method of the product in "average".

This is the definition of the field in stock.account:

'cost_method': fields.property(type='selection', selection=[('standard', 'Standard Price'), ('average', 'Average Price'), ('real', 'Real Price')],
            help="""Standard Price: The cost price is manually updated at the end of a specific period (usually every year).
                    Average Price: The cost price is recomputed at each incoming shipment and used for the product valuation.
                    Real Price: The cost price displayed is the price of the last outgoing product (will be use in case of inventory loss for example).""",
            string="Costing Method", required=True, copy=True),

And I try this:

class product_template(models.Model):
    _inherit = 'product.template'

    cost_method = fields.selection(default='average')

But not works, and also try this:

class product_template(osv.osv):
    _inherit = 'product.template'

    _defaults = {
     'cost_method':'average'
}

But not works. The installation of my module is correct and I don't see any error, but the default cost method in the form of the product is "standard". How can I set it to "average"? Thanks!

Jose, have you checked it?

Akhil P Sivan
on 2/3/15, 11:19 PM
2

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/3/15, 12:51 AM

Hi Jose,

Try Like this:

class product_template(models.Model):
    _inherit = 'product.template'

    cost_method = fields.Selection( [('standard', 'Standard Price'),

                                                     ('average', 'Average Price'),

                                                       ('real', 'Real Price')], default='average')

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/30/15, 1:38 PM
Seen: 1078 times
Last updated: 7/20/16, 4:46 AM