diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/product/populate | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/product/populate')
| -rw-r--r-- | addons/product/populate/__init__.py | 4 | ||||
| -rw-r--r-- | addons/product/populate/product.py | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/addons/product/populate/__init__.py b/addons/product/populate/__init__.py new file mode 100644 index 00000000..3d587b16 --- /dev/null +++ b/addons/product/populate/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import product diff --git a/addons/product/populate/product.py b/addons/product/populate/product.py new file mode 100644 index 00000000..ed61c259 --- /dev/null +++ b/addons/product/populate/product.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +import logging + +from odoo import models +from odoo.tools import populate + +_logger = logging.getLogger(__name__) + + +class ProductCategory(models.Model): + _inherit = "product.category" + _populate_sizes = {"small": 50, "medium": 500, "large": 30000} + + def _populate_factories(self): + def get_name(values=None, counter=0, complete=False, **kwargs): + return "%s_%s_%s" % ("product_category", int(complete), counter) + + # quid of parent_id ??? + + return [("name", populate.compute(get_name))] + + +class ProductProduct(models.Model): + _inherit = "product.product" + _populate_sizes = {"small": 150, "medium": 5000, "large": 60000} + + def _populate_factories(self): + + return [ + ("name", populate.constant('product_template_name_{counter}')), + ("sequence", populate.randomize([False] + [i for i in range(1, 101)])), + ("description", populate.constant('product_template_description_{counter}')), + ("default_code", populate.constant('product_default_code_{counter}')), + ("active", populate.randomize([True, False], [0.8, 0.2])), + ] |
