Avoid to write 2 times on the invoice by using the method that prepare

the values before the write
This commit is contained in:
Guewen Baconnier
2014-10-09 09:04:36 +02:00
parent 0630827efb
commit 9228bb0a68

View File

@@ -19,24 +19,16 @@
#
##############################################################################
from openerp.osv.orm import Model
from openerp.osv import orm
class StockPicking(Model):
class StockPicking(orm.Model):
_inherit = "stock.picking"
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(cr, uid, pick_id, context=context)
if pick.sale_id and 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
def _create_invoice_from_picking(self, cr, uid, picking, vals,
context=None):
""" Propagate the transaction ID from sale to invoice """
vals['transaction_id'] = picking.sale_id.transaction_id
_super = super(StockPicking, self)
return _super._create_invoice_from_picking(cr, uid, picking, vals,
context=context)