Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
7019 มุมมอง

I'm getting this error after I have set the setting for the first time. It happens whenever accessing the settings menu.

Full Error Log:
https://lbwebsites.me/web/static/src/js/fields/basic_fields.js:814
Traceback:
Error: "30" is not an integer or a virtual id
    at Class._formatValue (https://lbwebsites.me/web/static/src/js/fields/basic_fields.js:814:23)
    at Class.prototype.<computed> [as _formatValue] (https://lbwebsites.me/web/static/src/js/core/class.js:90:38)
    at Class._prepareInput (https://lbwebsites.me/web/static/src/js/fields/basic_fields.js:247:30)
    at Class._renderEdit (https://lbwebsites.me/web/static/src/js/fields/basic_fields.js:259:14)
    at Class._render (https://lbwebsites.me/web/static/src/js/fields/abstract_field.js:353:25)
    at https://lbwebsites.me/web/static/src/js/fields/abstract_field.js:187:25
    at https://lbwebsites.me/web/static/lib/jquery/jquery.js:3276:89
    at fire (https://lbwebsites.me/web/static/lib/jquery/jquery.js:3119:58)
    at Object.add [as done] (https://lbwebsites.me/web/static/lib/jquery/jquery.js:3165:49)
    at Array.<anonymous> (https://lbwebsites.me/web/static/lib/jquery/jquery.js:3275:77)
Model
default_quote_valid_to = fields.Integer(string="Default Quote Valid to Days")
get_values method (appears to be the issue)
@api.model
def get_values(self):
    res = super(ResConfigSettings, self).get_values()
    ICPSudo = self.env['ir.config_parameter'].sudo()
    res.update(
        default_quote_valid_to = ICPSudo.get_param('quote.default_quote_valid_to', default=30),
    )
    return res

Edit: also the view where the field is displayed:
<div class="row mt16 o_settings_container">
    <div class="col-12 col-lg-6 o_setting_box" id="quotes">
        <div class="o_setting_left_pane">
            <field name="default_quote_valid_to" widget="integer"/>
        </div>
        <div class="o_setting_right_pane">
            <label for="default_quote_valid_to"/>
            <div class="text-muted">
                Set the default value of the days a quote is available to.
            </div>
        </div>
    </div>
</div>


Edit 2: this is a bespoke quote module not the built in one

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Please write as following because your field is integer so value must be integer. 

@api.model
def get_values(self):
    res = super(ResConfigSettings, self).get_values()
    ICPSudo = self.env['ir.config_parameter'].sudo()
    res.update(
        default_quote_valid_to = int(ICPSudo.get_param('quote.default_quote_valid_to', default=30)),
    )
    return res


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Have the same issue. As a temporal solution I made all my settings fields Char.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Levi: If you are interested in setting the number of days for which a Quotation is valid, you can set it in Settings > General Settings. The setting is also available in Quotation Templates if you need different validity periods.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank you Paresh W however i forgot to mention that it is actually a bespoke quote module so using that will not work for me

Edit:

My only temporary fix was to change the JavaScript that handles the fields, as it was using regex to check if it was and Integer so i changed it to convert the string to int and check if it was NaN

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
6
มี.ค. 24
22755
2
ต.ค. 17
11600
1
พ.ค. 16
5268
INSTALL A MODULE BASED ON CHECKBOX VALUE แก้ไขแล้ว
1
ก.พ. 24
2255
1
มี.ค. 15
8608