From 0494d081798eafc0f99861741ea348b0cd1f6c99 Mon Sep 17 00:00:00 2001 From: Guillem Barba Date: Mon, 21 Sep 2015 14:43:04 +0200 Subject: [PATCH] Add patches to remove company from payment type --- 024726_account_bank_remove_company.diff | 11 ++ ...6_account_payment_type_remove_company.diff | 121 ++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 024726_account_bank_remove_company.diff create mode 100644 024726_account_payment_type_remove_company.diff diff --git a/024726_account_bank_remove_company.diff b/024726_account_bank_remove_company.diff new file mode 100644 index 0000000..6717d73 --- /dev/null +++ b/024726_account_bank_remove_company.diff @@ -0,0 +1,11 @@ +diff --git a/view/account_payment_type_form_view.xml b/view/account_payment_type_form_view.xml +--- a/trytond/trytond/modules/account_bank/view/account_payment_type_form_view.xml ++++ b/trytond/trytond/modules/account_bank/view/account_payment_type_form_view.xml +@@ -1,6 +1,6 @@ + + +- ++ + + +diff --git a/payment_type.py b/payment_type.py +--- a/trytond/trytond/modules/account_payment_type/payment_type.py ++++ b/trytond/trytond/modules/account_payment_type/payment_type.py +@@ -1,11 +1,10 @@ + # This file is part of account_payment_type module for Tryton. + # The COPYRIGHT file at the top level of this repository contains + # the full copyright notices and license terms. +- + from trytond.model import ModelView, ModelSQL, fields +-from trytond.pyson import Eval, If + from trytond.pool import Pool + from trytond.transaction import Transaction ++from trytond import backend + + __all__ = ['PaymentType'] + +@@ -17,11 +16,6 @@ + name = fields.Char('Name', required=True, translate=True) + code = fields.Char('Code') + active = fields.Boolean('Active') +- company = fields.Many2One('company.company', 'Company', required=True, +- select=True, readonly=True, domain=[ +- ('id', If(Eval('context', {}).contains('company'), '=', '!='), +- Eval('context', {}).get('company', 0)), +- ]) + note = fields.Text('Description', translate=True, + help=('Description of the payment type that will be shown in ' + 'descriptions')) +@@ -32,6 +26,17 @@ + help='The kind of payment type.') + + @classmethod ++ def __register__(cls, module_name): ++ TableHandler = backend.get('TableHandler') ++ cursor = Transaction().cursor ++ table = TableHandler(cursor, cls, module_name) ++ ++ super(PaymentType, cls).__register__(module_name) ++ ++ # Migration from 3.4: drop required on company ++ table.not_null_action('company', action='remove') ++ ++ @classmethod + def __setup__(cls): + super(PaymentType, cls).__setup__() + cls._check_modify_fields = set(['kind']) +@@ -49,10 +54,6 @@ + def default_active(): + return True + +- @staticmethod +- def default_company(): +- return Transaction().context.get('company') +- + def get_rec_name(self, name): + if self.code: + return '[' + self.code + '] ' + self.name