Purnendu Singh (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-refund_improvement into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-refund_improvement/+merge/112108
Hello,
Improve the refund logic so it will support partial payment now.
Thanks,
Purnendu Singh
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-refund_improvement/+merge/112108
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-refund_improvement.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2012-06-01 12:15:47 +0000
+++ account/account_invoice.py 2012-06-26 13:24:25 +0000
@@ -295,6 +295,7 @@
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
journal_obj = self.pool.get('account.journal')
+ user_obj = self.pool.get('res.users')
if context is None:
context = {}
@@ -317,6 +318,12 @@
if field == 'journal_id' and type:
journal_select = journal_obj._name_search(cr, uid, '', [('type', '=', type)], context=context, limit=None, name_get_uid=1)
res['fields'][field]['selection'] = journal_select
+ if field == 'account_id' and type:
+ company_id = user_obj.browse(cr, uid, uid, context=context).company_id.id
+ if type in ('sale', 'purchase_refund'):
+ res['fields'][field]['domain'] = [('company_id', '=', company_id), ('type', '=', 'receivable')]
+ elif type in ('sale_refund', 'purchase'):
+ res['fields'][field]['domain'] = [('company_id', '=', company_id), ('type', '=', 'payable')]
doc = etree.XML(res['arch'])
@@ -466,7 +473,9 @@
p.property_account_receivable = rec_obj_acc[0]
p.property_account_payable = pay_obj_acc[0]
- if type in ('out_invoice', 'out_refund'):
+ #Setting Receivable account in case of customer invoice and supplier refund
+ #and payable account in case of supplier invoice and customer refund
+ if type in ('out_invoice', 'in_refund'):
acc_id = p.property_account_receivable.id
else:
acc_id = p.property_account_payable.id
@@ -1131,6 +1140,7 @@
obj_invoice_line = self.pool.get('account.invoice.line')
obj_invoice_tax = self.pool.get('account.invoice.tax')
obj_journal = self.pool.get('account.journal')
+ obj_partner = self.pool.get('res.partner')
new_ids = []
for invoice in invoices:
del invoice['id']
@@ -1157,6 +1167,13 @@
if not date:
date = time.strftime('%Y-%m-%d')
+ partner = obj_partner.browse(cr, uid, invoice['partner_id'][0])
+ #As this is refund setting payable account in case of customer invoice and supplier refund
+ #and receivable account in case of supplier invoice and customer refund
+ if invoice['type'] in ('out_invoice', 'in_refund'):
+ invoice['account_id'] = partner.property_account_payable.id
+ else:
+ invoice['account_id'] = partner.property_account_receivable.id
invoice.update({
'type': type_dict[invoice['type']],
'date_invoice': date,
@@ -1176,7 +1193,7 @@
})
# take the id part of the tuple returned for many2one fields
for field in ('partner_id',
- 'account_id', 'currency_id', 'payment_term', 'journal_id'):
+ 'currency_id', 'payment_term', 'journal_id'):
invoice[field] = invoice[field] and invoice[field][0]
# create the new invoice
new_ids.append(self.create(cr, uid, invoice))
=== modified file 'account/account_invoice_view.xml'
--- account/account_invoice_view.xml 2012-06-22 05:52:30 +0000
+++ account/account_invoice_view.xml 2012-06-26 13:24:25 +0000
@@ -171,8 +171,7 @@
groups="account.group_account_user" widget="selection"/>
<field name="journal_id" on_change="onchange_journal_id(journal_id)" widget="selection"
groups="account.group_account_user"/>
- <field domain="[('company_id', '=', company_id), ('type', '=', 'payable')]"
- name="account_id" groups="account.group_account_user"/>
+ <field name="account_id" groups="account.group_account_user"/>
<field name="currency_id"/>
<field name="type" invisible="1"/>
</group>
@@ -316,8 +315,7 @@
<field name="journal_id" groups="account.group_account_user"
on_change="onchange_journal_id(journal_id, context)" widget="selection"/>
- <field domain="[('company_id', '=', company_id),('type','=', 'receivable')]"
- name="account_id" groups="account.group_account_user"/>
+ <field name="account_id" groups="account.group_account_user"/>
<label for="currency_id"/>
<div>
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2012-05-23 06:53:42 +0000
+++ account_voucher/account_voucher.py 2012-06-26 13:24:25 +0000
@@ -162,7 +162,9 @@
if view_type == 'form':
if not view_id and context.get('invoice_type'):
- if context.get('invoice_type') in ('out_invoice', 'out_refund'):
+ #Called supplier payment form while payment the customer refund invoice and
+ #Customer payment form while payment supplier refund invoice
+ if context.get('invoice_type') in ('out_invoice', 'in_refund'):
result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
else:
result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
=== modified file 'account_voucher/invoice.py'
--- account_voucher/invoice.py 2012-02-29 06:47:05 +0000
+++ account_voucher/invoice.py 2012-06-26 13:24:25 +0000
@@ -28,8 +28,17 @@
def invoice_pay_customer(self, cr, uid, ids, context=None):
if not ids: return []
inv = self.browse(cr, uid, ids[0], context=context)
+ name = _("Pay Invoice")
+ if inv.type == 'out_invoice':
+ name = _("Customer Payment")
+ elif inv.type == 'in_invoice':
+ name = _("Supplier Payment")
+ elif inv.type == 'out_refund':
+ name = _("Customer Refund Payment")
+ else:
+ name = _("Supplier Refund Payment")
return {
- 'name':_("Pay Invoice"),
+ 'name': name,
'view_mode': 'form',
'view_id': False,
'view_type': 'form',
@@ -45,9 +54,9 @@
'close_after_process': True,
'invoice_type':inv.type,
'invoice_id':inv.id,
- 'default_type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment',
- 'type': inv.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
- }
+ 'default_type': inv.type in ('out_invoice','in_refund') and 'receipt' or 'payment',
+ 'type': inv.type in ('out_invoice','in_refund') and 'receipt' or 'payment'
+ }
}
invoice()
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp