开发sf制造模块权限角色
This commit is contained in:
@@ -97,12 +97,15 @@ class QualityPoint(models.Model):
|
||||
component_ids = fields.One2many('product.product', compute='_compute_component_ids')
|
||||
product_ids = fields.Many2many(
|
||||
default=_default_product_ids,
|
||||
domain="operation_id and [('id', 'in', bom_product_ids)] or [('type', 'in', ('product', 'consu')), '|', ('company_id', '=', False), ('company_id', '=', company_id)]")
|
||||
domain="operation_id and [('id', 'in', bom_product_ids)] or"
|
||||
" [('type', 'in', ('product', 'consu')),"
|
||||
" '|', ('company_id', '=', False), ('company_id', '=', company_id)]")
|
||||
bom_product_ids = fields.One2many('product.product', compute="_compute_bom_product_ids")
|
||||
test_type_id = fields.Many2one(
|
||||
'quality.point.test_type',
|
||||
domain="[('allow_registration', '=', operation_id and is_workorder_step)]")
|
||||
test_report_type = fields.Selection([('pdf', 'PDF'), ('zpl', 'ZPL')], string="Report Type", default="pdf", required=True)
|
||||
test_report_type = fields.Selection([('pdf', 'PDF'), ('zpl', 'ZPL')], string="Report Type",
|
||||
default="pdf", required=True)
|
||||
source_document = fields.Selection(
|
||||
selection=[('operation', 'Specific Page of Operation Worksheet'), ('step', 'Custom')],
|
||||
string="Step Document",
|
||||
@@ -125,20 +128,23 @@ class QualityPoint(models.Model):
|
||||
points_for_workorder_step = self.filtered(lambda p: p.operation_id and p.bom_id)
|
||||
for point in points_for_workorder_step:
|
||||
bom_product_ids = point.bom_id.product_id or point.bom_id.product_tmpl_id.product_variant_ids
|
||||
point.bom_product_ids = bom_product_ids.filtered(lambda p: not p.company_id or p.company_id == point.company_id._origin)
|
||||
point.bom_product_ids = bom_product_ids.filtered(lambda p: not p.company_id or
|
||||
p.company_id == point.company_id._origin)
|
||||
|
||||
@api.depends('product_ids', 'test_type_id', 'is_workorder_step')
|
||||
def _compute_component_ids(self):
|
||||
self.component_ids = False
|
||||
for point in self:
|
||||
if not point.is_workorder_step or not self.bom_id or point.test_type not in ('register_consumed_materials', 'register_byproducts'):
|
||||
if not point.is_workorder_step or not self.bom_id or point.test_type not in ('register_consumed_materials',
|
||||
'register_byproducts'):
|
||||
point.component_id = None
|
||||
continue
|
||||
if point.test_type == 'register_byproducts':
|
||||
point.component_ids = point.bom_id.byproduct_ids.product_id
|
||||
else:
|
||||
bom_products = point.bom_id.product_id or point.bom_id.product_tmpl_id.product_variant_ids
|
||||
# If product_ids is set the step will exist only for these product variant then we can filter out for the bom explode
|
||||
# If product_ids is set the step will exist only for these product variant then we can filter
|
||||
# out for the bom explode
|
||||
if point.product_ids:
|
||||
bom_products &= point.product_ids._origin
|
||||
|
||||
@@ -183,7 +189,8 @@ class QualityCheck(models.Model):
|
||||
|
||||
workorder_id = fields.Many2one(
|
||||
'mrp.workorder', 'Operation', check_company=True)
|
||||
workcenter_id = fields.Many2one('mrp.workcenter', related='workorder_id.workcenter_id', store=True, readonly=True) # TDE: necessary ?
|
||||
workcenter_id = fields.Many2one('mrp.workcenter', related='workorder_id.workcenter_id', store=True,
|
||||
readonly=True) # TDE: necessary ?
|
||||
production_id = fields.Many2one(
|
||||
'mrp.production', 'Production Order', check_company=True)
|
||||
|
||||
@@ -201,12 +208,14 @@ class QualityCheck(models.Model):
|
||||
component_uom_id = fields.Many2one('uom.uom', related='move_id.product_uom', readonly=True)
|
||||
|
||||
qty_done = fields.Float('Done', digits='Product Unit of Measure')
|
||||
finished_lot_id = fields.Many2one('stock.lot', 'Finished Lot/Serial', related='production_id.lot_producing_id', store=True)
|
||||
finished_lot_id = fields.Many2one('stock.lot', 'Finished Lot/Serial', related='production_id.lot_producing_id',
|
||||
store=True)
|
||||
additional = fields.Boolean('Register additional product', compute='_compute_additional')
|
||||
component_tracking = fields.Selection(related='component_id.tracking', string="Is Component Tracked")
|
||||
|
||||
# Workorder specific fields
|
||||
component_remaining_qty = fields.Float('Remaining Quantity for Component', compute='_compute_component_data', digits='Product Unit of Measure')
|
||||
component_remaining_qty = fields.Float('Remaining Quantity for Component', compute='_compute_component_data',
|
||||
digits='Product Unit of Measure')
|
||||
component_qty_to_do = fields.Float(compute='_compute_component_qty_to_do')
|
||||
is_user_working = fields.Boolean(related="workorder_id.is_user_working")
|
||||
consumption = fields.Selection(related="workorder_id.consumption")
|
||||
@@ -241,7 +250,8 @@ class QualityCheck(models.Model):
|
||||
super()._compute_title()
|
||||
for check in self:
|
||||
if not check.point_id or check.component_id:
|
||||
check.title = '{} "{}"'.format(check.test_type_id.display_name, check.component_id.name or check.workorder_id.name)
|
||||
check.title = '{} "{}"'.format(check.test_type_id.display_name, check.component_id.name
|
||||
or check.workorder_id.name)
|
||||
|
||||
@api.depends('point_id', 'quality_state', 'component_id', 'component_uom_id', 'lot_id', 'qty_done')
|
||||
def _compute_result(self):
|
||||
@@ -266,7 +276,8 @@ class QualityCheck(models.Model):
|
||||
|
||||
def _get_check_result(self):
|
||||
if self.test_type in ('register_consumed_materials', 'register_byproducts') and self.lot_id:
|
||||
return '{} - {}, {} {}'.format(self.component_id.name, self.lot_id.name, self.qty_done, self.component_uom_id.name)
|
||||
return '{} - {}, {} {}'.format(self.component_id.name, self.lot_id.name, self.qty_done,
|
||||
self.component_uom_id.name)
|
||||
elif self.test_type in ('register_consumed_materials', 'register_byproducts'):
|
||||
return '{}, {} {}'.format(self.component_id.name, self.qty_done, self.component_uom_id.name)
|
||||
else:
|
||||
@@ -281,12 +292,14 @@ class QualityCheck(models.Model):
|
||||
for check in self:
|
||||
if check.test_type in ('register_byproducts', 'register_consumed_materials'):
|
||||
if check.quality_state == 'none':
|
||||
completed_lines = check.workorder_id.move_line_ids.filtered(lambda l: l.lot_id) if check.component_id.tracking != 'none' else check.workorder_id.move_line_ids
|
||||
completed_lines = check.workorder_id.move_line_ids.filtered(lambda l: l.lot_id)\
|
||||
if check.component_id.tracking != 'none' else check.workorder_id.move_line_ids
|
||||
if check.move_id.additional:
|
||||
qty = check.workorder_id.qty_remaining
|
||||
else:
|
||||
qty = check.workorder_id.qty_producing
|
||||
check.component_remaining_qty = self._prepare_component_quantity(check.move_id, qty) - sum(completed_lines.mapped('qty_done'))
|
||||
check.component_remaining_qty = self._prepare_component_quantity(check.move_id, qty) -\
|
||||
sum(completed_lines.mapped('qty_done'))
|
||||
check.component_uom_id = check.move_id.product_uom
|
||||
|
||||
def action_print(self):
|
||||
@@ -369,7 +382,8 @@ class QualityCheck(models.Model):
|
||||
vals_list = []
|
||||
# apply putaway
|
||||
location_dest_id = self.move_id.location_dest_id._get_putaway_strategy(self.move_id.product_id)
|
||||
quants = self.env['stock.quant']._gather(self.product_id, self.move_id.location_id, lot_id=self.lot_id, strict=False)
|
||||
quants = self.env['stock.quant']._gather(self.product_id, self.move_id.location_id, lot_id=self.lot_id,
|
||||
strict=False)
|
||||
# Search for a sub-locations where the product is available.
|
||||
# Loop on the quants to get the locations. If there is not enough
|
||||
# quantity into stock, we take the move location. Anyway, no
|
||||
@@ -386,7 +400,8 @@ class QualityCheck(models.Model):
|
||||
for quant in quants:
|
||||
vals = shared_vals.copy()
|
||||
quantity = quant.quantity - quant.reserved_quantity
|
||||
quantity = self.product_id.uom_id._compute_quantity(quantity, self.product_uom_id, rounding_method='HALF-UP')
|
||||
quantity = self.product_id.uom_id._compute_quantity(quantity, self.product_uom_id,
|
||||
rounding_method='HALF-UP')
|
||||
rounding = quant.product_uom_id.rounding
|
||||
if (float_compare(quant.quantity, 0, precision_rounding=rounding) <= 0 or
|
||||
float_compare(quantity, 0, precision_rounding=self.product_uom_id.rounding) <= 0):
|
||||
@@ -469,7 +484,8 @@ class QualityCheck(models.Model):
|
||||
|
||||
def _update_component_quantity(self):
|
||||
if self.component_tracking == 'serial':
|
||||
self._origin.qty_done = self.component_id.uom_id._compute_quantity(1, self.component_uom_id, rounding_method='HALF-UP')
|
||||
self._origin.qty_done = self.component_id.uom_id._compute_quantity(1, self.component_uom_id,
|
||||
rounding_method='HALF-UP')
|
||||
return
|
||||
move = self.move_id
|
||||
# Compute the new quantity for the current component
|
||||
|
||||
Reference in New Issue
Block a user