diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-26 13:39:04 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-26 13:39:04 +0700 |
| commit | dd9a7582658e13d657393bd2fdecc5ab1d7fac0a (patch) | |
| tree | c78d6a9bd838cc9fc369b538f4deb1efb3a380a9 | |
| parent | ccd1d7bca71aadc54f9327d39e59180ee4c3a6c2 (diff) | |
add store column for stock vendor
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/stock_vendor.py | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 7b5d07f4..145d2076 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -31,6 +31,7 @@ class ProductTemplate(models.Model): product_rating = fields.Float('Product Rating', help="Digunakan untuk sorting product di website", default=0.0) last_calculate_rating = fields.Datetime("Last Calculate Rating") web_price_sorting = fields.Float('Web Price Sorting', help='Hanya digunakan untuk sorting di web, harga tidak berlaku', default=0.0) + qty_vendor = fields.Float(string='Qty Vendor') def _compute_qty_stock_vendor(self): for product_template in self: diff --git a/indoteknik_custom/models/stock_vendor.py b/indoteknik_custom/models/stock_vendor.py index 78baf14c..6f80a12e 100755 --- a/indoteknik_custom/models/stock_vendor.py +++ b/indoteknik_custom/models/stock_vendor.py @@ -1,4 +1,7 @@ from odoo import fields, models +import logging + +_logger = logging.getLogger(__name__) class StockVendor(models.Model): @@ -8,3 +11,13 @@ class StockVendor(models.Model): product_variant_id = fields.Many2one("product.product", string="Product Variant") quantity = fields.Integer(string="Quantity") + + def update_product_template(self): + stock_vendors = self.env['stock.vendor'].search([('quantity', '>', 0)]) + count = 0 + for stock in stock_vendors: + template = stock.product_variant_id.product_tmpl_id + template.qty_vendor = stock.quantity + _logger.info("Update Stock Vendor %s" % template.id) + count += 1 + _logger.info("CHECKED HERE - Stock Vendor Updated %s" % count) |
