mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 06:32:02 +02:00
Initial commit: Sale packages
This commit is contained in:
commit
14e3d26998
6469 changed files with 2479670 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
import { Many2OneField } from "@web/views/fields/many2one/many2one_field";
|
||||
import { X2ManyField } from "@web/views/fields/x2many/x2many_field";
|
||||
|
||||
export class SoLineField extends Many2OneField {
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
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 });
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
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;
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
.o_timesheet_accordion {
|
||||
.card-header {
|
||||
a {
|
||||
text-decoration: none;
|
||||
&:after {
|
||||
content: "\f0d7";
|
||||
font-family: 'FontAwesome';
|
||||
}
|
||||
&.collapsed:after {
|
||||
content: "\f0da";
|
||||
font-family: 'FontAwesome';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue