Add patches to remove company from payment type

This commit is contained in:
Guillem Barba 2015-09-21 14:43:04 +02:00
parent 6e2c9779ae
commit 0494d08179
2 changed files with 132 additions and 0 deletions

View File

@ -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 @@
<?xml version="1.0"?>
<data>
- <xpath expr="/form/field[@name='company']" position="after">
+ <xpath expr="/form/field[@name='active']" position="after">
<label name="account_bank"/>
<field name="account_bank"/>
<label name="party"/>

View File

@ -0,0 +1,121 @@
diff --git a/view/payment_type_tree.xml b/view/payment_type_tree.xml
--- a/trytond/trytond/modules/account_payment_type/view/payment_type_tree.xml
+++ b/trytond/trytond/modules/account_payment_type/view/payment_type_tree.xml
@@ -2,7 +2,6 @@
<tree string="Payment Type">
<field name="name"/>
<field name="code"/>
- <field name="company"/>
<field name="active"/>
<field name="kind"/>
</tree>
diff --git a/view/payment_type_form.xml b/view/payment_type_form.xml
--- a/trytond/trytond/modules/account_payment_type/view/payment_type_form.xml
+++ b/trytond/trytond/modules/account_payment_type/view/payment_type_form.xml
@@ -4,13 +4,10 @@
<field name="name"/>
<label name="code"/>
<field name="code"/>
+ <label name="kind"/>
+ <field name="kind"/>
<label name="active"/>
<field name="active"/>
- <label name="company"/>
- <field name="company" widget="selection"/>
- <label name="kind"/>
- <field name="kind"/>
- <newline/>
<separator name="note" colspan="4"/>
<field name="note" colspan="4"/>
</form>
diff --git a/tests/test_account_payment_type.py b/tests/test_account_payment_type.py
--- a/trytond/trytond/modules/account_payment_type/tests/test_account_payment_type.py
+++ b/trytond/trytond/modules/account_payment_type/tests/test_account_payment_type.py
@@ -78,12 +78,10 @@
payment_payable, = self.payment_type.create([{
'name': 'Payment Payable',
'kind': 'payable',
- 'company': company.id,
}])
payment_receivable, = self.payment_type.create([{
'name': 'Payment Receivable',
'kind': 'receivable',
- 'company': company.id,
}])
move, = self.move.create([{
'period': period.id,
diff --git a/payment_type.xml b/payment_type.xml
--- a/trytond/trytond/modules/account_payment_type/payment_type.xml
+++ b/trytond/trytond/modules/account_payment_type/payment_type.xml
@@ -54,14 +54,5 @@
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
-
- <record model="ir.rule.group" id="rule_group_payment_type">
- <field name="model" search="[('model', '=', 'account.payment.type')]"/>
- <field name="global_p" eval="True"/>
- </record>
- <record model="ir.rule" id="rule_payment_type1">
- <field name="domain">[('company', '=', user.company.id if user.company else None)]</field>
- <field name="rule_group" ref="rule_group_payment_type"/>
- </record>
</data>
</tryton>
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