Files
odoo_source/addons/stock/populate/product.py
T
Rémy Voet (ryv)andFeyensv 2c1823514c [IMP] product: product_* population
- Improve product.product & product category population: Add "random"
types, prices, and product categories to product. Specify some product
categories as children of others (populate the `parent_id` field).
- Provide product template and product attributes population
- product pricelist population

task-2446266

Co-authored-by: Feyensv <vfe@odoo.com>
2021-04-29 09:28:39 +00:00

26 lines
772 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.tools import populate
class ProductProduct(models.Model):
_inherit = 'product.product'
def _populate_get_types(self):
types, types_distribution = super()._populate_get_types()
return types + ["product"], types_distribution + [3]
def _populate_factories(self):
def get_tracking(values, counter, random):
if values['type'] == 'product':
return random.choices(['none', 'lot', 'serial'], [0.7, 0.2, 0.1])[0]
else:
return 'none'
return super()._populate_factories() + [
('tracking', populate.compute(get_tracking))
]