diff --git a/addons/account/account.py b/addons/account/account.py index bfd5a05f48a..f0884044fcf 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -595,7 +595,7 @@ class account_journal(osv.osv): _columns = { 'name': fields.char('Journal Name', size=64, required=True, translate=True,help="Name of the journal"), 'code': fields.char('Code', size=16,required=True,help="Code of the journal"), - 'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'),('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, + 'type': fields.selection([('sale', 'Sale'),('sale_refund','Sale Refund'), ('purchase', 'Purchase'), ('purchase_refund','Purchase Refund'),('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank and Cheques'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, help="Select 'Sale' for Sale journal to be used at the time of making invoice."\ " Select 'Purchase' for Purchase Journal to be used at the time of approving purchase order."\ " Select 'Cash' to be used at the time of making payment."\ @@ -2624,13 +2624,13 @@ class wizard_multi_charts_accounts(osv.osv_memory): data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')]) data = data_pool.browse(cr, uid, data_id[0]) - ref_acc_bank = data.res_id + view_id_cur = data.res_id ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id current_num = 1 for line in obj_multi.bank_accounts_id: #create the account_account for this bank journal - tmp = self.pool.get('res.partner.bank').name_get(cr, uid, [line.acc_no.id])[0][1] + tmp = line.acc_name dig = obj_multi.code_digits if ref_acc_bank.code: try: @@ -2638,7 +2638,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): except Exception,e: new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)),'0')) + str(current_num) vals = { - 'name': line.acc_no.bank and line.acc_no.bank.name+' '+tmp or tmp, + 'name': tmp, 'currency_id': line.currency_id and line.currency_id.id or False, 'code': new_code, 'type': 'other', diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 270384a1d9f..c3809b44c04 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -368,16 +368,15 @@ class account_bank_statement(osv.osv): else: account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) - if st.journal_id.entry_posted: - account_move_obj.write(cr, uid, [move_id], {'state': 'posted'}) - self.log(cr, uid, st.id, 'Statement %s is confirmed and entries are created.' % st.name) done.append(st.id) next_number = obj_seq.get(cr, uid, 'account.bank.statement') if not st.name == '/': next_number = st.name + '/' + next_number[-1:] - account_move_obj.write(cr, uid, [move_id], {'state': 'posted', 'name': next_number}) + account_move_obj.write(cr, uid, [move_id], {'name': next_number}) + + account_move_obj.write(cr, uid, [move_id], {'state': 'posted'}) # Bank statements will not consider boolean on journal entry_posted self.write(cr, uid, [st.id], {'name': next_number}, context=context) self.write(cr, uid, done, {'state':'confirm'}, context=context) @@ -397,28 +396,15 @@ class account_bank_statement(osv.osv): return True def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None): - if not journal_id: - return {'value': {'currency': False}} - account_journal_obj = self.pool.get('account.journal') res_users_obj = self.pool.get('res.users') - res_currency_obj = self.pool.get('res.currency') - cursor.execute('SELECT balance_end_real \ FROM account_bank_statement \ - WHERE journal_id = %s \ - ORDER BY date DESC,id DESC LIMIT 1', (journal_id,)) + WHERE journal_id = %s AND NOT state = %s \ + ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft')) res = cursor.fetchone() balance_start = res and res[0] or 0.0 - - currency_id = account_journal_obj.browse(cursor, user, journal_id, - context=context).currency.id - if not currency_id: - currency_id = res_users_obj.browse(cursor, user, user, - context=context).company_id.currency_id.id - currency = res_currency_obj.name_get(cursor, user, [currency_id], - context=context)[0] - return {'value': {'balance_start': balance_start, 'currency': currency}} + return {'value': {'balance_start': balance_start}} def unlink(self, cr, uid, ids, context=None): stat = self.read(cr, uid, ids, ['state']) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 9df1880f61a..db70d5e0e5a 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -65,9 +65,8 @@ - - + @@ -501,7 +500,7 @@ - + diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index b89fbe86952..f28ebc76210 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -305,6 +305,7 @@ class account_move_line(osv.osv): ml = self.browse(cr, uid, id, context) return map(lambda x: x.id, ml.move_id.line_id) + # TODO: this is false, it does not uses draft and closed periods def _balance(self, cr, uid, ids, prop, unknow_none, unknow_dict): res={} # TODO group the foreach in sql @@ -344,9 +345,9 @@ class account_move_line(osv.osv): result = [] for line in self.browse(cr, uid, ids, context): if line.ref: - result.append((line.id, (line.name or '')+' ('+line.ref+')')) + result.append((line.id, (line.move_id.name or '')+' ('+line.ref+')')) else: - result.append((line.id, line.name)) + result.append((line.id, line.move_id.name)) return result def _balance_search(self, cursor, user, obj, name, args, domain=None, context=None): @@ -456,8 +457,8 @@ class account_move_line(osv.osv): type='many2one', relation='account.invoice', fnct_search=_invoice_search), 'account_tax_id':fields.many2one('account.tax', 'Tax'), 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'), -#TODO: remove this - 'amount_taxed':fields.float("Taxed Amount", digits_compute=dp.get_precision('Account')), + #TODO: remove this + #'amount_taxed':fields.float("Taxed Amount", digits_compute=dp.get_precision('Account')), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True) } @@ -864,7 +865,7 @@ class account_move_line(osv.osv): fields = {} flds = [] title = "Accounting Entries" #self.view_header_get(cr, uid, view_id, view_type, context) - xml = '''\n\n\t''' % (title) + xml = '''\n\n\t''' % (title) ids = journal_pool.search(cr, uid, []) journals = journal_pool.browse(cr, uid, ids) @@ -907,8 +908,8 @@ class account_move_line(osv.osv): if common_fields.get(field) == total: fields.get(field).append(None) - if field=='state': - state = 'colors="red:state==\'draft\'"' +# if field=='state': +# state = 'colors="red:state==\'draft\'"' attrs = [] if field == 'debit': diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 938de589eb8..a95b96aae9b 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -874,7 +874,7 @@ tree - + @@ -926,7 +926,7 @@ - + @@ -1775,7 +1775,7 @@ tree - + @@ -1818,9 +1818,9 @@ - + - + Create Account diff --git a/addons/account/i18n/da.po b/addons/account/i18n/da.po index 76d38294504..27244d23694 100644 --- a/addons/account/i18n/da.po +++ b/addons/account/i18n/da.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:52+0000\n" +"PO-Revision-Date: 2010-08-25 07:56+0000\n" "Last-Translator: OpenERP Administrators \n" "Language-Team: Danish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:38+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/de.po b/addons/account/i18n/de.po index fe08862e060..34c4d4fa398 100644 --- a/addons/account/i18n/de.po +++ b/addons/account/i18n/de.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:55+0000\n" +"PO-Revision-Date: 2010-08-25 08:04+0000\n" "Last-Translator: Ferdinand-chricar \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:38+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account @@ -5480,7 +5480,7 @@ msgstr "Berechne" #. module: account #: help:account.invoice.line,account_id:0 msgid "The income or expense account related to the selected product." -msgstr "Aufwand- und Ertragskonto des Produktes" +msgstr "Aufwand- und Erlöskonto des Produktes" #. module: account #: field:account.tax,type_tax_use:0 @@ -5798,7 +5798,7 @@ msgstr "5" #: field:product.category,property_account_income_categ:0 #: field:product.template,property_account_income:0 msgid "Income Account" -msgstr "Ertragskonto" +msgstr "Erlöskonto" #. module: account #: field:account.period,special:0 diff --git a/addons/account/i18n/hu.po b/addons/account/i18n/hu.po index 5ea91a0497a..f6a0e982119 100644 --- a/addons/account/i18n/hu.po +++ b/addons/account/i18n/hu.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:54+0000\n" +"PO-Revision-Date: 2010-08-25 07:58+0000\n" "Last-Translator: OpenERP Administrators \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:38+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/it.po b/addons/account/i18n/it.po index 5889f96db0d..6cc89aab9b8 100644 --- a/addons/account/i18n/it.po +++ b/addons/account/i18n/it.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:52+0000\n" +"PO-Revision-Date: 2010-08-25 07:55+0000\n" "Last-Translator: eLBati - albatos.com \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:39+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/lt.po b/addons/account/i18n/lt.po index b5ff247bcf9..c32d8a0abff 100644 --- a/addons/account/i18n/lt.po +++ b/addons/account/i18n/lt.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:49+0000\n" +"PO-Revision-Date: 2010-08-25 07:43+0000\n" "Last-Translator: Giedrius Slavinskas \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:39+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/pl.po b/addons/account/i18n/pl.po index 1166eed6059..0360a636c9d 100644 --- a/addons/account/i18n/pl.po +++ b/addons/account/i18n/pl.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:49+0000\n" +"PO-Revision-Date: 2010-08-25 07:44+0000\n" "Last-Translator: OpenERP Administrators \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:39+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/sq.po b/addons/account/i18n/sq.po index 73dc1c70f42..d92c139d1fd 100644 --- a/addons/account/i18n/sq.po +++ b/addons/account/i18n/sq.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-addons\n" "Report-Msgid-Bugs-To: ASTRIT BOKSHI \n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:34+0000\n" +"PO-Revision-Date: 2010-08-25 07:19+0000\n" "Last-Translator: bokshas \n" "Language-Team: Albanian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:38+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:55+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/sv.po b/addons/account/i18n/sv.po index aab56027f36..25d42c77ba0 100644 --- a/addons/account/i18n/sv.po +++ b/addons/account/i18n/sv.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:53+0000\n" +"PO-Revision-Date: 2010-08-25 07:58+0000\n" "Last-Translator: OpenERP Administrators \n" "Language-Team: <> <>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:39+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:56+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/tr.po b/addons/account/i18n/tr.po index 9e2a6029f1a..480a019a8ca 100644 --- a/addons/account/i18n/tr.po +++ b/addons/account/i18n/tr.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:48+0000\n" +"PO-Revision-Date: 2010-08-25 07:43+0000\n" "Last-Translator: Omer Barlas \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:39+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:56+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/i18n/zh_CN.po b/addons/account/i18n/zh_CN.po index a5a7f0f5388..1c718ffeaac 100644 --- a/addons/account/i18n/zh_CN.po +++ b/addons/account/i18n/zh_CN.po @@ -7,13 +7,13 @@ msgstr "" "Project-Id-Version: OpenERP Server 6.0dev\n" "Report-Msgid-Bugs-To: support@openerp.com\n" "POT-Creation-Date: 2009-08-28 16:01+0000\n" -"PO-Revision-Date: 2010-08-23 06:39+0000\n" +"PO-Revision-Date: 2010-08-25 07:28+0000\n" "Last-Translator: Jeff Wang \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2010-08-24 03:39+0000\n" +"X-Launchpad-Export-Date: 2010-08-26 03:56+0000\n" "X-Generator: Launchpad (build Unknown)\n" #. module: account diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 0245acaa25d..e7b95cea8dc 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -874,7 +874,7 @@ class account_invoice(osv.osv): line = self.group_lines(cr, uid, iml, line, inv) - journal_id = inv.journal_id.id + journal_id = inv.journal_id.id journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.centralisation: raise osv.except_osv(_('UserError'), @@ -1496,12 +1496,18 @@ class account_invoice_tax(osv.osv): def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') - company_currency=False + company_currency = False + tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] + tax_sign=1 + if tax_amount < 0: + tax_sign = -1 + elif tax_amount == 0: + tax_sign = 0 if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: - amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) - return {'value': {'tax_amount':amount}} + amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) + return {'value': {'tax_amount': amount}} _order = 'sequence' _defaults = { diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index f3a8cca8ada..7f3c344ebff 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -130,8 +130,8 @@ diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index b241b725673..d017a6cbc11 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -156,10 +156,9 @@ diff --git a/addons/account/test/account_customer_invoice.yml b/addons/account/test/account_customer_invoice.yml index e5920d0caed..f8798d7d9e3 100644 --- a/addons/account/test/account_customer_invoice.yml +++ b/addons/account/test/account_customer_invoice.yml @@ -47,7 +47,7 @@ - !assert {model: account.invoice, id: account_invoice_customer0}: - state == 'open' - + - I check that now there is a move attached to the invoice - @@ -126,7 +126,7 @@ acc_id=self.browse(cr, uid, ref("account_invoice_customer0")) assert(acc_id.move_id) - - I refund the invoice Using Credit Note + I refund the invoice Using Refund Button - !record {model: account.invoice.refund, id: account_invoice_refund_0}: description: Refund To China Export diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index aa6b477d30d..9355691369e 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -33,10 +33,11 @@ class account_change_currency(osv.osv_memory): obj_inv = self.pool.get('account.invoice') if context is None: context = {} - state = obj_inv.browse(cr, uid, context['active_id']).state - if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': - raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) - pass + if context.get('active_id',False): + state = obj_inv.browse(cr, uid, context['active_id']).state + if obj_inv.browse(cr, uid, context['active_id']).state != 'draft': + raise osv.except_osv(_('Error'), _('You can only change currency for Draft Invoice !')) + pass def change_currency(self, cr, uid, ids, context=None): obj_inv = self.pool.get('account.invoice') diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index e6fc938b2ac..fb575509184 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -36,6 +36,7 @@ class account_invoice_refund(osv.osv_memory): 'period': fields.many2one('account.period', 'Force period'), 'journal_id': fields.many2one('account.journal', 'Refund Journal', help='You can select here the journal to use for the refund invoice that will be created. If you leave that field empty, it will use the same journal as the current invoice.'), 'description': fields.char('Description', size=128, required=True), + 'filter_refund': fields.selection([('modify', 'Modify'), ('refund', 'Refund'), ('cancel', 'Cancel')], "Refund Type", required=True, help='Refund invoice base on this type. You can not Modify and Cancel if the invoice is already rencociled'), } def _get_journal(self, cr, uid, context=None): @@ -50,7 +51,8 @@ class account_invoice_refund(osv.osv_memory): _defaults = { 'date': time.strftime('%Y-%m-%d'), - 'journal_id': _get_journal + 'journal_id': _get_journal, + 'filter_refund': 'modify', } def compute_refund(self, cr, uid, ids, mode='refund', context=None): @@ -66,6 +68,8 @@ class account_invoice_refund(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') wf_service = netsvc.LocalService('workflow') + inv_tax_obj = self.pool.get('account.invoice.tax') + inv_line_obj = self.pool.get('account.invoice.line') if context is None: context = {} @@ -76,15 +80,19 @@ class account_invoice_refund(osv.osv_memory): period = False description = False company = self.pool.get('res.users').browse(cr, uid, uid).company_id + journal_id = form.get('journal_id', False) for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context): if inv.state in ['draft', 'proforma2', 'cancel']: raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode)) + if inv.reconciled and mode in ('cancel', 'modify'): + raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode)) if form['period'] : period = form['period'] else: period = inv.period_id and inv.period_id.id or False - journal_id = form.get('journal_id', False) + if not journal_id: + journal_id = inv.journal_id.id if form['date'] : date = form['date'] @@ -153,10 +161,9 @@ class account_invoice_refund(osv.osv_memory): 'journal_id', 'period_id'], context=context) invoice = invoice[0] del invoice['id'] - invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'], context=context) + invoice_lines = inv_line_obj.read(cr, uid, invoice['invoice_line'], context=context) invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines) - tax_lines = self.pool.get('account.invoice.tax').read( - cr, uid, invoice['tax_line'], context=context) + tax_lines = inv_tax_obj.read(cr, uid, invoice['tax_line'], context=context) tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines) invoice.update({ @@ -196,14 +203,9 @@ class account_invoice_refund(osv.osv_memory): return result def invoice_refund(self, cr, uid, ids, context=None): - return self.compute_refund(cr, uid, ids, 'refund', context=context) - - def invoice_cancel(self, cr, uid, ids, context=None): - return self.compute_refund(cr, uid, ids, 'cancel', context=context) - - def invoice_modify(self, cr, uid, ids, context=None): - return self.compute_refund(cr, uid, ids, 'modify', context=context) + data_refund = self.read(cr, uid, ids, [] ,context=context)[0]['filter_refund'] + return self.compute_refund(cr, uid, ids, data_refund, context=context) account_invoice_refund() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account/wizard/account_invoice_refund_view.xml b/addons/account/wizard/account_invoice_refund_view.xml index 8ee56eacf61..e26eb4e12c9 100644 --- a/addons/account/wizard/account_invoice_refund_view.xml +++ b/addons/account/wizard/account_invoice_refund_view.xml @@ -14,19 +14,18 @@ + -