From db3034f122e4e8d846dc3d5f4bb0fc962ddebc74 Mon Sep 17 00:00:00 2001 From: wilson gomez Date: Sat, 7 Aug 2021 11:32:16 -0500 Subject: [PATCH] migrate v6.0 --- __init__.py | 16 ++++++++-------- booking.py | 6 +----- configuration.py | 10 +++++----- equipment.py | 2 -- message.xml | 19 +++++++++++++++++++ product.py | 3 --- sale.py | 2 -- service.py | 23 +++++++---------------- service.xml | 1 - stock.py | 9 --------- tryton.cfg | 4 +--- 11 files changed, 41 insertions(+), 54 deletions(-) create mode 100644 message.xml diff --git a/__init__.py b/__init__.py index 627a06f..43ece43 100644 --- a/__init__.py +++ b/__init__.py @@ -2,14 +2,14 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -import service -import booking -import configuration -import product -import sale -import invoice -import stock -import equipment +from . import service +from . import booking +from . import configuration +from . import product +from . import sale +from . import invoice +from . import stock +from . import equipment def register(): diff --git a/booking.py b/booking.py index 2ab4550..dbd1ee2 100644 --- a/booking.py +++ b/booking.py @@ -9,8 +9,6 @@ from trytond.pyson import Eval, If, In, Get from trytond.transaction import Transaction from trytond.pool import Pool -__all__ = ['Booking'] - STATES = { 'readonly': (Eval('state') != 'draft') } @@ -274,7 +272,6 @@ class Booking(Workflow, ModelSQL, ModelView): 'id_number': self.doc_number, 'addresses': [('create', [{ 'street': self.address, - 'zip': self.post_code, }])], 'contact_mechanisms': [ ('create', [ @@ -339,7 +336,6 @@ class Booking(Workflow, ModelSQL, ModelView): Fill the number field with the service sequence ''' pool = Pool() - Sequence = pool.get('ir.sequence') Config = pool.get('rental.configuration') config = Config(1) @@ -348,5 +344,5 @@ class Booking(Workflow, ModelSQL, ModelView): continue if not config.rental_booking_sequence: continue - number = Sequence.get_id(config.rental_booking_sequence.id) + number = config.rental_booking_sequence.get() cls.write([record], {'number': number}) diff --git a/configuration.py b/configuration.py index 70f6423..c189235 100644 --- a/configuration.py +++ b/configuration.py @@ -1,9 +1,7 @@ # 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.model import ModelView, ModelSQL, ModelSingleton, fields -from trytond.pyson import Eval - -__all__ = ['Configuration', 'RentalConfigCheckList'] +from trytond.pyson import Eval, Id class Configuration(ModelSingleton, ModelSQL, ModelView): @@ -17,12 +15,14 @@ class Configuration(ModelSingleton, ModelSQL, ModelView): rental_service_sequence = fields.Many2One('ir.sequence', 'Rental Service Sequence', domain=[ ('company', 'in', [Eval('context', {}).get('company', 0), None]), - ('code', '=', 'rental.service'), + ('sequence_type', '=', + Id('rental', 'sequence_type_rental_service')), ], required=True) rental_booking_sequence = fields.Many2One('ir.sequence', 'Rental Booking Sequence', domain=[ ('company', 'in', [Eval('context', {}).get('company', 0), None]), - ('code', '=', 'rental.service'), + ('sequence_type', '=', + Id('rental', 'sequence_type_rental_service')), ], required=True) value_early_return = fields.Numeric('Value to Early Return', digits=(16, 2), required=True) diff --git a/equipment.py b/equipment.py index bbf86c2..fa44742 100644 --- a/equipment.py +++ b/equipment.py @@ -3,8 +3,6 @@ from trytond.model import fields, Unique from trytond.pool import Pool, PoolMeta -__all__ = ['RentalEquipment'] - class RentalEquipment(metaclass=PoolMeta): __name__ = 'maintenance.equipment' diff --git a/message.xml b/message.xml new file mode 100644 index 0000000..ea4b043 --- /dev/null +++ b/message.xml @@ -0,0 +1,19 @@ + + + + + + Error in Date Start Service! + + + State of Service invalid, for generate sale this service should be in draft state! + + + Product not available but another service + + + Product "%s" without stock. + + + diff --git a/product.py b/product.py index 405cc49..aa856c9 100644 --- a/product.py +++ b/product.py @@ -3,9 +3,6 @@ from trytond.model import ModelView, ModelSQL, fields from trytond.pool import PoolMeta -__all__ = ['ProductCheckList', 'CheckListItem', 'ProductCategory', - 'ProductTemplate'] - class ProductCategory(metaclass=PoolMeta): __name__ = 'product.category' diff --git a/sale.py b/sale.py index 93b990c..f6acdec 100644 --- a/sale.py +++ b/sale.py @@ -4,8 +4,6 @@ from trytond.model import fields from trytond.pool import PoolMeta from trytond.report import Report -__all__ = ['SaleLine', 'RentalSaleRelationReport'] - class SaleLine(metaclass=PoolMeta): __name__ = 'sale.line' diff --git a/service.py b/service.py index 2dee1fc..edc9710 100644 --- a/service.py +++ b/service.py @@ -8,12 +8,9 @@ from trytond.pyson import Eval, If, In, Get, Bool from trytond.transaction import Transaction from trytond.pool import Pool from trytond.wizard import Wizard, StateTransition +from trytond.i18n import gettext +from trytond.exceptions import UserError -__all__ = [ - 'Service', 'ServiceForceDraft', 'RentalVoucher', 'RentalSale', - 'CacheExpirationDays', 'DepositLine', - 'RentalServiceReport', 'RentalEquipmentReturnReport' -] STATES = { 'readonly': Eval('state') != 'draft', @@ -206,12 +203,6 @@ class Service(Workflow, ModelSQL, ModelView): 'invisible': Bool(Eval('sended_deposit_notificacion')), }, }) - cls._error_messages.update({ - 'invalid_dates': ('Error in Date Start Service!'), - 'invalid_state': ('State of Service invalid, for generate sale \ - this service should be in draft state!'), - 'product_not_avalilable': ('Product not available but another service') - }) def get_rec_name(self, name): return self.party.rec_name @@ -434,7 +425,7 @@ class Service(Workflow, ModelSQL, ModelView): continue if not config.rental_service_sequence: continue - number = Sequence.get_id(config.rental_service_sequence.id) + number = config.rental_service_sequence.get() cls.write([rec], {'number': number}) @fields.depends('unit_price', 'service_product', 'hiring_time') @@ -537,8 +528,8 @@ class RentalServiceReport(Report): __name__ = 'rental.service.report' @classmethod - def get_context(cls, records, data): - report_context = super(RentalServiceReport, cls).get_context(records, data) + def get_context(cls, records, header, data): + report_context = super().get_context(records, header, data) user = Pool().get('res.user')(Transaction().user) report_context['company'] = user.company report_context['user'] = user @@ -551,8 +542,8 @@ class RentalEquipmentReturnReport(Report): __name__ = 'rental.equipment_return.report' @classmethod - def get_context(cls, records, data): - report_context = super(RentalEquipmentReturnReport, cls).get_context(records, data) + def get_context(cls, records, header, data): + report_context = super().get_context(records, header, data) user = Pool().get('res.user')(Transaction().user) report_context['company'] = user.company report_context['user'] = user diff --git a/service.xml b/service.xml index e12c19d..64fb334 100644 --- a/service.xml +++ b/service.xml @@ -68,7 +68,6 @@ this repository contains the full copyright notices and license terms. --> Rental Service - rental.service