需求计划供货方式修改
This commit is contained in:
@@ -9,11 +9,6 @@ class SfDemandPlan(models.Model):
|
||||
_name = 'sf.demand.plan'
|
||||
_description = 'sf_demand_plan'
|
||||
|
||||
def _get_machining_precision(self):
|
||||
machinings = self.env['sf.machining.accuracy'].sudo().search([])
|
||||
list = [(m.sync_id, m.name) for m in machinings]
|
||||
return list
|
||||
|
||||
state = fields.Selection([
|
||||
('10', '需求确认'),
|
||||
('20', '待工艺设计'),
|
||||
@@ -64,9 +59,7 @@ class SfDemandPlan(models.Model):
|
||||
compute='_compute_model_process_parameters_ids'
|
||||
, store=True
|
||||
)
|
||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='精度',
|
||||
related='product_id.model_machining_precision')
|
||||
|
||||
model_machining_precision = fields.Selection(related='product_id.model_machining_precision', string='精度')
|
||||
inventory_quantity_auto_apply = fields.Float(
|
||||
string="成品库存",
|
||||
compute='_compute_inventory_quantity_auto_apply', store=True
|
||||
@@ -85,6 +78,12 @@ class SfDemandPlan(models.Model):
|
||||
default=False
|
||||
)
|
||||
|
||||
readonly_custom_made_type = fields.Boolean(
|
||||
string='字段自制类型只读',
|
||||
compute='_compute_readonly_custom_made_type',
|
||||
default=False
|
||||
)
|
||||
|
||||
@api.depends('product_id.part_number', 'product_id.model_name')
|
||||
def _compute_part_number(self):
|
||||
for line in self:
|
||||
@@ -181,17 +180,18 @@ class SfDemandPlan(models.Model):
|
||||
else:
|
||||
line.state = '10'
|
||||
|
||||
@api.depends('line_ids.status')
|
||||
def _compute_readonly_custom_made_type(self):
|
||||
for line in self:
|
||||
production_demand_plan = line.line_ids.filtered(
|
||||
lambda p: p.status in ('50', '60') and p.new_supply_method == 'custom_made')
|
||||
line.readonly_custom_made_type = bool(production_demand_plan)
|
||||
|
||||
def write(self, vals):
|
||||
res = super(SfDemandPlan, self).write(vals)
|
||||
line_ids = self.line_ids.filtered(lambda p: p.plan_uom_qty == 0 or p.plan_uom_qty < 0)
|
||||
if line_ids:
|
||||
raise ValidationError(f"计划量不能小于等于0")
|
||||
if 'line_ids' in vals:
|
||||
for line in self.line_ids:
|
||||
if not line.sale_order_id:
|
||||
line.sale_order_id = self.sale_order_id
|
||||
if not line.sale_order_line_id:
|
||||
line.sale_order_line_id = self.sale_order_line_id
|
||||
return res
|
||||
|
||||
def name_get(self):
|
||||
|
||||
Reference in New Issue
Block a user