diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 7669bfc4810..cf7b445fbf6 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -59,7 +59,7 @@ class stock_move(osv.osv): def _create_invoice_line_from_vals(self, cr, uid, move, invoice_line_vals, context=None): if move.purchase_line_id: invoice_line_vals['purchase_line_id'] = move.purchase_line_id.id - invoice_line_vals['account_analytic_id'] = move.purchase_line_id.account_analytic_id.id or False, + invoice_line_vals['account_analytic_id'] = move.purchase_line_id.account_analytic_id.id or False invoice_line_id = super(stock_move, self)._create_invoice_line_from_vals(cr, uid, move, invoice_line_vals, context=context) if move.purchase_line_id: purchase_line = move.purchase_line_id diff --git a/addons/stock_dropshipping/tests/__init__.py b/addons/stock_dropshipping/tests/__init__.py new file mode 100644 index 00000000000..17a9f9dafbc --- /dev/null +++ b/addons/stock_dropshipping/tests/__init__.py @@ -0,0 +1 @@ +from . import test_invoicing diff --git a/addons/stock_dropshipping/tests/test_invoicing.py b/addons/stock_dropshipping/tests/test_invoicing.py new file mode 100644 index 00000000000..c1588b0af13 --- /dev/null +++ b/addons/stock_dropshipping/tests/test_invoicing.py @@ -0,0 +1,60 @@ +# Author: Leonardo Pistone +# Copyright 2015 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from openerp.tests.common import TransactionCase + + +class TestCreateInvoice(TransactionCase): + + def setUp(self): + super(TestCreateInvoice, self).setUp() + self.Wizard = self.env['stock.invoice.onshipping'] + + self.customer = self.env.ref('base.res_partner_3') + product = self.env.ref('product.product_product_36') + dropship_route = self.env.ref('stock_dropshipping.route_drop_shipping') + + self.so = self.env['sale.order'].create({ + 'partner_id': self.customer.id, + }) + self.sol = self.env['sale.order.line'].create({ + 'name': '/', + 'order_id': self.so.id, + 'product_id': product.id, + 'route_id': dropship_route.id, + }) + + def test_po_on_delivery_creates_correct_invoice(self): + self.so.action_button_confirm() + + po = self.so.procurement_group_id.procurement_ids.purchase_id + self.assertTrue(po) + po.invoice_method = 'picking' + po.signal_workflow('purchase_confirm') + + picking = po.picking_ids + self.assertEqual(1, len(picking)) + picking.action_done() + + wizard = self.Wizard.with_context({ + 'active_id': picking.id, + 'active_ids': [picking.id], + }).create({}) + invoice_ids = wizard.create_invoice() + invoices = self.env['account.invoice'].browse(invoice_ids) + self.assertEqual(1, len(invoices)) + self.assertEqual(invoices.type, 'in_invoice') + self.assertEqual(invoices, po.invoice_ids)