diff --git a/base_transaction_id/__openerp__.py b/base_transaction_id/__openerp__.py index 07d5bb6e..9d1c1f5a 100644 --- a/base_transaction_id/__openerp__.py +++ b/base_transaction_id/__openerp__.py @@ -24,23 +24,34 @@ 'author': 'Camptocamp', 'maintainer': 'Camptocamp', 'category': 'Hidden/Dependency', - 'complexity': 'easy', #easy, normal, expert - 'depends': ['account', 'sale','stock'], + 'complexity': 'easy', + 'depends': [ + 'account', + 'sale', + 'stock' + ], 'description': """ - Adds transaction id to invoice and sale models and views. On Sales order, you can specify the transaction ID - used for the payment and it will be propagated to the invoice (even if made from packing). - This is mostly used for e-commerce handling. You can then add a mapping on that SO field to save the e-commerce - financial Transaction ID into the OpenERP SO field. The main purpose is to ease the reconciliation process and + Adds transaction id to invoice and sale models and views. + On Sales order, you can specify the transaction ID used + for the payment and it will be propagated to the invoice + (even if made from packing). + This is mostly used for e-commerce handling. + You can then add a mapping on that SO field to save + the e-commerce financial Transaction ID into the + OpenERP sale order field. + The main purpose is to ease the reconciliation process and be able to find the partner when importing the bank statement. """, 'website': 'http://www.openerp.com', 'init_xml': [], - 'update_xml': ['invoice_view.xml', 'sale_view.xml'], + 'update_xml': [ + 'invoice_view.xml', + 'sale_view.xml' + ], 'demo_xml': [], 'test': [], 'installable': True, 'images': [], 'auto_install': False, 'license': 'AGPL-3', - 'active': False, } diff --git a/base_transaction_id/invoice.py b/base_transaction_id/invoice.py index 26a7f3ae..c1292595 100644 --- a/base_transaction_id/invoice.py +++ b/base_transaction_id/invoice.py @@ -19,17 +19,18 @@ # ############################################################################## -from osv import fields, osv -from tools.translate import _ +from openerp.osv.orm import Model +from openerp.osv import fields -class AccountInvoice(osv.osv): + +class AccountInvoice(Model): _inherit = 'account.invoice' + _columns = { - 'transaction_id':fields.char( + 'transaction_id': fields.char( 'Transaction id', size=128, required=False, select=1, - help="Transction id from the financial institute" - ), + help="Transction id from the financial institute"), } diff --git a/base_transaction_id/sale.py b/base_transaction_id/sale.py index 62330e2c..9e9fca3d 100644 --- a/base_transaction_id/sale.py +++ b/base_transaction_id/sale.py @@ -19,21 +19,25 @@ # ############################################################################## -from osv import fields, osv +from openerp.osv.orm import Model +from openerp.osv import fields -class SaleOrder(osv.osv): + +class SaleOrder(Model): _inherit = 'sale.order' + _columns = { - 'transaction_id':fields.char('Transaction id', size=128,required=False, - help="Transction id from the financial institute"), + 'transaction_id': fields.char( + 'Transaction id', + size=128, + required=False, + help="Transaction id from the financial institute"), } - - def _prepare_invoice(self, cursor, uid, order, lines, context=None): + def _prepare_invoice(self, cr, uid, order, lines, context=None): #we put the transaction id in the generated invoices - if context is None: - context = {} - invoice_vals = super(SaleOrder, self)._prepare_invoice(cursor, uid, order, lines, context) + invoice_vals = super(SaleOrder, self)._prepare_invoice( + cr, uid, order, lines, context=context) invoice_vals.update({ 'transaction_id': order.transaction_id}) return invoice_vals diff --git a/base_transaction_id/stock.py b/base_transaction_id/stock.py index f2b66f71..cd6d1e8b 100644 --- a/base_transaction_id/stock.py +++ b/base_transaction_id/stock.py @@ -19,20 +19,24 @@ # ############################################################################## -from osv import osv +from openerp.osv.orm import Model -class StockPicking(osv.osv): + +class StockPicking(Model): _inherit = "stock.picking" - def action_invoice_create(self, cursor, uid, ids, journal_id=False, - group=False, type='out_invoice', context=None): - res = super(StockPicking, self).action_invoice_create(cursor, uid, ids, - journal_id,group, type, context) + def action_invoice_create( + self, cr, uid, ids, journal_id=False, group=False, + type='out_invoice', context=None): + res = super(StockPicking, self).action_invoice_create( + cr, uid, ids, journal_id, group, type, context) for pick_id in res: - pick = self.browse(cursor, uid, pick_id) + pick = self.browse(cr, uid, pick_id, context=context) if pick.sale_id and pick.sale_id.transaction_id: - self.pool.get('account.invoice').write(cursor, - uid, - res[pick_id], - {'transaction_id': pick.sale_id.transaction_id}) + self.pool.get('account.invoice').write( + cr, + uid, + res[pick_id], + {'transaction_id': pick.sale_id.transaction_id}, + context=context) return res