跳至内容
菜单
此问题已终结

Hi, i did a new custom module. in my module, i want to calculate revenue from minimum order quantity (moq) and product price; and i want to store the revenue result in a field.

here is my module codes..

__init__.py

import sample

__openerp__.py

{
    'name': 'Testing Purpose',
    'version': '1000.000',
    'author': 'Jothimani.R',
    'category': 'Testing',
    'depends': ['base','product'],
    'demo': ['sample_view.xml'],
    'data': ['sample_view.xml'],
    'test': ['sample_view.xml'],
    'installable': True,
    'auto_install': False,

}

sample.py

from openerp.osv import osv, fields

class sample_work(osv.osv):
    _name = "testing_purpose"
    _description = "Testing Purpose"

    def onchange_price(self,cr,uid,ids,number,pro_price,context=None):
        price1 = number*pro_price

        return {'value':{'price_total': price1}} 


    _columns = {
             'product':fields.many2one('product.product','Product', required=True),             
             'number':fields.integer('MOQ', size=3),
             'price_total':fields.float('Price'),
             'pro_price': fields.related('product', 'list_price', type="many2one", relation="product.product", string="Product price", store=False)
             }
sample_work()

sample_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <record id="sample_form_view" model="ir.ui.view">
    <field name="name">sample.form_view</field>
    <field name="model">testing_purpose</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
        <form string="Testiing purpose form view">
            <field name="product"/> 
            <field name="number" on_change="onchange_price(number)"/>
            <field name="price_total"/>                         
            <!--<field name="pro_price"/>-->                
        </form>
    </field>
    </record>

    <record id="sample_tree_view" model="ir.ui.view">
    <field name="name">sample.tree_view</field>
    <field name="model">testing_purpose</field>
    <field name="type">tree</field>
    <field name="arch" type="xml">
        <tree string="Testiing purpose tree view">
            <field name="number" on_change="onchange_price(number)"/>
            <field name="price_total"/>
            <field name="product"/>     
            <!--<field name="pro_price"/>-->                            
        </tree>
    </field>
    </record>

    <record id="test-purpose" model="ir.actions.act_window">
        <field name="name">Testing Purpo</field>
        <field name="res_model">testing_purpose</field>
        <field name="view_type">form</field>
        <field name="view_mode">list,form</field>
    </record>

    <menuitem
    id="parent_menu"
    name="Testing"
    sequence="1"/>

    <menuitem
    id="sub_menu"
    name="Operations"
    parent="parent_menu"/>

    <menuitem
    action="test-purpose"
    id="sub2_menu"
    name="Sample_Purpose"
    parent="sub_menu"/> 


</data></openerp>

hi, please anyone help me........

形象
丢弃
相关帖文 回复 查看 活动
0
10月 23
1201
0
10月 20
2992
1
8月 16
4015
3
2月 25
35264
0
9月 24
691