Openerp/histest3

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา

หน้านี้รวมข้อมูลสำหรับการทดสอบการพัฒนาระบบด้วย OpenERP

การแยกโค้ด javascript เป็นส่วน

ก่อนเริ่ม: ดาวน์โหลดโค้ด histest.zip จากครั้งก่อน

histest.js

openerp.histest = function(instance) {

    openerp.histest.message(instance);
    openerp.histest.patient(instance);
    
    instance.web.client_actions.add('histest.indexAction',
                                    'instance.histest.indexAction');

};

histest_message.js

openerp.histest.message = function(instance) {
    
    instance.histest.MsgManagerWidget = instance.web.Widget.extend({

        start: function() {
            var self = this;
            console.log("MsgMan started...");
            setInterval(function() {
                self.popup();
            },5000);
            this.shownMsgId = 0; 
        },

        popup: function() {
            var model = new instance.web.Model('histest.message');
            var self = this;
            model.query().filter([['id','>',this.shownMsgId]]).all().done(function(results){
                if (results.length > 0) {
                    msgId = results[results.length-1].id;
                    self.do_action({
                        type: 'ir.actions.act_window',
                        res_model: "histest.message",
                        res_id: msgId,
                        views: [[false, 'form']],
                        target: 'new',
                        context: {},
                    });
                    self.shownMsgId = msgId;
                }
            });
        }
    });
};

histest_patient.hs

<syntaxhighligh lang="javascript"> openerp.histest.patient = function(instance) {

   instance.histest.indexAction = instance.web.Widget.extend({
       template: 'histest.index',
       events: {
           'click .oe_histest_patient_new_link': 'linkClick',
           'click .oe_histest_patient_query_link': 'patientQuery',
       },
       start: function() {
           var msgManager = new instance.histest.MsgManagerWidget(this);
           msgManager.appendTo('.oe_application');
       },
       patientQuery: function() {
           var model = new instance.web.Model('histest.patient');
           var self = this;
           self.$(".oe_histest_patient_results").html("");
           model.query().all().done(function(results) {
               for(var i=0; i < results.length; i++) {
                   self.$(".oe_histest_patient_results")

.append('

  • ' + results[i].first_name + '
  • '); } }); }, linkClick: function() { this.do_action({ type: 'ir.actions.act_window', res_model: 'histest.patient', views: false,'form', target: 'current', context: {}, }); } }); }; </syntaxhighlight>

    Responsive CSS

    เนื้อหาช่วงบ่าย

    เอกสารครั้งก่อน ๆ