summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-05-21 16:00:12 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-05-21 16:00:12 +0700
commit4f5594be8d73f88fbb42671525d0d2c6ed977abe (patch)
tree6d26829bc87af096a721613b853916eac5b9109c
parent04c3476f86c7499573f28aa603126481fe4e0daa (diff)
create function to update internal reference variants
-rwxr-xr-xindoteknik_custom/models/product_template.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 8494e18a..97ad07a7 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -350,6 +350,18 @@ class ProductProduct(models.Model):
is_edited = fields.Boolean(string='Is Edited')
qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
+ def update_internal_reference_variants(self, limit=100):
+ variants = self.env['product.product'].search([
+ ('default_code', '=', False),
+ ('type', '=', 'product'),
+ ('active', '=', True)
+ ], limit=limit, order='write_date desc')
+ for variant in variants:
+ if not variant.default_code:
+ variant.default_code = 'ITV.'+str(variant.id)
+
+ _logger.info('Updated variant %s' % variant.name)
+
def _get_po_suggest(self, qty_purchase):
if self.qty_available_bandengan < qty_purchase:
return 'harus beli'