trytonpsk-sale_pos/user.py

36 lines
1.1 KiB
Python
Raw Normal View History

2020-04-15 21:47:31 +02:00
# This file is part of the sale_payment 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 fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval
2021-01-21 20:51:33 +01:00
class User(metaclass=PoolMeta):
2020-04-15 21:47:31 +02:00
__name__ = "res.user"
sale_device = fields.Many2One('sale.device', 'Sale Device',
2021-01-21 20:51:33 +01:00
domain=[('shop', '=', Eval('shop'))],
depends=['shop']
2020-04-15 21:47:31 +02:00
)
@classmethod
def __setup__(cls):
super(User, cls).__setup__()
if 'sale_device' not in cls._preferences_fields:
cls._preferences_fields.extend([
2021-01-21 20:51:53 +01:00
'sale_device',
])
2020-04-15 21:47:31 +02:00
@classmethod
def __register__(cls, module_name):
2021-06-22 20:38:42 +02:00
table_h = cls.__table_handler__(module_name)
2020-04-15 21:47:31 +02:00
# Migrate from sale_pos 3.0
old_column = 'pos_device'
new_column = 'sale_device'
2021-06-22 20:38:42 +02:00
if table_h.column_exist(old_column):
table_h.drop_fk(old_column)
table_h.column_rename(old_column, new_column)
2020-04-15 21:47:31 +02:00
super(User, cls).__register__(module_name)