← Back to team overview

openerp-india team mailing list archive

[Bug 1191235] Re: Non-declared variable in sale_stock.py gives error

 

** Changed in: openobject-addons
     Assignee: OpenERP R&D Addons Team 3 (openerp-dev-addons3) => OpenERP R&D Addons Team 2 (openerp-dev-addons2)

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/1191235

Title:
  Non-declared variable in sale_stock.py gives error

Status in OpenERP Addons (modules):
  Confirmed

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/1191235/+subscriptions