← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 808567] [NEW] stock.py: Improvement in code when selecting account partner

 

Public bug reported:

The selection of the account partner in stock.py, whilst correct within
the current OpenERP model, is not "strictly" correct as it assumes the
delivery address partner is the account partner. We propose the
following simple change which corrects this issue as we needed to make
this change whilst implementing a franchise sub-partner payment model.
Diff below:

=== modified file 'stock/stock.py'
--- stock/stock.py	2011-06-01 21:07:58 +0000
+++ stock/stock.py	2011-07-11 00:43:43 +0000
@@ -979,6 +979,10 @@
                 continue
             payment_term_id = False
             partner =  picking.address_id and picking.address_id.partner_id
+
+            if picking.sale_id:
+                partner = picking.sale_id.partner_id
+
             if not partner:
                 raise osv.except_osv(_('Error, no partner !'),
                     _('Please put a partner on the picking list if you want to generate invoice.'))
@@ -1009,12 +1013,13 @@
                 }
                 invoice_obj.write(cr, uid, [invoice_id], invoice_vals, context=context)
             else:
+
                 invoice_vals = {
                     'name': picking.name,
                     'origin': (picking.name or '') + (picking.origin and (':' + picking.origin) or ''),
                     'type': inv_type,
                     'account_id': account_id,
-                    'partner_id': address.partner_id.id,
+                    'partner_id': partner.id,
                     'address_invoice_id': address_invoice_id,
                     'address_contact_id': address_contact_id,
                     'comment': comment,

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/808567

Title:
  stock.py: Improvement in code when selecting account partner

Status in OpenERP Modules (addons):
  New

Bug description:
  The selection of the account partner in stock.py, whilst correct
  within the current OpenERP model, is not "strictly" correct as it
  assumes the delivery address partner is the account partner. We
  propose the following simple change which corrects this issue as we
  needed to make this change whilst implementing a franchise sub-partner
  payment model. Diff below:

  === modified file 'stock/stock.py'
  --- stock/stock.py	2011-06-01 21:07:58 +0000
  +++ stock/stock.py	2011-07-11 00:43:43 +0000
  @@ -979,6 +979,10 @@
                   continue
               payment_term_id = False
               partner =  picking.address_id and picking.address_id.partner_id
  +
  +            if picking.sale_id:
  +                partner = picking.sale_id.partner_id
  +
               if not partner:
                   raise osv.except_osv(_('Error, no partner !'),
                       _('Please put a partner on the picking list if you want to generate invoice.'))
  @@ -1009,12 +1013,13 @@
                   }
                   invoice_obj.write(cr, uid, [invoice_id], invoice_vals, context=context)
               else:
  +
                   invoice_vals = {
                       'name': picking.name,
                       'origin': (picking.name or '') + (picking.origin and (':' + picking.origin) or ''),
                       'type': inv_type,
                       'account_id': account_id,
  -                    'partner_id': address.partner_id.id,
  +                    'partner_id': partner.id,
                       'address_invoice_id': address_invoice_id,
                       'address_contact_id': address_contact_id,
                       'comment': comment,

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


Follow ups

References