[IMP]: sale: removed unwanted new field advance, improved code and usability

bzr revid: rpa@tinyerp.com-20120522094928-qjmqaiwthsvt4sy3
This commit is contained in:
Rucha (Open ERP) 2012-05-22 15:19:28 +05:30
parent db9f321b71
commit e4d2620631
2 changed files with 12 additions and 31 deletions

View File

@ -35,12 +35,10 @@ class sale_advance_payment_inv(osv.osv_memory):
return product_id
_columns = {
'product_id': fields.many2one('product.product', 'Advance Product', required=False,
help="Select a product of type service which is called 'Advance Product'. You may have to create it and set it as a default value on this field."),
'product_id': fields.many2one('product.product', 'Advance Product', help="Select a product of type service which is called 'Advance Product'. You may have to create it and set it as a default value on this field."),
'amount': fields.float('Advance Amount', digits=(16, 2), required=True, help="The amount to be invoiced in advance."),
'qtty': fields.float('Quantity', digits=(16, 2), required=True),
'advance_payment_method':fields.selection([('percentage','Percentage'), ('fixed','Fixed Price')], 'Pay Type', required=True),
'advance': fields.boolean('Advance'),
'advance_payment_method':fields.selection([('percentage','Percentage'), ('fixed','Fixed Price')], 'Type', required=True, help="Use Fixed Price if you want to give specific amound in Advance, Use Percentage if you want to give percentage of Total Invoice Amount."),
}
_defaults = {
@ -49,27 +47,15 @@ class sale_advance_payment_inv(osv.osv_memory):
'product_id': _default_product_id,
}
def onchange_advance_payment_method(self, cr, uid, ids, advance_payment_method,product_id, context=None):
if not product_id:
return {'value': {'amount': 0}}
def onchange_advance_payment_method(self, cr, uid, ids, advance_payment_method, product_id, context=None):
if advance_payment_method == 'percentage':
return {'value': {'amount':0,'product_id':False }}
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
return {'value': {'amount':product.list_price}}
else:
if not product_id:
return {'value': {'amount': 0}}
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
return {'value': {'amount': product.list_price}}
def onchange_advance_product(self, cr, uid, ids, product_id, context=None):
value = {}
value['advance'] = 'False'
if not product_id:
return {'value': {'amount': 0,'advance': False}}
product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
value['amount'] = product.list_price
try:
advance_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'advance_product_0')[1]
if product.id == advance_id:
value['advance'] = 'True'
finally:
return {'value': value}
def create_invoices(self, cr, uid, ids, context=None):
"""

View File

@ -7,16 +7,11 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Advance Invoice">
<group colspan="2">
<field name="product_id" on_change="onchange_advance_product(product_id)" context="{'search_default_services':1}" attrs="{'invisible': [('advance_payment_method','=','percentage')]}" />
</group>
<field name="advance_payment_method" on_change="onchange_advance_payment_method(advance_payment_method,product_id)"/>
<newline />
<group colspan="2" col="6">
<field name="qtty" invisible="1"/>
<field name="amount"/>
<field name="advance_payment_method" nolabel="1" attrs="{'readonly':[('advance','=','True')]}" on_change="onchange_advance_payment_method(advance_payment_method,product_id)"/>
<field name="advance" invisible="1"/>
</group>
<field name="qtty" invisible="1"/>
<field name="product_id" on_change="onchange_advance_payment_method(advance_payment_method,product_id)" context="{'search_default_services':1}" attrs="{'invisible': [('advance_payment_method','=','percentage')]}" colspan="2"/>
<field name="amount" colspan="2"/>
<newline />
<separator string="" colspan="4"/>
<label string="" colspan="6" />