[Trunk/7.0] Service article not invoiced by invoice on delivery

Bug #1167330 reported by Christian Werner
46
This bug affects 9 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP R&D Addons Team 2

Bug Description

Service Products are not invoiced:

SO with:
Create Invoice: On Delivery Order

SOL:
Product A with Type: Stockable Product
Product B with Type: Service

If I confirm order and delivery and create Invoice, only Product A is in the invoice.

In Version 6.1 both products are invoiced.

I've tested it also with demo data. Same issue.

Tags: warehouse

Related branches

summary: - Service article not invoiced by invoice on delivery
+ [Trunk/7.0] Service article not invoiced by invoice on delivery
Changed in openobject-addons:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
Revision history for this message
Christian Werner (cw-x) wrote :

I have solved this problem by using function invoice_hook:

    def _invoice_hook(self, cr, uid, picking, invoice_id):
        context = {}
        for inv in self.pool.get('account.invoice').browse(cr, uid, [invoice_id], context=context):
            invoice_vals = { 'type': inv.type,
                             'fiscal_position': inv.fiscal_position
                           }

        for line in picking.sale_id.order_line:
             if not line.invoiced and not line.move_ids and line.state == 'done':
                 if invoice_vals['type'] in ('out_invoice', 'out_refund'):
                     account_id = line.product_id.property_account_income.id
                     if not account_id:
                         account_id = line.product_id.categ_id.property_account_income_categ.id
                 else:
                      account_id = line.product_id.property_account_expense.id
                      if not account_id:
                         account_id = line.product_id.categ_id.property_account_expense_categ.id

                 if invoice_vals['fiscal_position']:
                     fp_obj = self.pool.get('account.fiscal.position')
                     fiscal_position = fp_obj.browse(cr, uid, invoice_vals['fiscal_position'], context=context)
                     account_id = fp_obj.map_account(cr, uid, fiscal_position, account_id)

                 vals = {
                        'name': line.name,
                        'origin': line.order_id.name,
                        'invoice_id': invoice_id,
                        'uos_id': line.product_uom.id,
                        'product_id': line.product_id.id,
                        'account_id': account_id,
                        'price_unit': line.price_unit,
                        'discount': line.discount,
                        'quantity': line.product_uos_qty,
                        'invoice_line_tax_id': [(6, 0, [x.id for x in line.tax_id])],
                        'account_analytic_id': line.order_id.project_id and line.order_id.project_id.id or False,
                        }
                 inv_line_id = self.pool.get('account.invoice.line').create(cr, uid, vals, context=context)
                 self.pool.get('sale.order.line').write(cr, uid, [line.id], {'invoice_lines': [(4, inv_line_id)]}, context=context)

             else:
                 continue

        return super(stock_picking, self)._invoice_hook(cr, uid, picking, invoice_id)

So all products without move_ids in SOL will be invoiced by creating the invoice first delivery.

Revision history for this message
Alexis de Lattre (alexis-via) wrote :

I am experiencing the same bug. The cause is quite simple :

in the addons v6.1 branch, if you look at the code of sale/stock.py :
line 124 : the fonction action_invoice_create() of the object stock.picking is "inherited"
line 159 : that's where the service line of the sale order are read and added to the invoice (line 184)

If you try to find the "equivalent" code in addons v7.0, you look at sale_stock/stock.py :
- line 35, the object stock.picking is inherited
- but there is not inherit of the function "action_invoice_create" and no mention of "service" anywhere in the code

My conclusion is that the code that used to handle this in OpenERP 6.1 in the "sale" module has been dropped instead of being moved to the "sale_stock" module.

Amit Parik (amit-parik)
tags: added: warehouse
Revision history for this message
Alexis de Lattre (alexis-via) wrote :

I have fixed this bug in a dedicated module "stock_invoice_service_from_delivery" that you will find in the following branch :

lp:~akretion-team/+junk/70-usability

Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Fixed in version 7.0 at revision 9721 (revid <email address hidden>).

Changed in openobject-addons:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.