[6.0] product_id_change of account.invoice may fail if no company_id or currency_id is supplied.

Bug #615322 reported by Borja López Soilán (NeoPolus)
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
Unassigned

Bug Description

On trunk/6.0 the account module was updated to add multicompany support. The invoices product_id field 'on-change' method (named product_id_change) was modified to get the company_id from the context and the invoice view was modified accordingly to pass the company_id on the context.
But if a module does not pass the company_id on the context (like account_tax_include, see bug 615324) then product_id_change raises an exception cause it does not verify properly whether company_id is defined.

Currently the code looks like this:

    def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
        ...
        company_id = context.get('company_id',False)
        ...
        if company_id:
            ...
        ...
        if not company_id and not currency_id:
            return res_final

        company = self.pool.get('res.company').browse(cr, uid, company_id)
        currency = self.pool.get('res.currency').browse(cr, uid, currency_id)
        ...

That means that, if currency_id is defined, but company_id is not defined the method will crash!
Also, if no currency_id is defined, but company_id is in context, it will crash too.

Instead of "if not company_id and not currency_id:" it should be "if not company_id or not currency_id:".

Related branches

Revision history for this message
Borja López Soilán (NeoPolus) (borjals) wrote :
description: updated
summary: [6.0] product_id_change of account.invoice does crash if no company_id
- is passed in the contex
+ is passed in the context
Changed in openobject-addons:
status: New → Confirmed
summary: - [6.0] product_id_change of account.invoice does crash if no company_id
- is passed in the context
+ [6.0] product_id_change of account.invoice may fail if no company_id or
+ currency_id is supplied.
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Fixed by revision 4544 <email address hidden>.
Thanks.

Changed in openobject-addons:
importance: Undecided → Medium
milestone: none → 6.0
status: Confirmed → Fix Released
Revision history for this message
Borja López Soilán (NeoPolus) (borjals) wrote :

Thanks to you Jay :)

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.