← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 745045] Re: base_sale_multichannels: base.sale.payment.type multiple matches

 

Hi Guewen
I agree for the bug.
For the path I think it will be better to add your check also when there is only one payment setting found.
Indeed the method can be "bank" but as you forget to add this method in your setting, openerp will found the method "bank_cr". But for you it's not the same so It's better to don't map it.

Moreover maybe the best solution will to don't use anymore the "ilike"
feature to be case sensitive, what do you think?

Patch with case sensitive :

-        payment_setting_ids = self.pool.get('base.sale.payment.type').search(cr, uid, [['name', 'ilike', payment_code]])
-        return payment_setting_ids and self.pool.get('base.sale.payment.type').browse(cr, uid, payment_setting_ids[0], context) or False
+        pay_type_obj = self.pool.get('base.sale.payment.type')
+        payment_setting_ids = pay_type_obj.search(cr, uid, [['name', 'like', payment_code]])
+        payment_setting_id = False
+        for type in pay_type_obj.read(cr, uid, payment_setting_ids, fields=['name'], context=context):
+            if payment_code in [x.stip() for x in type['name'].split(';')]:
+                payment_setting_id = type['id']
+        return payment_setting_id and pay_type_obj.browse(cr, uid, payment_setting_id, context) or False

Patch without case sensitive

-        payment_setting_ids = self.pool.get('base.sale.payment.type').search(cr, uid, [['name', 'ilike', payment_code]])
-        return payment_setting_ids and self.pool.get('base.sale.payment.type').browse(cr, uid, payment_setting_ids[0], context) or False
+        pay_type_obj = self.pool.get('base.sale.payment.type')
+        payment_setting_ids = pay_type_obj.search(cr, uid, [['name', 'ilike', payment_code]])
+        payment_setting_id = False
+        for type in pay_type_obj.read(cr, uid, payment_setting_ids, fields=['name'], context=context):
+            if payment_code.lower() in [x.stip().lower() for x in type['name'].split(';')]:
+                payment_setting_id = type['id']
+        return payment_setting_id and pay_type_obj.browse(cr, uid, payment_setting_id, context) or False


What do you think?

-- 
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/745045

Title:
  base_sale_multichannels: base.sale.payment.type multiple matches

Status in Magento Open ERP Connector:
  New

Bug description:
  Hi,

  This bug concerns the module base_sale_multichannels in extra-addons,
  so I'm not sure if I better have to report the bug here or on
  openobject-addons. Please tell me if I have to report on extra-addons
  next time.

  The payment codes in base.sale.payment.type are a list of codes
  separated by a ; like "ccsave;free".

  There is a method payment_code_to_payment_settings in the sale.order
  class which searches and returns the right object of
  base.sale.payment.type according to the payment_code given by magento.

  The search is basically a "ilike" on the name, that's efficient and
  works perfect with most of cases.

  But it can happen that you have one payment settings "bank" and one
  "bankcr" for example (we have this issue).

  The method returns the first found, so it can return the settings of
  "bankcr" instead of "bank".

  I just added a few lines in that method which search the exact match
  when many rows are found with the "ilike".

  The attached patch is for extra-addons V5. But if you agree with my
  fix, I can give you a patch for V6 or apply them myself to both extra-
  addons v5 and v6. Just confirm me that's ok for you.

  Thanks
  Guewen



References