19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -1,28 +1,30 @@
/** @odoo-module */
import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Many2OneField } from "@web/views/fields/many2one/many2one_field";
import { X2ManyField } from "@web/views/fields/x2many/x2many_field";
import { computeM2OProps, Many2One } from "@web/views/fields/many2one/many2one";
import { buildM2OFieldDescription, Many2OneField } from "@web/views/fields/many2one/many2one_field";
export class SoLineField extends Many2OneField {
setup() {
super.setup();
export class SoLineField extends Component {
static template = "sale_timesheet.SoLineField";
static components = { Many2One };
static props = { ...Many2OneField.props };
const update = this.update;
this.update = (value, params = {}) => {
update(value, params);
if ( // field is unset AND the old & new so_lines are different
!this.props.record.data.is_so_line_edited &&
this.props.value[0] != (value[0] && value[0].id)
) {
this.props.record.update({ is_so_line_edited: true });
}
get m2oProps() {
return {
...computeM2OProps(this.props),
update: (value) => {
this.props.record.update({ [this.props.name]: value });
if (
// field is unset AND the old & new so_lines are different
!this.props.record.data.is_so_line_edited &&
this.props.record.data[this.props.name].id != value.id
) {
this.props.record.update({ is_so_line_edited: true });
}
},
};
}
}
export class TimesheetsOne2ManyField extends X2ManyField {}
TimesheetsOne2ManyField.additionalClasses = ['o_field_one2many'];
registry.category("fields").add('so_line_one2many', TimesheetsOne2ManyField); // TODO: Remove me when the gantt view is converted in OWL
registry.category("fields").add("so_line_field", SoLineField);
registry.category("fields").add("so_line_field", {
...buildM2OFieldDescription(SoLineField),
});

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="sale_timesheet.SoLineField">
<Many2One t-props="m2oProps"/>
<span class="text-muted" t-out="this.props.record.fields[this.props.name].falsy_value_label" t-if="props.readonly and !props.record.data.so_line"/>
</t>
</templates>

View file

@ -1,47 +0,0 @@
odoo.define('sale_timesheet.so_line_many2one', function (require) {
"use strict";
const fieldRegistry = require('web.field_registry');
const { FieldOne2Many, FieldMany2One } = require('web.relational_fields');
const SoLineOne2Many = FieldOne2Many.extend({
_onFieldChanged: function (ev) {
if (
ev.data.changes &&
ev.data.changes.hasOwnProperty('timesheet_ids') &&
ev.data.changes.timesheet_ids.operation === 'UPDATE' &&
ev.data.changes.timesheet_ids.data &&
ev.data.changes.timesheet_ids.data.hasOwnProperty('so_line')) {
const line = this.value.data.find(line => {
return line.id === ev.data.changes.timesheet_ids.id;
});
if (!line.is_so_line_edited) {
ev.data.changes.timesheet_ids.data.is_so_line_edited = true;
}
}
this._super.apply(this, arguments);
}
});
const SoLineMany2one = FieldMany2One.extend({
/**
* @override
*
* When the user manually changes the field, we need to change the is_so_line_edited field in this model
* to know the changes is manual and not via a compute method.
*/
_onFieldChanged(ev) {
if (ev.data.changes && ev.data.changes.hasOwnProperty('so_line') && !ev.data.changes.so_line.is_so_line_edited) {
ev.data.changes.is_so_line_edited = true;
}
this._super.apply(this, arguments);
},
});
fieldRegistry.add('so_line_one2many', SoLineOne2Many);
fieldRegistry.add('so_line_field', SoLineMany2one);
return SoLineOne2Many;
});

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<button t-name="SaleProjectKanbanView.buttons" type="button" class="btn btn-secondary o_create_sale_order">
Create Sales Order
</button>
</templates>