Odoo16_月份选择(owl)

发布时间 2023-04-11 17:57:36作者: 手可摘星辰。

1.js

/** @odoo-module **/

const { Component } = owl;
import { registry } from "@web/core/registry";


export class FsnMonth extends Component {

    setup() {
        super.setup();
    }

    onChangeValue(ev) {
        this.props.record.update({ [this.props.name]: ev.target.value });
    }
    
}
FsnMonth.template = "fsn_month_template"


registry.category("fields").add("fsn_month", FsnMonth);

2.xml

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
    <t t-name="fsn_month_template" owl="1">
        <input type="month" t-att-value="this.props.value" t-on-change="(ev) => this.onChangeValue(ev)"/>
    </t>
</templates>

3.导入资源

    'assets': {
        'web.assets_backend': [
            'my_widget/static/src/components/temp/temp.js',
            'my_widget/static/src/components/temp/temp.xml'
        ],
    },