Remove Property fields
issue2349 review28161002
This commit is contained in:
@@ -15,6 +15,7 @@ def register():
|
||||
Action_SaleLine,
|
||||
Action_InvoiceLine,
|
||||
Configuration,
|
||||
ConfigurationSequence,
|
||||
Sale,
|
||||
InvoiceLine,
|
||||
module='sale_complaint', type_='model')
|
||||
|
||||
@@ -2,26 +2,76 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond import backend
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = ['Configuration', 'Sale']
|
||||
__all__ = ['Configuration', 'ConfigurationSequence', 'Sale']
|
||||
|
||||
|
||||
class Configuration:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'sale.configuration'
|
||||
|
||||
complaint_sequence = fields.Property(fields.Many2One('ir.sequence',
|
||||
'Complaint Sequence', domain=[
|
||||
complaint_sequence = fields.MultiValue(fields.Many2One(
|
||||
'ir.sequence', "Complaint Sequence",
|
||||
domain=[
|
||||
('code', '=', 'sale.complaint'),
|
||||
['OR',
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
('company', '=', None),
|
||||
],
|
||||
('company', 'in', [
|
||||
Eval('context', {}).get('company', -1), None]),
|
||||
]))
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
pool = Pool()
|
||||
if field == 'complaint_sequence':
|
||||
return pool.get('sale.configuration.sequence')
|
||||
return super(Configuration, cls).multivalue_model(field)
|
||||
|
||||
@classmethod
|
||||
def default_complaint_sequence(cls):
|
||||
return cls.multivalue_model(
|
||||
'complaint_sequence').default_complaint_sequence()
|
||||
|
||||
|
||||
class ConfigurationSequence:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'sale.configuration.sequence'
|
||||
complaint_sequence = fields.Many2One(
|
||||
'ir.sequence', "Complaint Sequence",
|
||||
domain=[
|
||||
('code', '=', 'sale.complaint'),
|
||||
('company', 'in', [Eval('company', -1), None]),
|
||||
],
|
||||
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('complaint_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('complaint_sequence')
|
||||
value_names.append('complaint_sequence')
|
||||
super(ConfigurationSequence, cls)._migrate_property(
|
||||
field_names, value_names, fields)
|
||||
|
||||
@classmethod
|
||||
def default_complaint_sequence(cls):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
return ModelData.get_id('sale_complaint', 'sequence_complaint')
|
||||
|
||||
|
||||
class Sale:
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
@@ -29,11 +29,4 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">sale.complaint</field>
|
||||
</record>
|
||||
</data>
|
||||
<data noupdate="1">
|
||||
<record model="ir.property" id="property_complaint_sequence">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'sale.configuration'), ('name', '=', 'complaint_sequence')]"/>
|
||||
<field name="value" eval="'ir.sequence,' + str(ref('sequence_complaint'))"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
Reference in New Issue
Block a user