diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index ed250f0aaf0..3dff856b716 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -37,7 +37,7 @@ "category" : "Generic Modules/Accounting", "website" : "http://tinyerp.com", "depends" : [ - "base", + "base", "account" ], "init_xml" : [ @@ -54,8 +54,12 @@ "voucher_view.xml", "voucher_wizard.xml", "wizard/account_voucher_open_view.xml", - + ], + "test" : [ + "test/account_voucher.yml", + ], + 'certificate': '0037580727101', "active": False, "installable": True, diff --git a/addons/account_voucher/test/account_voucher.yml b/addons/account_voucher/test/account_voucher.yml new file mode 100644 index 00000000000..a49222c3b96 --- /dev/null +++ b/addons/account_voucher/test/account_voucher.yml @@ -0,0 +1,116 @@ + +- + In order to check account voucher module in OpenERP I create a customer voucher +- + !record {model: account.voucher, id: account_voucher_voucherforaxelor0}: + account_id: account.cash + company_id: base.main_company + currency_id: base.EUR + journal_id: account.bank_journal + name: Voucher for Axelor + narration: Basic Pc + payment_ids: + - account_id: account.a_recv + amount: 1000.0 + name: Voucher for Axelor + partner_id: base.res_partner_desertic_hispafuentes + period_id: account.period_6 + reference_type: none + +- + I check that Initially customer voucher is in the "Draft" state +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}: + - state == 'draft' +- + I change the state of voucher to "proforma" by clicking PRO-FORMA button +- + !workflow {model: account.voucher, action: open_voucher, ref: account_voucher_voucherforaxelor0} +- + I check that the voucher state is now "proforma" +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}: + - state == 'proforma' +- + I create voucher by clicking on Create button +- + !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor0} +- + I check that the voucher state is "Waiting for re-checking" +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}: + - state == 'recheck' +- + I clicked on Validate Button +- + !workflow {model: account.voucher, action: recheck_voucher, ref: account_voucher_voucherforaxelor0} +- + I check that the voucher state is "posted" +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor0}: + - state == 'posted' + +- + I check that Moves get created for this voucher +- + !python {model: account.voucher}: | + acc_id=self.browse(cr, uid, ref("account_voucher_voucherforaxelor0")) + assert(acc_id.move_id) + + +- + Now I create a Vendor Voucher +- + !record {model: account.voucher, id: account_voucher_voucheraxelor0}: + account_id: account.cash + company_id: base.main_company + currency_id: base.EUR + journal_id: account.bank_journal + name: Voucher Axelor + narration: Basic PC + payment_ids: + - account_id: account.cash + amount: 1000.0 + name: Voucher Axelor + period_id: account.period_6 + reference_type: none + +- + I check that Initially vendor voucher is in the "Draft" state +- + !assert {model: account.voucher, id: account_voucher_voucheraxelor0}: + - state == 'draft' +- + I change the state of voucher to "proforma" by clicking PRO-FORMA button +- + !workflow {model: account.voucher, action: open_voucher, ref: account_voucher_voucheraxelor0} +- + I check that the voucher state is now "proforma" +- + !assert {model: account.voucher, id: account_voucher_voucheraxelor0}: + - state == 'proforma' +- + I create voucher by clicking on Create button +- + !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucheraxelor0} +- + I check that the voucher state is "Waiting for re-checking" +- + !assert {model: account.voucher, id: account_voucher_voucheraxelor0}: + - state == 'recheck' +- + I clicked on Validate Button +- + !workflow {model: account.voucher, action: recheck_voucher, ref: account_voucher_voucheraxelor0} +- + I check that the voucher state is "posted" +- + !assert {model: account.voucher, id: account_voucher_voucheraxelor0}: + - state == 'posted' + +- + I check that moves get created for this voucher +- + !python {model: account.voucher}: | + acc_id=self.browse(cr, uid, ref("account_voucher_voucheraxelor0")) + assert(acc_id.move_id) diff --git a/addons/account_voucher_payment/__terp__.py b/addons/account_voucher_payment/__openerp__.py similarity index 92% rename from addons/account_voucher_payment/__terp__.py rename to addons/account_voucher_payment/__openerp__.py index 83864a543be..fa1b37399f6 100755 --- a/addons/account_voucher_payment/__terp__.py +++ b/addons/account_voucher_payment/__openerp__.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## { @@ -23,24 +23,29 @@ "version" : "1.0", "author" : 'Tiny & Axelor', "description": """This module includes : - * It reconcile the invoice (supplier, customer) while paying through + * It reconcile the invoice (supplier, customer) while paying through Accounting Vouchers """, "category" : "Generic Modules/Indian Accounting", "website" : "http://tinyerpindia.com", "depends" : [ - "base", + "base", "account", "account_voucher", ], "init_xml" : [ ], - + "demo_xml" : [], "update_xml" : [ "account_voucher_payment_view.xml", "account_voucher_payment_wizard.xml" ], + "test" : [ +# "test/account_voucher.yml", + "test/account_voucher_payment.yml", + ], + "active": False, "installable": True, } diff --git a/addons/account_voucher_payment/account_voucher_payment.py b/addons/account_voucher_payment/account_voucher_payment.py index 1cd1da98208..bf03c90c522 100755 --- a/addons/account_voucher_payment/account_voucher_payment.py +++ b/addons/account_voucher_payment/account_voucher_payment.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -35,9 +35,9 @@ class account_voucher(osv.osv): _columns = { 'voucher_line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}), } - + def action_move_line_create(self, cr, uid, ids, *args): - + for inv in self.browse(cr, uid, ids): if inv.move_id: continue @@ -55,12 +55,12 @@ class account_voucher(osv.osv): ref = inv.reference else: ref = self._convert_ref(cr, uid, inv.number) - + date = inv.date total_currency = 0 for i in iml: partner_id=i['partner_id'] - acc_id = i['account_id'] + acc_id = i['account_id'] if inv.currency_id.id != company_currency: i['currency_id'] = inv.currency_id.id i['amount_currency'] = i['amount'] @@ -97,19 +97,19 @@ class account_voucher(osv.osv): line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x,date, context={})) ,iml) an_journal_id=inv.journal_id.analytic_journal_id.id journal_id = inv.journal_id.id - + journal = self.pool.get('account.journal').browse(cr, uid, journal_id) if journal.sequence_id: name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id) move = { - 'name': name, - 'journal_id': journal_id, + 'name': name, + 'journal_id': journal_id, 'voucher_type':inv.type, 'narration' : inv.narration, 'data':date } - + if inv.period_id: move['period_id'] = inv.period_id.id for i in line: @@ -128,7 +128,7 @@ class account_voucher(osv.osv): 'journal_id':journal_id , 'period_id':inv.period_id.id, 'partner_id': False, - 'ref': ref, + 'ref': ref, 'date': date } if inv.type in ('rec_voucher', 'bank_rec_voucher', 'journal_pur_voucher', 'journal_voucher'): @@ -144,15 +144,15 @@ class account_voucher(osv.osv): 'voucher_invoice' : iml and iml[0]['invoice'] and iml[0]['invoice'].id or False, 'debit':False, 'credit':False, - 'move_id':move_id, + 'move_id':move_id, 'account_id':line.account_id.id or False, 'journal_id':journal_id , 'period_id':inv.period_id.id, 'partner_id':line.partner_id.id or False, - 'ref':ref, + 'ref':ref, 'date':date } - + if line.type == 'dr': move_line['debit'] = line.amount or False amount=line.amount @@ -161,7 +161,7 @@ class account_voucher(osv.osv): amount=line.amount * (-1) ml_id=self.pool.get('account.move.line').create(cr, uid, move_line) id_mapping_dict[line.id] = ml_id - + total = 0.0 mline = self.pool.get('account.move.line') if line.invoice_id.id: @@ -180,7 +180,7 @@ class account_voucher(osv.osv): line.name=inv.narration else: line.name=line.name - + if line.account_analytic_id: an_line = { 'name':line.name, @@ -197,22 +197,22 @@ class account_voucher(osv.osv): self.pool.get('account.move.line').reconcile_partial(cr, uid, mline_ids, 'manual', context={}) self.write(cr, uid, [inv.id], {'move_id': move_id}) obj=self.pool.get('account.move').browse(cr, uid, move_id) - + for line in obj.line_id : cr.execute('insert into voucher_id (account_id,rel_account_move) values (%d, %d)',(int(ids[0]),int(line.id))) - + return True account_voucher() class account_voucher_line(osv.osv): _inherit = 'account.voucher.line' - + def default_get(self, cr, uid, fields, context={}): data = super(account_voucher_line, self).default_get(cr, uid, fields, context) self.voucher_context = context return data - + _columns = { 'invoice_id' : fields.many2one('account.invoice','Invoice'), } @@ -220,8 +220,8 @@ class account_voucher_line(osv.osv): def move_line_get_item(self, cr, uid, line, context={}): res = super(account_voucher_line, self).move_line_get_item(cr, uid, line, context) res['invoice'] = line.invoice_id or False - return res - + return res + def onchange_invoice_id(self, cr, uid, ids, invoice_id, context={}): lines = [] if 'lines' in self.voucher_context: @@ -233,27 +233,27 @@ class account_voucher_line(osv.osv): residual = invoice_obj.residual same_invoice_amounts = [x['amount'] for x in lines if x['invoice_id']==invoice_id] residual -= sum(same_invoice_amounts) - return {'value' : {'amount':residual}} - + return {'value' : {'amount':residual}} + def onchange_line_account(self, cr, uid, ids, account_id, type, type1): if not account_id: return {'value' : {'account_id' : False, 'type' : False ,'amount':False}} obj = self.pool.get('account.account') acc_id = False - + if type1 in ('rec_voucher','bank_rec_voucher', 'journal_voucher'): acc_id = obj.browse(cr, uid, account_id) balance = acc_id.credit type = 'cr' - elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') : + elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.debit type = 'dr' - elif type1 in ('journal_sale_vou') : + elif type1 in ('journal_sale_vou') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.credit type = 'dr' - elif type1 in ('journal_pur_voucher') : + elif type1 in ('journal_pur_voucher') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.debit type = 'cr' @@ -265,7 +265,7 @@ account_voucher_line() class account_invoice(osv.osv): _inherit = "account.invoice" - + def action_cancel(self, cr, uid, ids, *args): res = super(account_invoice, self).action_cancel(cr, uid, ids, *args) invoices = self.read(cr, uid, ids, ['move_id']) @@ -276,7 +276,7 @@ class account_invoice(osv.osv): move_ids = move_db.search(cr, uid, []) move_obj = move_db.browse(cr, uid, move_ids) return res - + account_invoice() diff --git a/addons/account_voucher_payment/account_voucher_unreconcile.py b/addons/account_voucher_payment/account_voucher_unreconcile.py index a209fe13ba0..f36af98dc1c 100644 --- a/addons/account_voucher_payment/account_voucher_unreconcile.py +++ b/addons/account_voucher_payment/account_voucher_unreconcile.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -32,11 +32,11 @@ _info_form = ''' def _trans_unrec(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) voucher = pool.get('account.voucher').browse(cr, uid, data.get('id')) - recs = None + recs = [] for line in voucher.move_ids: if line.reconcile_id: recs = [line.reconcile_id.id] - + for rec in recs: pool.get('account.move.reconcile').unlink(cr, uid, rec) return {} diff --git a/addons/account_voucher_payment/test/account_voucher_payment.yml b/addons/account_voucher_payment/test/account_voucher_payment.yml new file mode 100644 index 00000000000..8bcea6a23a4 --- /dev/null +++ b/addons/account_voucher_payment/test/account_voucher_payment.yml @@ -0,0 +1,118 @@ +- + In order to test account_voucher_payment module in OpenERP I create an invoice and paid it through voucher +- + I create a customer invoice record +- + !record {model: account.invoice, id: account_invoice_voucher_payment}: + account_id: account.a_recv + address_contact_id: base.res_partner_address_3000 + address_invoice_id: base.res_partner_address_3000 + company_id: base.main_company + currency_id: base.EUR + invoice_line: + - account_id: account.a_sale + name: '[PC1] Basic PC' + price_unit: 450.0 + quantity: 1.0 + product_id: product.product_product_pc1 + uos_id: product.product_uom_unit + journal_id: account.sales_journal + partner_id: base.res_partner_desertic_hispafuentes + reference_type: none + +- + I check that Initially customer invoice is in the "Draft" state +- + !assert {model: account.invoice, id: account_invoice_voucher_payment}: + - state == 'draft' +- + I change the state of invoice to "Proforma2" by clicking PRO-FORMA button +- + !workflow {model: account.invoice, action: invoice_proforma2, ref: account_invoice_voucher_payment} +- + I check that the invoice state is now "Proforma2" +- + !assert {model: account.invoice, id: account_invoice_voucher_payment}: + - state == 'proforma2' +- + I create invoice by clicking on Create button +- + !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_voucher_payment} +- + I check that the invoice state is "Open" +- + !assert {model: account.invoice, id: account_invoice_voucher_payment}: + - state == 'open' + +- + I create a voucher record for above invoice +- + !record {model: account.voucher, id: account_voucher_voucherforaxelor1}: + account_id: account.cash + company_id: base.main_company + currency_id: base.EUR + journal_id: account.bank_journal + name: Voucher for Axelor + narration: Basic Pc + payment_ids: + - account_id: account.a_recv + amount: 450.0 + name: Voucher for Axelor + partner_id: base.res_partner_desertic_hispafuentes + invoice_id: account_invoice_voucher_payment + type: cr + period_id: account.period_6 + reference_type: none + +- + I check that Initially customer voucher is in the "Draft" state +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor1}: + - state == 'draft' +- + I change the state of voucher to "proforma" by clicking PRO-FORMA button +- + !workflow {model: account.voucher, action: open_voucher, ref: account_voucher_voucherforaxelor1} +- + I check that the voucher state is now "proforma" +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor1}: + - state == 'proforma' +- + I create voucher by clicking on Create button +- + !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_voucherforaxelor1} +- + I check that the voucher state is "Waiting for re-checking" +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor1}: + - state == 'recheck' +- + I clicked on Validate Button +- + !workflow {model: account.voucher, action: recheck_voucher, ref: account_voucher_voucherforaxelor1} +- + I check that the voucher state is "posted" +- + !assert {model: account.voucher, id: account_voucher_voucherforaxelor1}: + - state == 'posted' + +- + I check that Moves get created for this voucher +- + !python {model: account.voucher}: | + acc_id=self.browse(cr, uid, ref("account_voucher_voucherforaxelor1")) + assert(acc_id.move_id) + +- + I check that the invoice state is now Done +- + !assert {model: account.invoice, id: account_invoice_voucher_payment}: + - state == 'paid' + + + + + + +