summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index e10b4de2..ecaf9106 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -91,7 +91,8 @@ class ProductTemplate(models.Model):
group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
active_model = self.env.context.get('active_model')
- if self.env.user.id not in users_in_group.mapped('id') and active_model == None:
+ from_sourcing = self.env.context.get('from_sourcing_approval')
+ if self.env.user.id not in users_in_group.mapped('id') and active_model == None and not from_sourcing:
raise UserError('Hanya MD yang bisa membuat Product')
result = super(ProductTemplate, self).create(vals)
return result
@@ -940,9 +941,32 @@ class ProductProduct(models.Model):
qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant')
qty_pcs_box = fields.Float("Pcs Box")
barcode_box = fields.Char("Barcode Box")
- # keyword_id = fields.Many2one('keywords', string='Keyword')
+ keyword_id = fields.Many2one('keywords', string='Keyword')
+ sourcing_job_id = fields.Many2one(
+ "sourcing.job.order",
+ string="Sourcing Job",
+ readonly=True,
+ )
has_magento = fields.Boolean(string='Has Magento?', default=False, readonly=True)
+ def _add_product_to_keywords(self,product):
+ keywords_model = self.env['keywords']
+ if not product:
+ return False
+
+ for product in self:
+ match_keywords = keywords_model.search([
+ '|',
+ ('name', 'ilike', product.name),
+ ('keywords', 'ilike', product.website_description)
+ ])
+
+ for kw in match_keywords.filtered(lambda k: not k.skip):
+ if not self.unpublished and product.id not in kw.product_ids.ids:
+ kw.write({'product_ids': [(4, product.id)]})
+
+ return True
+
def generate_product_sla(self):
product_variant_ids = self.env.context.get('active_ids', [])
product_variant = self.search([('id', 'in', product_variant_ids)])
@@ -960,7 +984,8 @@ class ProductProduct(models.Model):
group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id
active_model = self.env.context.get('active_model')
users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])])
- if self.env.user.id not in users_in_group.mapped('id') and active_model == None:
+ from_sourcing = self.env.context.get('from_sourcing_approval')
+ if self.env.user.id not in users_in_group.mapped('id') and active_model == None and not from_sourcing:
raise UserError('Hanya MD yang bisa membuat Product')
result = super(ProductProduct, self).create(vals)
return result