From: Sébastien Grignard Date: Wed, 15 Jan 2014 22:59:26 +0000 (+0100) Subject: Added a refund purchase button in the pos session form. This action creates a stateme... X-Git-Url: http://git.cyclocoop.org/?p=burette%2Fbikecoop.git;a=commitdiff_plain;h=455835a01a4a32ce55122740e101c251e42767db Added a refund purchase button in the pos session form. This action creates a statement balanced using the journal's purchase account. --- diff --git a/bikecoop.py b/bikecoop.py index 91ca5e2..2dd81da 100644 --- a/bikecoop.py +++ b/bikecoop.py @@ -23,6 +23,9 @@ from openerp.osv import fields, osv import openerp.addons.decimal_precision as dp +from openerp.tools.translate import _ +from openerp.addons.point_of_sale.wizard.pos_box import PosBoxOut + from datetime import date @@ -77,5 +80,37 @@ class product_template(osv.osv): product_template() +# Inheriting journal in order to define a purchase account which will be used when refunding an employee from an open register +class account_journal(osv.osv): + _inherit = 'account.journal' + _columns = { + 'purchase_account_id' : fields.many2one('account.account', 'Purchase Account', select=1), + } +account_journal() + +class PurchaseBox(PosBoxOut): + # Copied from account/wizard/pos_box.py since there is no way to overload the account used to create the statement + def _run(self, cr, uid, ids, records, context=None): + for box in self.browse(cr, uid, ids, context=context): + for record in records: + if not record.journal_id: + raise osv.except_osv(_('Error!'), + _("Please check that the field 'Journal' is set on the Bank Statement")) + + if not record.journal_id.purchase_account_id: + raise osv.except_osv(_('Error!'), + _("Please check that the field 'Purchase Account' is set on the payment method '%s'.") % (record.journal_id.name,)) + + self._create_bank_statement_line(cr, uid, box, record, context=context) + + return {} + + def _compute_values_for_statement_line(self, cr, uid, box, record, context=None): + values = super(PosBoxOut, self)._compute_values_for_statement_line(cr, uid, box, record, context=context) + values['account_id'] = record.journal_id.purchase_account_id.id + return values + +PurchaseBox() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/view/point_of_sale.xml b/view/point_of_sale.xml index d9c11c5..2dc0cc5 100644 --- a/view/point_of_sale.xml +++ b/view/point_of_sale.xml @@ -27,5 +27,36 @@ + + + + + pos.session + pos.session + + + +