修改前暂存
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
'depends': ['sf_manufacturing'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/view.xml'
|
||||
'views/view.xml',
|
||||
'views/duration_view.xml'
|
||||
],
|
||||
|
||||
'assets': {
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import custom_plan
|
||||
from . import duration
|
||||
|
||||
25
sf_plan/models/duration.py
Normal file
25
sf_plan/models/duration.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import base64
|
||||
import json, requests
|
||||
from odoo import models, fields, api, _
|
||||
from datetime import datetime, timedelta
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class HoleDuration(models.Model):
|
||||
_name = 'hole.duration'
|
||||
_description = 'Hole Duration'
|
||||
|
||||
hole_diameter = fields.Selection([('3', '≤¢3'), ('6', '≤¢6'), ('10', '≤¢10'), ('12', '≤¢12'), ('16', '≤¢16'), ('25', '≤¢25')], string='孔径', required=True)
|
||||
name = fields.Char(string='名称', required=True, default='钻孔')
|
||||
hole_depth = fields.Selection([
|
||||
('10', '≤10'),
|
||||
('30', '≤30'),
|
||||
('50', '≤50'),
|
||||
('70', '≤70'),
|
||||
('90', '≤90'),
|
||||
('100', '≤100'),
|
||||
('120', '≤120'),
|
||||
('150', '≤150')], string='深度', required=True)
|
||||
working_hours = fields.Float(string='工时', required=True)
|
||||
hole_expansion = fields.Float(string='扩孔', required=True, default=0.6)
|
||||
@@ -1,6 +1,7 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,1,1,1
|
||||
access_sf_machine_schedule,sf.machine.schedule,model_sf_machine_schedule,base.group_user,1,1,1,1
|
||||
access_hole_duration,hole.duration,model_hole_duration,base.group_user,1,1,1,1
|
||||
|
||||
|
||||
|
||||
|
||||
|
52
sf_plan/views/duration_view.xml
Normal file
52
sf_plan/views/duration_view.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="hole_duration_tree" model="ir.ui.view">
|
||||
<field name="name">hole.duration.tree</field>
|
||||
<field name="model">hole.duration</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="孔加工">
|
||||
<field name="name"/>
|
||||
<field name="hole_diameter"/>
|
||||
<field name="hole_depth"/>
|
||||
<field name="working_hours"/>
|
||||
<field name="hole_expansion"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hole_duration_form" model="ir.ui.view">
|
||||
<field name="name">hole.duration.form</field>
|
||||
<field name="model">hole.duration</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="孔加工">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="hole_diameter"/>
|
||||
<field name="hole_depth"/>
|
||||
<field name="working_hours"/>
|
||||
<field name="hole_expansion"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hole_duration_action" model="ir.actions.act_window">
|
||||
<field name="name">孔加工</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hole.duration</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="hole_duration_menu"
|
||||
name="孔加工"
|
||||
sequence="900"
|
||||
action="hole_duration_action"
|
||||
parent="sf_production_plan_menu"
|
||||
/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -128,7 +128,7 @@
|
||||
decoration-success="state == 'done'"
|
||||
progress_bar="name"
|
||||
form_view_id="sf_production_plan_form"
|
||||
default_scale="week"
|
||||
default_scale="day"
|
||||
scales="day,week,month,year"
|
||||
precision="{'day': 'hour:quarter', 'week': 'day:half', 'month': 'day', 'year': 'month:quarter'}">
|
||||
<field name="shift"/>
|
||||
|
||||
@@ -684,10 +684,18 @@ export default AbstractRenderer.extend(WidgetAdapterMixin, {
|
||||
const stopDate = this.state.stopDate;
|
||||
let day = this.state.startDate;
|
||||
const dates = [];
|
||||
while (day <= stopDate) {
|
||||
dates.push(day);
|
||||
day = day.clone().add(1, token);
|
||||
if (this.state.scale == "day") {
|
||||
while (day <= stopDate) {
|
||||
dates.push(day);
|
||||
day = day.clone().add(8, token);
|
||||
}
|
||||
} else {
|
||||
while (day <= stopDate) {
|
||||
dates.push(day);
|
||||
day = day.clone().add(1, token);
|
||||
}
|
||||
}
|
||||
console.log(dates)
|
||||
return dates;
|
||||
},
|
||||
/**
|
||||
@@ -806,6 +814,7 @@ export default AbstractRenderer.extend(WidgetAdapterMixin, {
|
||||
* @override
|
||||
*/
|
||||
async _renderView() {
|
||||
console.log('this.state', this.state)
|
||||
const oldRowWidgets = Object.keys(this.rowWidgets).map((rowId) => {
|
||||
return this.rowWidgets[rowId];
|
||||
});
|
||||
|
||||
@@ -261,12 +261,18 @@ var GanttRow = Widget.extend({
|
||||
_adaptPills: function () {
|
||||
var self = this;
|
||||
var dateStartField = this.state.dateStartField;
|
||||
console.log("dateStartField",dateStartField)
|
||||
var dateStopField = this.state.dateStopField;
|
||||
console.log("dateStopField",dateStopField)
|
||||
var ganttStartDate = this.state.startDate;
|
||||
console.log("ganttStartDate",ganttStartDate)
|
||||
var ganttStopDate = this.state.stopDate;
|
||||
console.log("ganttStopDate",ganttStopDate)
|
||||
this.pills.forEach(function (pill) {
|
||||
var pillStartDate = self._convertToUserTime(pill[dateStartField]);
|
||||
console.log("pillStartDate",pillStartDate)
|
||||
var pillStopDate = self._convertToUserTime(pill[dateStopField]);
|
||||
console.log("pillStopDate",pillStopDate)
|
||||
if (pillStartDate < ganttStartDate) {
|
||||
pill.startDate = ganttStartDate;
|
||||
pill.disableStartResize = true;
|
||||
@@ -459,13 +465,44 @@ var GanttRow = Widget.extend({
|
||||
let margin;
|
||||
switch (self.state.scale) {
|
||||
case 'day':
|
||||
left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||
pill.leftMargin = (left / 60) * 100;
|
||||
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||
// console.log('left', left)
|
||||
// pill.leftMargin = (left / 60) * 100;
|
||||
// console.log('pill.leftMargin', pill.leftMargin)
|
||||
// diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
||||
// console.log('diff', diff)
|
||||
// var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - 1; // Eventually compensate border(s) width
|
||||
// console.log('gapSize', gapSize)
|
||||
// widthPill = (diff / 60) * 100;
|
||||
// console.log('widthPill', widthPill)
|
||||
// margin = pill.aggregatedPills ? 0 : 4;
|
||||
// console.log('margin', margin)
|
||||
// pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
|
||||
// console.log('pill.width', pill.width)
|
||||
// break;
|
||||
|
||||
left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
|
||||
console.log('left', left)
|
||||
left = (left / (8 * 60)) * 100; // 修改这里,以8小时为单位
|
||||
console.log('adjusted left', left)
|
||||
pill.leftMargin = left;
|
||||
|
||||
diff = pill.stopDate.diff(pill.startDate, 'minutes');
|
||||
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - 1; // Eventually compensate border(s) width
|
||||
widthPill = (diff / 60) * 100;
|
||||
console.log('diff', diff)
|
||||
diff = (diff / (8 * 60)) * 100; // 修改这里,以8小时为单位
|
||||
console.log('adjusted diff', diff)
|
||||
|
||||
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') / 8 - 1; // 修改这里,以8小时为单位
|
||||
console.log('gapSize', gapSize)
|
||||
|
||||
widthPill = diff;
|
||||
console.log('widthPill', widthPill)
|
||||
|
||||
margin = pill.aggregatedPills ? 0 : 4;
|
||||
console.log('margin', margin)
|
||||
|
||||
pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
|
||||
console.log('pill.width', pill.width)
|
||||
break;
|
||||
case 'week':
|
||||
case 'month':
|
||||
|
||||
@@ -76,8 +76,17 @@
|
||||
<div t-attf-class="col position-relative o_gantt_header_cell text-center p-2 #{isToday? 'o_gantt_today' : ''} ">
|
||||
<t t-if="widget.state.scale in formats" t-esc="slot.format(formats[widget.state.scale])"/>
|
||||
<small t-else="">
|
||||
<b t-esc="slot.format('k')"/>
|
||||
<span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/>
|
||||
<t t-if="slot.format('k') == 24">
|
||||
<div>夜班</div>
|
||||
</t>
|
||||
<t t-if="slot.format('k') == 8">
|
||||
<div>早班</div>
|
||||
</t>
|
||||
<t t-if="slot.format('k') == 16">
|
||||
<div>晚班</div>
|
||||
</t>
|
||||
<!-- <b t-esc="slot.format('k')"/> -->
|
||||
<!-- <span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/> -->
|
||||
</small>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user