Openbravo Issue Tracking System - Retail Modules
View Issue Details
0031524Retail ModulesWeb POSpublic2015-11-18 14:112015-12-29 13:06
malsasua 
mario_castello 
highmajoralways
closedfixed 
20Community Appliance
 
RR16Q1 
jorge-garcia
No
0031524: hook 'OBPOS_PreCustomerSave' is not working fine
the hook OBPOS_PreCustomerSave is not working fine:
. it is not possible to access to customer object
. it is not possible to cancel
. add the next hook:
OB.MobileApp.model.hookManager.registerHook('OBPOS_PreCustomerSave', function (args, callbacks) {
  // execute all your logic here
  debugger;
});

file: org.openbravo.retail.posterminal/js/pointofsale/view/subwindows/customers/components/sharedcomponents.js

add propossed hooks (comments)


  saveCustomer: function (inSender, inEvent) {
    var me = this,
        sw = me.subWindow;

    function getCustomerValues(params) {
      me.waterfall('onSaveChange', {
        customer: params.customer
      });
    }

    function goToViewWindow(sw, params) {
      if (sw.caller === 'mainSubWindow') {
        sw.doChangeSubWindow({
          newWindow: {
            name: 'customerView',
            params: {
              navigateOnClose: 'mainSubWindow',
              businessPartner: params.customer
            }
          }
        });
      } else {
        sw.doChangeSubWindow({
          newWindow: {
            name: 'customerView',
            params: {
              navigateOnClose: 'customerAdvancedSearch',
              businessPartner: params.customer
            }
          }
        });
      }
    }

    if (this.customer === undefined) {
      this.model.get('customer').newCustomer();
      this.waterfall('onSaveChange', {
        customer: this.model.get('customer')
      });
      this.adjustNames(this.model.get('customer'));
      //Hook here OBPOS_BeforeCustomerSave
      //arg1: customer: this.model.get('customer')
      //arg2: isNew: true
      //callback
      //if (args.cancelOperation) {
      // return
      //}
      var success = this.model.get('customer').saveCustomer();
      if (success) {
        goToViewWindow(sw, {
          customer: OB.UTIL.clone(this.model.get('customer'))
        });
      }
    } else {
      var that = this;
      this.model.get('customer').loadById(this.customer.get('id'), function (customer) {
        getCustomerValues({
          customer: customer
        });
        that.adjustNames(customer);
        //Hook here OBPOS_BeforeCustomerSave
        //arg1: customer: customer
        //arg2: isNew: false
        //callback
        //if (args.cancelOperation) {
        // return
        //}
        var success = customer.saveCustomer();
        if (success) {
          goToViewWindow(sw, {
            customer: customer
          });
        }
      });
    }
  },

Propossed name for the hook: OBPOS_BeforeCustomerSave
No tags attached.
Issue History
2015-11-18 14:11malsasuaNew Issue
2015-11-18 14:11malsasuaAssigned To => Retail
2015-11-18 14:11malsasuaResolution time => 1452121200
2015-11-18 14:11malsasuaTriggers an Emergency Pack => No
2015-11-18 14:12malsasuaResolution time1452121200 => 1450566000
2015-11-18 22:34OrekariaNote Added: 0081965
2015-11-18 22:34OrekariaStatusnew => feedback
2015-11-18 22:35OrekariaNote Edited: 0081965bug_revision_view_page.php?bugnote_id=0081965#r10274
2015-11-18 22:35OrekariaNote Edited: 0081965bug_revision_view_page.php?bugnote_id=0081965#r10275
2015-12-07 12:27malsasuaStatusfeedback => new
2015-12-07 12:30OrekariaStatusnew => acknowledged
2015-12-07 16:39guilleaerNote Added: 0082599
2015-12-07 16:39guilleaerProposed Solution updated
2015-12-12 18:07OrekariaSummaryhook "OBPOS_PreCustomerSave" is not working fine => hook 'OBPOS_PreCustomerSave' is not working fine
2015-12-14 16:23mario_castelloAssigned ToRetail => mario_castello
2015-12-14 16:23mario_castelloStatusacknowledged => scheduled
2015-12-19 02:54hgbotCheckin
2015-12-19 02:54hgbotNote Added: 0082879
2015-12-19 06:47hgbotCheckin
2015-12-19 06:47hgbotNote Added: 0082880
2015-12-19 06:47hgbotStatusscheduled => resolved
2015-12-19 06:47hgbotResolutionopen => fixed
2015-12-19 06:47hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/1578af5dacef7b5fa7fd1c14a3b422de55cf7a75 [^]
2015-12-29 12:36jorge-garciaReview Assigned To => jorge-garcia
2015-12-29 13:06jorge-garciaNote Added: 0083046
2015-12-29 13:06jorge-garciaStatusresolved => closed
2015-12-29 13:06jorge-garciaFixed in Version => RR16Q1

Notes
(0081965)
Orekaria   
2015-11-18 22:34   
(edited on: 2015-11-18 22:35)
Cancelation:
The hook can be canceled with the args.passValidation = false value

Customer object:
If the args.meObject.customer is assigned, that customer will be taken
All the available information at that stage can be retrieved within the args.meObject.model value

(0082599)
guilleaer   
2015-12-07 16:39   
Don't forget to update the documentation when hook is created
(0082879)
hgbot   
2015-12-19 02:54   
Repository: tools/automation/pi-mobile
Changeset: 20539d6c1789a0b3e5c9450a794e97d32c1b76d6
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Fri Dec 18 19:54:18 2015 -0600
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/20539d6c1789a0b3e5c9450a794e97d32c1b76d6 [^]

Related to issue 31524: Added automation test

---
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I31524_HookBeforeCustomerSaveCancelling.java
---
(0082880)
hgbot   
2015-12-19 06:47   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 1578af5dacef7b5fa7fd1c14a3b422de55cf7a75
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Fri Dec 18 23:46:51 2015 -0600
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/1578af5dacef7b5fa7fd1c14a3b422de55cf7a75 [^]

Fixed issue 31524: Added new hook OBPOS_BeforeCustomerSave

---
M web/org.openbravo.retail.posterminal/js/pointofsale/view/subwindows/customers/components/sharedcomponents.js
---
(0083046)
jorge-garcia   
2015-12-29 13:06   
Code review and testing OK