diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2026-03-12 09:04:08 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2026-03-12 09:04:08 +0700 |
| commit | b0583d9afe66887e53aa2ea80f1701b892fbf67f (patch) | |
| tree | f752a7898b3572b5a0b1d3d346622a3f7cbaa001 /indoteknik_custom/models/product_template.py | |
| parent | 08c93fcf63a23eddae47b56863e4b90b022c87b5 (diff) | |
| parent | 1ee6bd364ff290a3d8dddc6e9b599e52f8f66c4a (diff) | |
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
matches so
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 |
