[MIG] base_transaction_id: Migrated to 7.0

- Adapt import to fit last recomandation
- Import osv for osv.except
- pep8, pylint, eyeballing
- standardize the naming of the argument 'cr' instead of 'cursor'
- Remove the active key in the __openerp__.py
pull/821/head
Joel Grand-Guillaume 2012-12-19 13:58:54 +01:00 committed by Bhavesh Heliconia
parent 93f6ecd661
commit 6ef2f81091
4 changed files with 54 additions and 34 deletions

View File

@ -24,23 +24,34 @@
'author': 'Camptocamp', 'author': 'Camptocamp',
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Hidden/Dependency', 'category': 'Hidden/Dependency',
'complexity': 'easy', #easy, normal, expert 'complexity': 'easy',
'depends': ['account', 'sale','stock'], 'depends': [
'account',
'sale',
'stock'
],
'description': """ 'description': """
Adds transaction id to invoice and sale models and views. On Sales order, you can specify the transaction ID Adds transaction id to invoice and sale models and views.
used for the payment and it will be propagated to the invoice (even if made from packing). On Sales order, you can specify the transaction ID used
This is mostly used for e-commerce handling. You can then add a mapping on that SO field to save the e-commerce for the payment and it will be propagated to the invoice
financial Transaction ID into the OpenERP SO field. The main purpose is to ease the reconciliation process and (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. be able to find the partner when importing the bank statement.
""", """,
'website': 'http://www.openerp.com', 'website': 'http://www.openerp.com',
'init_xml': [], 'init_xml': [],
'update_xml': ['invoice_view.xml', 'sale_view.xml'], 'update_xml': [
'invoice_view.xml',
'sale_view.xml'
],
'demo_xml': [], 'demo_xml': [],
'test': [], 'test': [],
'installable': True, 'installable': True,
'images': [], 'images': [],
'auto_install': False, 'auto_install': False,
'license': 'AGPL-3', 'license': 'AGPL-3',
'active': False,
} }

View File

@ -19,17 +19,18 @@
# #
############################################################################## ##############################################################################
from osv import fields, osv from openerp.osv.orm import Model
from tools.translate import _ from openerp.osv import fields
class AccountInvoice(osv.osv):
class AccountInvoice(Model):
_inherit = 'account.invoice' _inherit = 'account.invoice'
_columns = { _columns = {
'transaction_id':fields.char( 'transaction_id': fields.char(
'Transaction id', 'Transaction id',
size=128, size=128,
required=False, required=False,
select=1, select=1,
help="Transction id from the financial institute" help="Transction id from the financial institute"),
),
} }

View File

@ -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' _inherit = 'sale.order'
_columns = { _columns = {
'transaction_id':fields.char('Transaction id', size=128,required=False, 'transaction_id': fields.char(
help="Transction id from the financial institute"), 'Transaction id',
size=128,
required=False,
help="Transaction id from the financial institute"),
} }
def _prepare_invoice(self, cr, uid, order, lines, context=None):
def _prepare_invoice(self, cursor, uid, order, lines, context=None):
#we put the transaction id in the generated invoices #we put the transaction id in the generated invoices
if context is None: invoice_vals = super(SaleOrder, self)._prepare_invoice(
context = {} cr, uid, order, lines, context=context)
invoice_vals = super(SaleOrder, self)._prepare_invoice(cursor, uid, order, lines, context)
invoice_vals.update({ invoice_vals.update({
'transaction_id': order.transaction_id}) 'transaction_id': order.transaction_id})
return invoice_vals return invoice_vals

View File

@ -19,20 +19,24 @@
# #
############################################################################## ##############################################################################
from osv import osv from openerp.osv.orm import Model
class StockPicking(osv.osv):
class StockPicking(Model):
_inherit = "stock.picking" _inherit = "stock.picking"
def action_invoice_create(self, cursor, uid, ids, journal_id=False, def action_invoice_create(
group=False, type='out_invoice', context=None): self, cr, uid, ids, journal_id=False, group=False,
res = super(StockPicking, self).action_invoice_create(cursor, uid, ids, type='out_invoice', context=None):
journal_id,group, type, context) res = super(StockPicking, self).action_invoice_create(
cr, uid, ids, journal_id, group, type, context)
for pick_id in res: 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: if pick.sale_id and pick.sale_id.transaction_id:
self.pool.get('account.invoice').write(cursor, self.pool.get('account.invoice').write(
uid, cr,
res[pick_id], uid,
{'transaction_id': pick.sale_id.transaction_id}) res[pick_id],
{'transaction_id': pick.sale_id.transaction_id},
context=context)
return res return res