Non-declared variable in sale_stock.py gives error

Bug #1191235 reported by Kitti Upariphutthiphong
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Medium
OpenERP R&D Addons Team 2

Bug Description

Based on rev 9242,

sale_stock.py --> at the bottom end method _create_invoices(), I found that 2 variables are not declared, --> inv_amount and res.
In normal case, when sale.order_policy == 'picking', this method will not be used. So far, no problem.
Somehow, I write my own addons, which use this method on order_policy = picking, gives error (as variables are not declared).
May be the code need re-factoring??

================================

class sale_advance_payment_inv(osv.osv_memory):
    _inherit = "sale.advance.payment.inv"

    def _create_invoices(self, cr, uid, inv_values, sale_id, context=None):
        result = super(sale_advance_payment_inv, self)._create_invoices(cr, uid, inv_values, sale_id, context=context)
        sale_obj = self.pool.get('sale.order')
        sale_line_obj = self.pool.get('sale.order.line')
        wizard = self.browse(cr, uid, [result], context)
        sale = sale_obj.browse(cr, uid, sale_id, context=context)
        if sale.order_policy == 'postpaid':
            raise osv.except_osv(
                _('Error!'),
                _("You cannot make an advance on a sales order \
                     that is defined as 'Automatic Invoice after delivery'."))

        # kittiu: seem to be a bug as inv_amoutn is not declared. And in normal case, this part is not used, so I delete them.
# # If invoice on picking: add the cost on the SO
# # If not, the advance will be deduced when generating the final invoice
# line_name = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('name') or ''
# line_tax = inv_values.get('invoice_line') and inv_values.get('invoice_line')[0][2].get('invoice_line_tax_id') or False
# if sale.order_policy == 'picking':
# vals = {
# 'order_id': sale.id,
# 'name': line_name,
# 'price_unit': -inv_amount,
# 'product_uom_qty': wizard.qtty or 1.0,
# 'product_uos_qty': wizard.qtty or 1.0,
# 'product_uos': res.get('uos_id', False),
# 'product_uom': res.get('uom_id', False),
# 'product_id': wizard.product_id.id or False,
# 'discount': False,
# 'tax_id': line_tax,
# }
# sale_line_obj.create(cr, uid, vals, context=context)
        # -- kittiu:
        return result

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

It will gives error when you customized the code.

Thank you!

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Medium
status: New → Confirmed
Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 3 (openerp-dev-addons3) → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
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.