diff -r a247523ff3db trytond/trytond/modules/sale_supply/__init__.py --- a/trytond/trytond/modules/sale_supply/__init__.py Mon May 06 15:14:01 2019 +0200 +++ b/trytond/trytond/modules/sale_supply/__init__.py Mon May 13 11:30:56 2019 +0200 @@ -16,6 +16,7 @@ purchase.Purchase, stock.ShipmentIn, product.Template, + product.TemplateSupplyOnSale, product.Product, module='sale_supply', type_='model') Pool.register( diff -r a247523ff3db trytond/trytond/modules/sale_supply/product.py --- a/trytond/trytond/modules/sale_supply/product.py Mon May 06 15:14:01 2019 +0200 +++ b/trytond/trytond/modules/sale_supply/product.py Mon May 13 11:29:50 2019 +0200 @@ -1,18 +1,35 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.model import fields -from trytond.pool import PoolMeta +from trytond.model import fields, ModelSQL +from trytond.pool import Pool, PoolMeta +from trytond.modules.company.model import (CompanyMultiValueMixin, + CompanyValueMixin) from trytond.pyson import Eval +supply_on_sale = fields.Boolean('Supply On Sale', states={ + 'invisible': ~Eval('purchasable') | ~Eval('salable'), + }, depends=['purchasable', 'salable']) -class Template(metaclass=PoolMeta): +class Template(CompanyMultiValueMixin, metaclass=PoolMeta): __name__ = 'product.template' - supply_on_sale = fields.Boolean('Supply On Sale', - states={ - 'invisible': ~Eval('purchasable') | ~Eval('salable'), - }, - depends=['purchasable', 'salable']) + supply_on_sale = fields.MultiValue(supply_on_sale) + supply_on_sales = fields.One2Many( + 'product.template.supply_on_sale', 'template', "Supply on sales") + + @classmethod + def multivalue_model(cls, field): + pool = Pool() + if field == 'supply_on_sale': + return pool.get('product.template.supply_on_sale') + return super(Template, cls).multivalue_model(field) + + +class TemplateSupplyOnSale(ModelSQL, CompanyValueMixin): + "Template Supply On Sale" + __name__ = 'product.template.supply_on_sale' + template = fields.Many2One('product.template', 'Product Template') + supply_on_sale = supply_on_sale class Product(metaclass=PoolMeta):