Merge branch 'develop' into feature/流程用扫码完成

This commit is contained in:
胡尧
2024-09-13 08:53:16 +08:00
25 changed files with 1602 additions and 589 deletions

View File

@@ -4,6 +4,7 @@ from collections import defaultdict
from odoo import fields, models, api
from odoo.addons.resource.models.resource import Intervals
from odoo.exceptions import UserError, ValidationError
import math
class ResWorkcenter(models.Model):
@@ -195,7 +196,9 @@ class ResWorkcenter(models.Model):
def get_integer_and_decimal_parts(self, value):
integer_part = int(value)
decimal_part = value - integer_part
return int(integer_part), int(decimal_part)
if decimal_part > 0:
decimal_part = round(decimal_part, 2) * 60
return int(integer_part), math.ceil(decimal_part)
# 处理排程是否超过日产能
def deal_available_default_capacity(self, date_planned):
@@ -204,7 +207,8 @@ class ResWorkcenter(models.Model):
date_planned_end = date_planned_end.strftime('%Y-%m-%d')
plan_ids = self.env['sf.production.plan'].sudo().search([('date_planned_start', '>=', date_planned_start),
('date_planned_start', '<',
date_planned_end), ('state', '!=', 'draft')])
date_planned_end),
('state', 'not in', ['draft', 'cancel'])])
if plan_ids:
sum_qty = sum([p.product_qty for p in plan_ids])
if sum_qty >= self.default_capacity:
@@ -219,7 +223,8 @@ class ResWorkcenter(models.Model):
date_planned_end = date_planned_end.strftime('%Y-%m-%d %H:00:00')
plan_ids = self.env['sf.production.plan'].sudo().search([('date_planned_start', '>=', date_planned_start),
('date_planned_start', '<',
date_planned_end), ('state', '!=', 'draft')])
date_planned_end),
('state', 'not in', ['draft', 'cancel'])])
if plan_ids:
sum_qty = sum([p.product_qty for p in plan_ids])