diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-11-17 11:15:47 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-11-17 11:15:47 +0700 |
| commit | dbd6731a446bc93a34b6f8389b865ebd94fbff95 (patch) | |
| tree | c06adf79f9a6995e86c7f0b2a1572c454d7272dc | |
| parent | 7f08a09863e6bd8771e1de943228abdaf019a698 (diff) | |
| parent | 390cc9e5b2e2b02eecb37472d4362c829a3745db (diff) | |
Merge branch 'master' of bitbucket.org:altafixco/indoteknik-addons
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 114899e6..743667cc 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -40,6 +40,30 @@ class ProductTemplate(models.Model): # vals['solr_flag'] = 2 # return super().write(vals) + def update_internal_reference(self): + templates_without_variant = self.env['product.template'].search([ + ('default_code', '=', False), + ('type', '=', 'product'), + ('active', '=', True), + ('product_variant_ids', '=', False), + ]) + for template_without_variant in templates_without_variant: + template_without_variant.default_code = 'IT.'+str(template_without_variant.id) + _logger.info('Updated Template %s' % template_without_variant.name) + + templates_with_variant = self.env['product.template'].search([ + ('default_code', '=', False), + ('type', '=', 'product'), + ('active', '=', True), + ('product_variant_ids', '!=', False), + ]) + for template_with_variant in templates_with_variant: + for product in template_with_variant.product_variant_ids: + if product.default_code: + continue + product.default_code = 'ITV.'+str(product.id) + _logger.info('Updated Variant %s' % product.name) + @api.onchange('name','default_code','x_manufacture','product_rating','website_description','image_1920','weight','public_categ_ids') def update_solr_flag(self): for tmpl in self: |
