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

Extending a module to set new defaults values. How to get started ?

By
Christian Parent
on 4/12/14, 6:01 PM 1,766 views

In the module product, there is a 'type' field that has 2 options, consu or service. By default, it is set to consu.

/addons/product/product.py

_defaults = {
    'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'product.template', context=c),
    'list_price': 1,
    'cost_method': 'standard',
    'standard_price': 0.0,
    'sale_ok': 1,
    'produce_delay': 1,
    'uom_id': _get_uom_id,
    'uom_po_id': _get_uom_id,
    'uos_coeff' : 1.0,
    'mes_type' : 'fixed',
    'categ_id' : _default_category,
    'type' : 'consu',
}

The module produce.py extend this to add the value product to the type field.

/addons/product/procurement.py

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

_columns = {
    'type': fields.selection([('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help="Consumable: Will not imply stock management for this $
    'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Procurement Method', required=True, help="Make to Stock: When needed, the product is take$
    'supply_method': fields.selection([('produce','Manufacture'),('buy','Buy')], 'Supply Method', required=True, help="Manufacture: When procuring the product, a manufacturing order or a task will be $
}

I simply need to change the default to product.

I know that I could probably hard code it in procurement.py under

_defaults = {
    'type' : 'product',

}

But, I also know that by doing so, each time the procurement.py will be updated, I will lose the change and will need to do it again.

Thus why I would like a tutorial (or example here) of how to create a module to extend procurement.

OpenERP is gainig a lot of ground, I am a hobbyist, doing this to help peeps and at no charge. I am a promoter of open source solutions. The only thing that is missing for help the community grow to where it could really be is a central point for all the learning resources like, A "Learn module creation for OpenERP with these teaching code examples" .

Something that explain module directory structure, __init.py__ etc... code that each lines are comment to explain why I do this like:

import soandso <--- needed to acces _defaults to modify it _inherit <--- needed for this and that

etc. As you see, it should be small modules that easy stuff 1 or 2 maybe, if there are other things that could fit in it, just need to modify it and explain properly what this line(s) does !

Thanx for the help !

0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 4/12/14, 6:52 PM

You can start here and here

A good practical tutorials from Tony Galmiche

OpenERP 7 technical memento v0.7.4

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

0 follower(s)

Stats

Asked: 4/12/14, 6:01 PM
Seen: 1766 times
Last updated: 3/16/15, 8:10 AM