Hi again, I think that adding this piece of code in the purchase_discount/purchase_discount.py file in the class purchase_order should correct this lack :
def action_invoice_create(self, cr, uid, ids, *args): res = False for o in self.browse(cr, uid, ids): il = [] for ol in o.order_line: if ol.product_id: a = ol.product_id.product_tmpl_id.property_account_expense.id if not a: a = ol.product_id.categ_id.property_account_expense_categ.id if not a: raise osv.except_osv('Error !', 'There is no expense account defined for this product: "%s" (id:%d)' % (line.product_id.name, line.product_id.id,)) else: print ol.discount a = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category') il.append((0, False, { 'name': ol.name, 'account_id': a, 'price_unit': ol.price_unit or 0.0, 'quantity': ol.product_qty, 'product_id': ol.product_id.id or False, 'uos_id': ol.product_uom.id or False, 'discount': ol.discount or 0.0, 'invoice_line_tax_id': [(6, 0, [x.id for x in ol.taxes_id])], 'account_analytic_id': ol.account_analytic_id.id, })) a = o.partner_id.property_account_payable.id inv = { 'name': o.partner_ref or o.name, 'reference': "P%dPO%d" % (o.partner_id.id, o.id), 'account_id': a, 'type': 'in_invoice', 'partner_id': o.partner_id.id, 'currency_id': o.pricelist_id.currency_id.id, 'address_invoice_id': o.partner_address_id.id, 'address_contact_id': o.partner_address_id.id, 'origin': o.name, 'invoice_line': il, } inv_id = self.pool.get('account.invoice').create(cr, uid, inv, {'type':'in_invoice'}) self.pool.get('account.invoice').button_compute(cr, uid, [inv_id], {'type':'in_invoice'}, set_total=True) self.write(cr, uid, [o.id], {'invoice_id': inv_id}) res = inv_id return res Regards ------------------------ André Kurz - www.hasa.ch - Open ERP Starter Partner Hasa Sà rl - 1201 Genève -------------------- m2f -------------------- -- http://www.openerp.com/forum/viewtopic.php?p=24901#24901 -------------------- m2f -------------------- _______________________________________________ Tinyerp-users mailing list http://tiny.be/mailman/listinfo/tinyerp-users
