+2 votes
22 views

I have a custom section called layout_category_id, which lists a series of items. The mentioned items are 4 in total and each one has its respective id. What I am trying to do is that when the id of layout_category_id is different from 1, no discount can be applied.

I made a code in js that makes that comparison that works only at a visual level ... well, even if the discount is assigned or equal, it continues to apply the discount if it was previously added.

`

_computeAggregates: function () {
        var self = this;
        var data = [];
        var datos = 0;
        try {
            datos = this.state.data.length;
            if (datos >= 0) {
                for (var i = 0; i < datos; i++) {
                    if (this.state.data[i]['data'].layout_category_id.data) {
                        // preguntamos si es distinto a alquileres
                        if (this.state.data[i]['data'].layout_category_id.data.id != 1) {
                            this.state.data[i]['data']['discount'] = 0.00;
                        }
                        // console.log(this.state.data[i]['data']);
                    } 
                }
            }
        } catch(err) {
          console.log(err.message);
        }
        if (this.selection.length) {
            console.log('entro mal');
            utils.traverse_records(this.state, function (record) {
                if (_.contains(self.selection, record.id)) {
                    data.push(record); // find selected records
                }
            });
        } else {
            // xnet
            data = this.state.data;
        }
        _.each(this.columns, this._computeColumnAggregates.bind(this, data));
    },

`

Initially I wanted to do it in XML in this way but obviously it did not work <field t-if="layout_category_id == 1" name="discount" class="descuento" groups="sale.group_discount_per_so_line"/> 

Photo Link

in Back-end by (10.3k points) | 22 views

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
193 questions
174 answers
33 comments
80,668 users