[IMP] point_of_sale: Improved Make Payment wizard.

bzr revid: uco@tinyerp.com-20100911112909-itekdx4wfhima9q9
This commit is contained in:
uco (Open ERP)
2010-09-11 16:59:09 +05:30
parent e391a8c343
commit bbb57fe006
5 changed files with 25 additions and 8 deletions
+2 -2
View File
@@ -585,7 +585,7 @@ class pos_order(osv.osv):
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
if data.get('is_acc',False):
args['is_acc']=data['is_acc']
args['is_acc'] = data['is_acc']
args['account_id']= prod_obj.browse(cr,uid, data['product_id']).property_account_income and prod_obj.browse(cr,uid, data['product_id']).property_account_income.id
if not args['account_id']:
raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')%(prod_obj.browse(cr,uid, data['product_id']).name))
@@ -635,7 +635,7 @@ class pos_order(osv.osv):
wf_service = netsvc.LocalService("workflow")
wf_service.trg_write(uid, 'pos.order', order_id, cr)
return order_line_id
return order_line_id, price
def refund(self, cr, uid, ids, context=None):
"""Create a copy of order for refund order"""
@@ -17,7 +17,7 @@
<group colspan="4" col="2">
<button icon='gtk-cancel' special="cancel"
string="Close" />
<button name="get_in" string="Take Money"
<button name="get_in" string="Put Money"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
+1 -1
View File
@@ -17,7 +17,7 @@
<group colspan="4" col="2">
<button icon='gtk-cancel' special="cancel"
string="Close" />
<button name="get_out" string="Put Money"
<button name="get_out" string="Take Money"
colspan="1" type="object" icon="gtk-ok" />
</group>
</form>
+18 -2
View File
@@ -127,6 +127,18 @@ class pos_make_payment(osv.osv_memory):
"""
return result
def onchange_product_id(self, cr, uid, ids, product_id, amount):
""" Changes amount if product_id changes.
@param product_id: Changed product_id
@param amount: Amount to be paid
@return: Dictionary of changed values
"""
prod_obj = self.pool.get('product.product')
if product_id:
product = prod_obj.browse(cr, uid, product_id)
amount = amount + product.list_price
return {'value': {'amount': amount}}
def check(self, cr, uid, ids, context):
"""Check the order:
@@ -139,8 +151,12 @@ class pos_make_payment(osv.osv_memory):
amount = order.amount_total - order.amount_paid
data = self.read(cr, uid, ids)[0]
invoice_wanted = data['invoice_wanted']
is_accompte = data['is_acc']
# Todo need to check ...
if is_accompte:
line_id, price = order_obj.add_product(cr, uid, order.id, data['product_id'], 1.0, context)
amount = order.amount_total - order.amount_paid + price
if amount != 0.0:
order_obj.write(cr, uid, [active_id], {'invoice_wanted': invoice_wanted, 'partner_id': data['partner_id']})
order_obj.add_payment(cr, uid, active_id, data, context=context)
@@ -209,7 +225,7 @@ class pos_make_payment(osv.osv_memory):
_columns = {
'journal':fields.selection(pos_box_entries.get_journal, "Cash Register",required=True),
'product_id': fields.many2one('product.product', "Acompte"),
'product_id': fields.many2one('product.product', "Accompte"),
'amount':fields.float('Amount', digits=(16,2) ,required= True),
'payment_name': fields.char('Payment name', size=32, required=True),
'payment_date': fields.date('Payment date', required=True),
+3 -2
View File
@@ -19,9 +19,10 @@
<!--field name="payment_name" /-->
<field name="invoice_wanted" />
<field name="num_sale" />
<field name="is_acc" />
<field name="is_acc"/>
<group attrs="{'invisible':[('is_acc','=',False)]}" colspan="4" col="2">
<field name="product_id" attrs="{'required':[('is_acc', '=', True)]}" domain="[('type','=','service')]"/>
<field name="product_id" attrs="{'required':[('is_acc', '=', True)]}" domain="[('type','=','service')]"
on_change="onchange_product_id(product_id, amount)"/>
</group>
<newline/>
<group attrs="{'invisible':[('invoice_wanted','=',False)]}" colspan="4">