mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] quality_control:
* Changed permissions * security modified * some demo info added * Added "partner_selectable" field, so that inspections can by made by partner * Little view fixing, field was oe_edit_only instead of label * Add partners to trigger lines * Tests added * Trigger lines with duplicated test cleaned
This commit is contained in:
@@ -5,6 +5,16 @@
|
||||
from openerp import models, fields
|
||||
|
||||
|
||||
def _filter_trigger_lines(trigger_lines):
|
||||
filtered_trigger_lines = []
|
||||
unique_tests = []
|
||||
for trigger_line in trigger_lines:
|
||||
if trigger_line.test not in unique_tests:
|
||||
filtered_trigger_lines.append(trigger_line)
|
||||
unique_tests.append(trigger_line.test)
|
||||
return filtered_trigger_lines
|
||||
|
||||
|
||||
class QcTriggerLine(models.AbstractModel):
|
||||
_name = "qc.trigger.line"
|
||||
_description = "Abstract line for defining triggers"
|
||||
@@ -14,8 +24,13 @@ class QcTriggerLine(models.AbstractModel):
|
||||
user = fields.Many2one(
|
||||
comodel_name='res.users', string='Responsible',
|
||||
track_visibility='always', default=lambda self: self.env.user)
|
||||
partners = fields.Many2many(
|
||||
comodel_name='res.partner', string='Partners',
|
||||
help='If filled, the test will only be created when the action is done'
|
||||
' for one of the specified partners. If empty, the test will be always'
|
||||
' created.', domain="[('parent_id', '=', False)]")
|
||||
|
||||
def get_trigger_line_for_product(self, trigger, product):
|
||||
def get_trigger_line_for_product(self, trigger, product, partner=False):
|
||||
"""Overridable method for getting trigger_line associated to a product.
|
||||
Each inherited model will complete this module to make the search by
|
||||
product, template or category.
|
||||
@@ -33,15 +48,18 @@ class QcTriggerProductCategoryLine(models.Model):
|
||||
|
||||
product_category = fields.Many2one(comodel_name="product.category")
|
||||
|
||||
def get_trigger_line_for_product(self, trigger, product):
|
||||
trigger_lines = super(QcTriggerProductCategoryLine,
|
||||
self).get_trigger_line_for_product(trigger,
|
||||
product)
|
||||
def get_trigger_line_for_product(self, trigger, product, partner=False):
|
||||
trigger_lines = super(
|
||||
QcTriggerProductCategoryLine,
|
||||
self).get_trigger_line_for_product(trigger, product,
|
||||
partner=partner)
|
||||
category = product.categ_id
|
||||
while category:
|
||||
for trigger_line in category.qc_triggers:
|
||||
if trigger_line.trigger.id == trigger.id:
|
||||
trigger_lines.add(trigger_line)
|
||||
for trigger_line in category.qc_triggers.filtered(
|
||||
lambda r: r.trigger == trigger and (
|
||||
not r.partners or not partner or
|
||||
partner.commercial_partner_id in r.partners)):
|
||||
trigger_lines.add(trigger_line)
|
||||
category = category.parent_id
|
||||
return trigger_lines
|
||||
|
||||
@@ -52,13 +70,16 @@ class QcTriggerProductTemplateLine(models.Model):
|
||||
|
||||
product_template = fields.Many2one(comodel_name="product.template")
|
||||
|
||||
def get_trigger_line_for_product(self, trigger, product):
|
||||
trigger_lines = super(QcTriggerProductTemplateLine,
|
||||
self).get_trigger_line_for_product(trigger,
|
||||
product)
|
||||
for trigger_line in product.product_tmpl_id.qc_triggers:
|
||||
if trigger_line.trigger.id == trigger.id:
|
||||
trigger_lines.add(trigger_line)
|
||||
def get_trigger_line_for_product(self, trigger, product, partner=False):
|
||||
trigger_lines = super(
|
||||
QcTriggerProductTemplateLine,
|
||||
self).get_trigger_line_for_product(trigger, product,
|
||||
partner=partner)
|
||||
for trigger_line in product.product_tmpl_id.qc_triggers.filtered(
|
||||
lambda r: r.trigger == trigger and (
|
||||
not r.partners or not partner or
|
||||
partner.commercial_partner_id in r.partners)):
|
||||
trigger_lines.add(trigger_line)
|
||||
return trigger_lines
|
||||
|
||||
|
||||
@@ -68,11 +89,14 @@ class QcTriggerProductLine(models.Model):
|
||||
|
||||
product = fields.Many2one(comodel_name="product.product")
|
||||
|
||||
def get_trigger_line_for_product(self, trigger, product):
|
||||
trigger_lines = super(QcTriggerProductLine,
|
||||
self).get_trigger_line_for_product(trigger,
|
||||
product)
|
||||
for trigger_line in product.qc_triggers:
|
||||
if trigger_line.trigger.id == trigger.id:
|
||||
trigger_lines.add(trigger_line)
|
||||
def get_trigger_line_for_product(self, trigger, product, partner=False):
|
||||
trigger_lines = super(
|
||||
QcTriggerProductLine,
|
||||
self).get_trigger_line_for_product(trigger, product,
|
||||
partner=partner)
|
||||
for trigger_line in product.qc_triggers.filtered(
|
||||
lambda r: r.trigger == trigger and (
|
||||
not r.partners or not partner or
|
||||
partner.commercial_partner_id in r.partners)):
|
||||
trigger_lines.add(trigger_line)
|
||||
return trigger_lines
|
||||
|
||||
Reference in New Issue
Block a user