diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2026-03-11 13:10:18 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2026-03-11 13:10:18 +0000 |
| commit | 281ef9da5abb74b1d38dd7f7ea07c0f02e47b992 (patch) | |
| tree | ba8bd1521c10ac78e45a6e6481b6d651a69fc606 /indoteknik_custom/models/product_template.py | |
| parent | e6b6691f518a7400babdbd4b95541fb3d07f154d (diff) | |
| parent | 715a60d3dce76a253afd2b119e0e800a230dd24d (diff) | |
Merged in CR/Sourcing-Job (pull request #496)
CR/Sourcing Job
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 31 |
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 |
