mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
539e88c6f5
Since 72b2fb3ab3
Task #048598
72 lines
2.4 KiB
Diff
72 lines
2.4 KiB
Diff
diff --git a/__init__.py b/__init__.py
|
|
index c5c21fb..484a6de 100644
|
|
--- a/tryton/modules/sale_supply/__init__.py
|
|
+++ b/tryton/modules/sale_supply/__init__.py
|
|
@@ -14,6 +14,7 @@ def register():
|
|
purchase.Purchase,
|
|
stock.ShipmentIn,
|
|
product.Template,
|
|
+ product.TemplateSupplyOnSale,
|
|
product.Product,
|
|
module='sale_supply', type_='model')
|
|
Pool.register(
|
|
diff --git a/product.py b/product.py
|
|
index 08537ed..34ccc24 100644
|
|
--- a/tryton/modules/sale_supply/product.py
|
|
+++ b/tryton/modules/sale_supply/product.py
|
|
@@ -4,23 +4,34 @@
|
|
from sql import Literal
|
|
|
|
from trytond.i18n import gettext
|
|
-from trytond.model import fields
|
|
+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
|
|
from trytond.transaction import Transaction
|
|
|
|
|
|
-class Template(metaclass=PoolMeta):
|
|
+class Template(CompanyMultiValueMixin, metaclass=PoolMeta):
|
|
__name__ = 'product.template'
|
|
|
|
- supply_on_sale = fields.Selection([
|
|
+ supply_on_sale = fields.MultiValue(fields.Selection([
|
|
(None, "Never"),
|
|
('stock_first', "Stock First"),
|
|
('always', "Always"),
|
|
], "Supply On Sale",
|
|
states={
|
|
'invisible': ~Eval('purchasable') | ~Eval('salable'),
|
|
- })
|
|
+ }))
|
|
+ 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)
|
|
|
|
@classmethod
|
|
def __resgister__(cls, module):
|
|
@@ -71,5 +82,16 @@ class Template(metaclass=PoolMeta):
|
|
order_points=names))
|
|
|
|
|
|
+class TemplateSupplyOnSale(ModelSQL, CompanyValueMixin):
|
|
+ "Template Supply On Sale"
|
|
+ __name__ = 'product.template.supply_on_sale'
|
|
+ template = fields.Many2One('product.template', 'Product Template')
|
|
+ supply_on_sale = fields.Selection([
|
|
+ (None, "Never"),
|
|
+ ('stock_first', "Stock First"),
|
|
+ ('always', "Always"),
|
|
+ ], "Supply On Sale")
|
|
+
|
|
+
|
|
class Product(metaclass=PoolMeta):
|
|
__name__ = 'product.product'
|