Remove Property fields
issue2349 review36271002
This commit is contained in:
1 parent
efbe15bfb3
commit
a0499d9c7f
5 files changed
+149
-33
No files matched your search
@@ -11,13 +11,16 @@ from .party import PartyReplace
|
||||
def register():
|
||||
Pool.register(
|
||||
Configuration,
|
||||
ConfigurationSequence,
|
||||
ShipmentDrop,
|
||||
Move,
|
||||
SaleConfig,
|
||||
SaleConfigSaleDropLocation,
|
||||
Sale,
|
||||
SaleLine,
|
||||
PurchaseRequest,
|
||||
PurchaseConfig,
|
||||
PurchaseConfigPurchaseDropLocation,
|
||||
Purchase,
|
||||
PurchaseLine,
|
||||
ProductSupplier,
|
||||
|
||||
+45
-5
@@ -1,13 +1,18 @@
|
||||
# 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 import backend
|
||||
from trytond.model import ModelSQL, ValueMixin, fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.tools.multivalue import migrate_property
|
||||
|
||||
|
||||
__all__ = ['PurchaseRequest', 'PurchaseConfig', 'Purchase', 'PurchaseLine',
|
||||
__all__ = ['PurchaseRequest', 'PurchaseConfig',
|
||||
'PurchaseConfigPurchaseDropLocation', 'Purchase', 'PurchaseLine',
|
||||
'ProductSupplier', 'CreatePurchase', 'PurchaseHandleShipmentException']
|
||||
purchase_drop_location = fields.Many2One(
|
||||
'stock.location', "Purchase Drop Location", domain=[('type', '=', 'drop')])
|
||||
|
||||
|
||||
class PurchaseRequest:
|
||||
@@ -31,9 +36,44 @@ class PurchaseConfig:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'purchase.configuration'
|
||||
|
||||
purchase_drop_location = fields.Property(
|
||||
fields.Many2One('stock.location', 'Purchase Drop Location',
|
||||
domain=[('type', '=', 'drop')]))
|
||||
purchase_drop_location = fields.MultiValue(purchase_drop_location)
|
||||
|
||||
@classmethod
|
||||
def default_purchase_drop_location(cls, **pattern):
|
||||
return cls.multivalue_model(
|
||||
'purchase_drop_location').default_purchase_drop_location()
|
||||
|
||||
|
||||
class PurchaseConfigPurchaseDropLocation(ModelSQL, ValueMixin):
|
||||
"Purchase Configuration Purchase Drop Location"
|
||||
__name__ = 'purchase.configuration.purchase_drop_location'
|
||||
purchase_drop_location = purchase_drop_location
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
exist = TableHandler.table_exist(cls._table)
|
||||
|
||||
super(PurchaseConfigPurchaseDropLocation, cls).__register__(
|
||||
module_name)
|
||||
|
||||
if not exist:
|
||||
cls._migrate_property([], [], [])
|
||||
|
||||
@classmethod
|
||||
def _migrate_property(cls, field_names, value_names, fields):
|
||||
field_names.append('purchase_drop_location')
|
||||
value_names.append('purchase_drop_location')
|
||||
migrate_property(
|
||||
'purchase.configuration', field_names, cls, value_names,
|
||||
fields=fields)
|
||||
|
||||
@classmethod
|
||||
def default_purchase_drop_location(cls):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
return ModelData.get_id(
|
||||
'sale_supply_drop_shipment', 'location_drop')
|
||||
|
||||
|
||||
class Purchase:
|
||||
|
||||
@@ -1,20 +1,59 @@
|
||||
# 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 import backend
|
||||
from trytond.model import ModelSQL, ValueMixin, fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.tools.multivalue import migrate_property
|
||||
|
||||
__all__ = ['SaleConfig', 'Sale', 'SaleLine']
|
||||
__all__ = ['SaleConfig', 'SaleConfigSaleDropLocation', 'Sale', 'SaleLine']
|
||||
sale_drop_location = fields.Many2One(
|
||||
'stock.location', "Sale Drop Location", domain=[('type', '=', 'drop')])
|
||||
|
||||
|
||||
class SaleConfig:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'sale.configuration'
|
||||
|
||||
sale_drop_location = fields.Property(
|
||||
fields.Many2One('stock.location', 'Sale Drop Location',
|
||||
domain=[('type', '=', 'drop')]))
|
||||
sale_drop_location = fields.MultiValue(sale_drop_location)
|
||||
|
||||
@classmethod
|
||||
def default_sale_drop_location(cls, **pattern):
|
||||
return cls.multivalue_model(
|
||||
'sale_drop_location').default_sale_drop_location()
|
||||
|
||||
|
||||
class SaleConfigSaleDropLocation(ModelSQL, ValueMixin):
|
||||
"Sale Configuration Sale Drop Location"
|
||||
__name__ = 'sale.configuration.sale_drop_location'
|
||||
sale_drop_location = sale_drop_location
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
exist = TableHandler.table_exist(cls._table)
|
||||
|
||||
super(SaleConfigSaleDropLocation, cls).__register__(
|
||||
module_name)
|
||||
|
||||
if not exist:
|
||||
cls._migrate_property([], [], [])
|
||||
|
||||
@classmethod
|
||||
def _migrate_property(cls, field_names, value_names, fields):
|
||||
field_names.append('sale_drop_location')
|
||||
value_names.append('sale_drop_location')
|
||||
migrate_property(
|
||||
'sale.configuration', field_names, cls, value_names,
|
||||
fields=fields)
|
||||
|
||||
@classmethod
|
||||
def default_sale_drop_location(cls):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
return ModelData.get_id(
|
||||
'sale_supply_drop_shipment', 'location_drop')
|
||||
|
||||
|
||||
class Sale:
|
||||
|
||||
@@ -6,6 +6,7 @@ from decimal import Decimal
|
||||
from sql.operators import Concat
|
||||
from sql.aggregate import Count
|
||||
|
||||
from trytond import backend
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
@@ -13,19 +14,71 @@ from trytond.transaction import Transaction
|
||||
from trytond.tools import grouped_slice
|
||||
|
||||
|
||||
__all__ = ['Configuration', 'ShipmentDrop', 'Move']
|
||||
__all__ = ['Configuration', 'ConfigurationSequence', 'ShipmentDrop', 'Move']
|
||||
|
||||
|
||||
class Configuration:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'stock.configuration'
|
||||
|
||||
shipment_drop_sequence = fields.Property(fields.Many2One('ir.sequence',
|
||||
'Drop Shipment Sequence', domain=[
|
||||
shipment_drop_sequence = fields.MultiValue(fields.Many2One(
|
||||
'ir.sequence', "Drop Shipment Sequence", required=True,
|
||||
domain=[
|
||||
('company', 'in',
|
||||
[Eval('context', {}).get('company', -1), None]),
|
||||
('code', '=', 'stock.shipment.drop'),
|
||||
], required=True))
|
||||
]))
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
pool = Pool()
|
||||
if field == 'shipment_drop_sequence':
|
||||
return pool.get('stock.configuration.sequence')
|
||||
return super(Configuration, cls).multivalue_model(field)
|
||||
|
||||
@classmethod
|
||||
def default_shipment_drop_sequence(cls, **pattern):
|
||||
return cls.multivalue_model(
|
||||
'shipment_drop_sequence').default_shipment_drop_sequence()
|
||||
|
||||
|
||||
class ConfigurationSequence:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'stock.configuration.sequence'
|
||||
shipment_drop_sequence = fields.Many2One(
|
||||
'ir.sequence', "Drop Shipment Sequence", required=True,
|
||||
domain=[
|
||||
('company', 'in', [Eval('company', -1), None]),
|
||||
('code', '=', 'stock.shipment.drop'),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
exist = TableHandler.table_exist(cls._table)
|
||||
if exist:
|
||||
table = TableHandler(cls, module_name)
|
||||
exist &= table.column_exist('shipment_drop_sequence')
|
||||
|
||||
super(ConfigurationSequence, cls).__register__(module_name)
|
||||
|
||||
if not exist:
|
||||
cls._migrate_property([], [], [])
|
||||
|
||||
@classmethod
|
||||
def _migrate_property(cls, field_names, value_names, fields):
|
||||
field_names.append('shipment_drop_sequence')
|
||||
value_names.append('shipment_drop_sequence')
|
||||
super(ConfigurationSequence, cls)._migrate_property(
|
||||
field_names, value_names, fields)
|
||||
|
||||
@classmethod
|
||||
def default_shipment_drop_sequence(cls):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
return ModelData.get_id(
|
||||
'sale_supply_drop_shipment', 'sequence_shipment_drop')
|
||||
|
||||
|
||||
class ShipmentDrop(Workflow, ModelSQL, ModelView):
|
||||
|
||||
@@ -202,24 +202,5 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="type">drop</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.property" id="property_shipment_drop_sequence">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'stock.configuration'), ('name', '=', 'shipment_drop_sequence')]"/>
|
||||
<field name="value" eval="'ir.sequence,' + str(ref('sequence_shipment_drop'))"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.property" id="default_sale_location_drop">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'sale.configuration'), ('name', '=', 'sale_drop_location')]"/>
|
||||
<field name="value"
|
||||
eval="'stock.location,' + str(ref('location_drop'))"/>
|
||||
</record>
|
||||
<record model="ir.property" id="default_purchase_location_drop">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'purchase.configuration'), ('name', '=', 'purchase_drop_location')]"/>
|
||||
<field name="value"
|
||||
eval="'stock.location,' + str(ref('location_drop'))"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
Reference in new issue
Block a user