Remove Property fields

issue2349
review35331002
This commit is contained in:
Cédric Krier
2017-04-01 00:32:16 +02:00
parent e8a8eed39b
commit 2314ef1d7f
3 changed files with 23 additions and 39 deletions
+1 -2
View File
@@ -2,13 +2,12 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .ir import *
from .product import *
def register():
Pool.register(
Property,
ProductCostPrice,
ProductCostHistory,
module='product_cost_history', type_='model')
Pool.register(
-11
View File
@@ -1,11 +0,0 @@
# 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.pool import PoolMeta
__all__ = ['Property']
class Property:
__metaclass__ = PoolMeta
__name__ = 'ir.property'
_history = True
+22 -26
View File
@@ -3,15 +3,20 @@
from sql import Column
from sql.aggregate import Max
from sql.conditionals import Coalesce
from sql.functions import Trim, Substring
from trytond.model import ModelView, ModelSQL, fields
from trytond.wizard import Wizard, StateAction
from trytond.pyson import PYSONEncoder
from trytond.pool import Pool
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
__all__ = ['ProductCostHistory', 'OpenProductCostHistory']
__all__ = ['ProductCostPrice', 'ProductCostHistory', 'OpenProductCostHistory']
class ProductCostPrice:
__metaclass__ = PoolMeta
__name__ = 'product.cost_price'
_history = True
class ProductCostHistory(ModelSQL, ModelView):
@@ -30,29 +35,20 @@ class ProductCostHistory(ModelSQL, ModelView):
@classmethod
def table_query(cls):
pool = Pool()
Property = pool.get('ir.property')
Field = pool.get('ir.model.field')
property_history = Property.__table_history__()
field = Field.__table__()
return property_history.join(field,
condition=field.id == property_history.field
).select(Max(Column(property_history, '__id')).as_('id'),
Max(property_history.create_uid).as_('create_uid'),
Max(property_history.create_date).as_('create_date'),
Max(property_history.write_uid).as_('write_uid'),
Max(property_history.write_date).as_('write_date'),
Coalesce(property_history.write_date,
property_history.create_date).as_('date'),
Trim(Substring(property_history.res, ',.*'), 'LEADING', ','
).cast(cls.template.sql_type().base).as_('template'),
Trim(property_history.value, 'LEADING', ','
).cast(cls.cost_price.sql_type().base).as_('cost_price'),
where=(field.name == 'cost_price')
& property_history.res.like('product.template,%'),
group_by=(property_history.id,
Coalesce(property_history.write_date,
property_history.create_date),
property_history.res, property_history.value))
ProductCostPrice = pool.get('product.cost_price')
history = ProductCostPrice.__table_history__()
return history.select(Max(Column(history, '__id')).as_('id'),
Max(history.create_uid).as_('create_uid'),
Max(history.create_date).as_('create_date'),
Max(history.write_uid).as_('write_uid'),
Max(history.write_date).as_('write_date'),
Coalesce(history.write_date,
history.create_date).as_('date'),
history.template.as_('template'),
history.cost_price.as_('cost_price'),
group_by=(history.id,
Coalesce(history.write_date, history.create_date),
history.template, history.cost_price))
class OpenProductCostHistory(Wizard):