1

我收到以下错误:找不到客户端操作eacta_previsionnel_hebdomadaire

XML 代码

<record id="eacta_previsionnel_report_action_client" model="ir.actions.client"  >
    <field name="name">Prévisionnel hebdomadaire</field>
    <field name="tag">eacta_previsionnel_hebdomadaire</field>
</record>

JS代码:

odoo.define('eacta_previsionnel.eacta_previsionnel_hebdomadaire', function (require) {
'use strict';

var core = require('web.core');
var Widget = require('web.Widget');
var ControlPanelMixin = require('web.ControlPanelMixin');
var AbstractAction = require('web.AbstractAction');
var SearchView = require('web.SearchView');
var data = require('web.data');
var pyeval = require('web.pyeval');
var field_utils = require('web.field_utils');
var session = require('web.session');
var datepicker = require('web.datepicker');

var QWeb = core.qweb;
var _t = core._t;

var ClientAction  = AbstractAction.extend(ControlPanelMixin, {
    custom_events: {
        search: '_onSearch',
    },

    events:{
        'change .o_eacta_date_start': 'on_change_date_start',
        'change .o_mps_save_input_text': 'save_line_prevision',
        'click .o_eacta_product_name': 'open_eacta_product',
        'click .o_eacta_variete_name': 'open_eacta_plantation',
        'click .o_eacta_next_week': 'on_click_next_week',
        'click .o_eacta_prev_week': 'on_click_prev_week',
    },
    init: function(parent, action) {
        this.actionManager = parent;
        this.action = action;
        this.domain = [];
        return this._super.apply(this, arguments);
    },
    render_search_view: function(){
        var self = this;
        var defs = [];
        this._rpc({
                model: 'ir.model.data',
                method: 'get_object_reference',
                args: ['eacta_mrp_base', 'eacta_search_mrp_farm_plantation'],
            })
            .then(function(view_id){
                self.dataset = new data.DataSetSearch(this, 'eacta.r.variete.serre.period');
                self.loadFieldView(self.dataset, view_id[1], 'search')
                .then(function (fields_view) {
                    self.fields_view = fields_view;
                    var options = {
                        $buttons: $("<div>"),
                        action: this.action,
                        disable_groupby: true,
                    };
                    self.searchview = new SearchView(self, self.dataset, self.fields_view, options);
                    self.searchview.appendTo($("<div>")).then(function () {
                        self.$searchview_buttons = self.searchview.$buttons.contents();
                        self.update_cp();
                        defs.push(self.update_cp());
                    });
                });
            });
    },
    willStart: function() {
        return this.get_html();
    },
    start: function() {
        var self = this;
        this.render_search_view();
        return this._super.apply(this, arguments).then(function () {
            self.$el.html(self.html);
        });
    },
    re_renderElement: function() {
        this.$el.html(this.html);
        this.update_cp();
    },
    open_eacta_product: function(e){
        this.do_action({
            type: 'ir.actions.act_window',
            res_model: "eacta.conf.culture",
            res_id: parseInt($(e.target).data('product')),
            views: [[false, 'form']],
        });
    },
    open_eacta_plantation: function(e){
        this.do_action({
            type: 'ir.actions.act_window',
            res_model: "eacta.r.variete.serre.period",
            res_id: parseInt($(e.target).data('plantation')),
            views: [[false, 'form']],
        });
    },
    save_line_prevision: function(e){
        var self = this;
        var $input = $(e.target);
        var target_value;
        try {
            target_value = field_utils.parse.float($input.val().replace(String.fromCharCode(8209), '-'));
        } catch(err) {
            return this.do_warn(_t("Wrong value entered!"), err);
        }
        return this._rpc({
            model: 'eacta.data.recolte.previsionnel',
            method: 'save_line_prevision',
            args: [field_utils.parse.float($input.val()), parseInt($input.data('plantation')),$input.data('date')],
        })
        .done(function(res){
            self.get_html().then(function() {
                self.re_renderElement();
                self.update_cp();
            });
        });
    },
    on_change_date_start: function(e){
        var self = this;
        var $input = $(".o_eacta_date_start").val();
        var target_value;
        try {
            if ($input == ''){
                this.do_warn(_t("Wrong value entered!"), "<ul><li>Date de debut</li></ul>");
                return;
            }
//            target_value = field_utils.format.date(field_utils.parse.date($input, {}, {isUTC: true}));
        } catch(err) {
            return this.do_warn(_t("Wrong value entered!"), err);
        }
        return this._rpc({
                model: 'eacta.previsionnel.hebdomadaire',
                method: 'search',
                args: [[]],
            })
            .then(function(res){
                return self._rpc({
                        model: 'eacta.previsionnel.hebdomadaire',
                        method: 'write',
                        args: [res, {'date_start': $input}],
                })
                .done(function(result){
                    self.get_html().then(function() {
                        self.re_renderElement();
                        self.update_cp();
                    });
                });
        });
    },
    on_click_next_week: function(e){
        var self = this;
        var date = self.operation_date("next",7);
        var max_next_date = new Date(date[2], parseInt(date[1])-1,date[0])
        var date_max = new Date($('.o_eacta_date_start').getAttributes()["date-max"]);
        if (max_next_date > date_max)
            $(".o_eacta_date_start").val(field_utils.parse.date(date_max).format('DD/MM/YYYY'));
        else
            $(".o_eacta_date_start").val(date[0] + "/" + date[1] + "/" + date[2]);
        self.on_change_date_start();
    },
    on_click_prev_week: function(e){
        var self = this;
        var date = self.operation_date("prev",7);
        var min_prev_date = new Date(date[2], parseInt(date[1])-1,date[0])
        var date_min = new Date($('.o_eacta_date_start').getAttributes()["date-min"]);
        if (min_prev_date < date_min)
            $(".o_eacta_date_start").val(field_utils.parse.date(date_min).format('DD/MM/YYYY'));
        else
            $(".o_eacta_date_start").val(date[0] + "/" + date[1] + "/" + date[2]);
        self.on_change_date_start();
    },
    operation_date: function(operation,nbr_day){
        var counter = 0;
        counter = counter + nbr_day;
        var today = new Date($(".o_eacta_date_start").datepicker( "getDate" ));
        if (operation == "next")
            today.setDate(today.getDate() + counter);
        else if (operation == "prev")
            today.setDate(today.getDate() - counter);
        var formattedDate = new Date(today);
        var d = ("0" + formattedDate.getDate()).slice(-2);
        var m = ("0" + (formattedDate.getMonth() + 1)).slice(-2);
        var y = formattedDate.getFullYear();
        return [d,m,y]
    },
    get_html: function() {
        var self = this;
        return this._rpc({
                model: 'eacta.previsionnel.hebdomadaire',
                method: 'get_html',
                args: [this.domain],
            })
            .then(function (result) {
                self.html = result.html;
                self.report_context = result.report_context;
            });
    },
    update_cp: function() {
        var self = this;
        self.readonly_input_previsionnel();
        self.enabled_input_previsionnel();
        self.sous_total_previsionnel();
        self.total_previsionnel();
        self.total_sous_total_previsionnel();
        self.visibility_icon_next();
        self.visibility_icon_prev();
        this.update_control_panel({
            breadcrumbs: this.actionManager.get_breadcrumbs(),
            cp_content: {
                $buttons: this.$buttons,
                $searchview: this.searchview.$el,
                // $searchview_buttons: this.$searchview_buttons,
                $searchview_buttons: this.$searchview_buttons
             },
             searchview: this.searchview,
        });
    },
    total_previsionnel: function() {
        $('.demand_forecast').each(function () {
            var sum = 0.00
            $(this).find('.text-right .o_mps_save_input_text').each(function () {
                sum += Number(field_utils.parse.float($(this).context.value));
            });
            $(this).find('.o_mps_save_input_text_total').html(field_utils.format.float(sum));
        });
    },
    sous_total_previsionnel: function(){
        var list_periode = [];
        var sum = 0.00;
        $('tr.demand_forecast:first td.text-right input').each(function () {
            list_periode.push($(this)[0].attributes['data-date'].value);
        });
        for (var i = 0;i< list_periode.length;i++){
            $('.demand_forecast') .parent() .each(function () {
                sum = 0.00;
                $(this).find('input[data-date='+list_periode[i]+']').each(function () {
                    sum += field_utils.parse.float($(this).context.value);
                });
                $(this).parent().find('span[class=o_eacta_sous_total][data-date='+list_periode[i]+']').html(field_utils.format.float(sum));
            });
        }
    },
    total_sous_total_previsionnel: function(){
        var sum = 0.00;
        $('.demand_forecast').parent().parent().each(function () {
            $(this).find('span[class=o_eacta_sous_total]').each(function () {
                sum += field_utils.parse.float($(this).text());
            });
            $(this).find('tr.active td:last .o_eacta_total_sous_total').html(field_utils.format.float(sum));
            sum = 0.00;
        });
    },
    enabled_input_previsionnel: function() {
        $('.demand_forecast').each(function () {
            $(this).find('.eacta_readonly').each(function () {
                $(this).prop('disabled', true);
                $(this).prop('readonly', true);
                $(this).css('background-color', 'transparent');
                $(this).css('color', '#AEA79F');
            });
        });
    },
    readonly_input_previsionnel: function() {
        $('.demand_forecast').each(function () {
            $(this).find('.eacta_input_span_readonly').each(function () {
                $(this).prop('disabled', true);
                $(this).prop('readonly', true);
                $(this).css('background-color', '#ffffff');
                $(this).css('border', 'medium none');
            });
        });
    },
    visibility_icon_next:function(){
        var self = this;
        var date = self.operation_date("next",7);
        var max_next_date = new Date(date[2], parseInt(date[1])-1,date[0])
        var date_max = new Date($('.o_eacta_date_start').getAttributes()["date-max"]);
        if (max_next_date > date_max)
            $('.o_eacta_next_week').css('visibility', 'hidden');
        else
            $('.o_eacta_next_week').css('visibility', 'visible');

    },
    visibility_icon_prev:function(){
        var self = this;
        var date = self.operation_date("prev",7);
        var min_prev_date = new Date(date[2], parseInt(date[1])-1,date[0])
        var date_min = new Date($('.o_eacta_date_start').getAttributes()["date-min"]);
        if (min_prev_date < date_min)
            $('.o_eacta_prev_week').css('visibility', 'hidden');
        else
            $('.o_eacta_prev_week').css('visibility', 'visible');
    },
    _onSearch: function (event) {
        var session = this.getSession();
        var result = pyeval.eval_domains_and_contexts({
            contexts: [session.user_context],
            domains: event.data.domains
        });
        this.domain = result.domain;
        this.update_cp();
        this.get_html().then(this.re_renderElement.bind(this));
    },
});

core.action_registry.add('eacta_previsionnel_hebdomadaire', ClientAction );
return ClientAction ;
});

我正在使用 Odoo 13 我在这里做错了什么?
如果您需要更多详细信息,请告诉我。
谢谢!

4

0 回答 0