Remove Property fields
issue2349 review39261002
This commit is contained in:
1 parent
d85a03bb09
commit
d07fb2fe01
5 files changed
+71
-30
No files matched your search
@@ -15,8 +15,10 @@ def register():
|
||||
ProcessPaymentStart,
|
||||
PayLineAskJournal,
|
||||
Configuration,
|
||||
ConfigurationPaymentGroupSequence,
|
||||
Invoice,
|
||||
party.Party,
|
||||
party.PartyPaymentDirectDebit,
|
||||
module='account_payment', type_='model')
|
||||
Pool.register(
|
||||
ProcessPayment,
|
||||
|
||||
+53
-5
@@ -7,16 +7,20 @@ from sql.aggregate import Sum
|
||||
from sql.conditionals import Case, Coalesce
|
||||
from sql.functions import Abs
|
||||
|
||||
from trytond import backend
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.model import ModelSQL, ModelView, fields
|
||||
from trytond.pyson import Eval, If, Bool
|
||||
from trytond.wizard import (Wizard, StateView, StateAction, StateTransition,
|
||||
Button)
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.tools.multivalue import migrate_property
|
||||
from trytond.modules.company.model import CompanyValueMixin
|
||||
|
||||
from .payment import KINDS
|
||||
|
||||
__all__ = ['MoveLine', 'PayLine', 'PayLineAskJournal', 'Configuration',
|
||||
__all__ = ['MoveLine', 'PayLine', 'PayLineAskJournal',
|
||||
'Configuration', 'ConfigurationPaymentGroupSequence',
|
||||
'Invoice']
|
||||
|
||||
|
||||
@@ -302,12 +306,56 @@ class PayLine(Wizard):
|
||||
class Configuration:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.configuration'
|
||||
payment_group_sequence = fields.Property(fields.Many2One('ir.sequence',
|
||||
'Payment Group Sequence', domain=[
|
||||
payment_group_sequence = fields.MultiValue(fields.Many2One(
|
||||
'ir.sequence', 'Payment Group Sequence', required=True,
|
||||
domain=[
|
||||
('company', 'in',
|
||||
[Eval('context', {}).get('company', -1), None]),
|
||||
('code', '=', 'account.payment.group'),
|
||||
], required=True))
|
||||
]))
|
||||
|
||||
@classmethod
|
||||
def default_payment_group_sequence(cls):
|
||||
return cls.multivalue_model(
|
||||
'payment_group_sequence').default_payment_group_sequence()
|
||||
|
||||
|
||||
class ConfigurationPaymentGroupSequence(ModelSQL, CompanyValueMixin):
|
||||
"Account Configuration Payment Group Sequence"
|
||||
__name__ = 'account.configuration.payment_group_sequence'
|
||||
payment_group_sequence = fields.Many2One(
|
||||
'ir.sequence', "Payment Group Sequence", required=True,
|
||||
domain=[
|
||||
('company', 'in', [Eval('company', -1), None]),
|
||||
('code', '=', 'account.payment.group'),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
exist = TableHandler.table_exist(cls._table)
|
||||
|
||||
super(ConfigurationPaymentGroupSequence, cls).__register__(module_name)
|
||||
|
||||
if not exist:
|
||||
cls._migrate_property([], [], [])
|
||||
|
||||
@classmethod
|
||||
def _migrate_property(cls, field_names, value_names, fields):
|
||||
field_names.append('payment_group_sequence')
|
||||
value_names.append('payment_group_sequence')
|
||||
fields.append('company')
|
||||
migrate_property(
|
||||
'account.configuration', field_names, cls, value_names,
|
||||
fields=fields)
|
||||
|
||||
@classmethod
|
||||
def default_payment_group_sequence(cls):
|
||||
pool = Pool()
|
||||
ModelData = pool.get('ir.model.data')
|
||||
return ModelData.get_id(
|
||||
'account_payment', 'sequence_account_payment_group')
|
||||
|
||||
|
||||
class Invoice:
|
||||
|
||||
@@ -122,13 +122,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">configuration_form</field>
|
||||
</record>
|
||||
</data>
|
||||
<data noupdate="1">
|
||||
<record model="ir.property" id="property_payment_group_sequence">
|
||||
<field name="field"
|
||||
search="[('model.model', '=', 'account.configuration'), ('name', '=', 'payment_group_sequence')]"/>
|
||||
<field name="value" eval="'ir.sequence,' + str(ref('sequence_account_payment_group'))"/>
|
||||
</record>
|
||||
</data>
|
||||
<data depends="account_invoice">
|
||||
<record model="ir.ui.view" id="invoice_view_form">
|
||||
<field name="model">account.invoice</field>
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
# 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
|
||||
from trytond.model import fields
|
||||
from trytond.model import ModelSQL, fields
|
||||
from trytond.modules.company.model import CompanyValueMixin
|
||||
|
||||
__all__ = ['Party', 'PartyReplace']
|
||||
__all__ = ['Party', 'PartyPaymentDirectDebit', 'PartyReplace']
|
||||
payment_direct_debit = fields.Boolean(
|
||||
"Direct Debit", help="Check if supplier does direct debit.")
|
||||
|
||||
|
||||
class Party:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'party.party'
|
||||
|
||||
payment_direct_debit_int = fields.Property(
|
||||
fields.Integer("Direct Debit Internal"))
|
||||
payment_direct_debit = fields.Function(
|
||||
fields.Boolean(
|
||||
"Direct Debit", help="Check if supplier does direct debit."),
|
||||
'get_payment_direct_debit', setter='set_payment_direct_debit')
|
||||
payment_direct_debit = fields.MultiValue(payment_direct_debit)
|
||||
payment_direct_debits = fields.One2Many(
|
||||
'party.party.payment_direct_debit', 'party', "Direct Debits")
|
||||
|
||||
@classmethod
|
||||
def default_payment_direct_debit(cls):
|
||||
def default_payment_direct_debit(cls, **pattern):
|
||||
return False
|
||||
|
||||
def get_payment_direct_debit(self, name):
|
||||
return bool(self.payment_direct_debit_int)
|
||||
|
||||
@classmethod
|
||||
def set_payment_direct_debit(cls, parties, name, value):
|
||||
cls.write(parties, {
|
||||
'payment_direct_debit_int': (
|
||||
int(value) if value is not None else None),
|
||||
})
|
||||
class PartyPaymentDirectDebit(ModelSQL, CompanyValueMixin):
|
||||
"Party Payment Direct Debit"
|
||||
__name__ = 'party.party.payment_direct_debit'
|
||||
party = fields.Many2One(
|
||||
'party.party', "Party", ondelete='CASCADE', select=True)
|
||||
payment_direct_debit = payment_direct_debit
|
||||
|
||||
|
||||
class PartyReplace:
|
||||
|
||||
@@ -118,7 +118,7 @@ Create invoice::
|
||||
>>> Invoice = Model.get('account.invoice')
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.party = party
|
||||
>>> invoice.payment_direct_debit
|
||||
>>> bool(invoice.payment_direct_debit)
|
||||
True
|
||||
>>> line = invoice.lines.new()
|
||||
>>> line.description = 'Description'
|
||||
|
||||
Reference in new issue
Block a user