Fix flake8 errors and warnings
We add the flake8 configuration used so we ensure everyone uses the same. We remove the usage of __all__ for non public API. When possible, we rationalize the class name according to its __name__ and module. issue9082 review297061002
This commit is contained in:
+30
-30
@@ -2,36 +2,36 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import Pool
|
||||
from .sale import *
|
||||
from . import sale
|
||||
from . import product
|
||||
from .stock import *
|
||||
from .configuration import *
|
||||
from .invoice import *
|
||||
from . import stock
|
||||
from . import configuration
|
||||
from . import invoice
|
||||
from . import party
|
||||
from . import sale_reporting
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Move,
|
||||
Sale,
|
||||
SaleIgnoredInvoice,
|
||||
SaleRecreatedInvoice,
|
||||
SaleLine,
|
||||
SaleLineTax,
|
||||
SaleLineIgnoredMove,
|
||||
SaleLineRecreatedMove,
|
||||
stock.Move,
|
||||
sale.Sale,
|
||||
sale.SaleIgnoredInvoice,
|
||||
sale.SaleRecreatedInvoice,
|
||||
sale.SaleLine,
|
||||
sale.SaleLineTax,
|
||||
sale.SaleLineIgnoredMove,
|
||||
sale.SaleLineRecreatedMove,
|
||||
product.Template,
|
||||
product.Product,
|
||||
product.SaleContext,
|
||||
ShipmentOut,
|
||||
ShipmentOutReturn,
|
||||
HandleShipmentExceptionAsk,
|
||||
HandleInvoiceExceptionAsk,
|
||||
ReturnSaleStart,
|
||||
Configuration,
|
||||
ConfigurationSequence,
|
||||
ConfigurationSaleMethod,
|
||||
stock.ShipmentOut,
|
||||
stock.ShipmentOutReturn,
|
||||
sale.HandleShipmentExceptionAsk,
|
||||
sale.HandleInvoiceExceptionAsk,
|
||||
sale.ReturnSaleStart,
|
||||
configuration.Configuration,
|
||||
configuration.ConfigurationSequence,
|
||||
configuration.ConfigurationSaleMethod,
|
||||
sale_reporting.Context,
|
||||
sale_reporting.Customer,
|
||||
sale_reporting.CustomerTimeseries,
|
||||
@@ -45,19 +45,19 @@ def register():
|
||||
sale_reporting.Subdivision,
|
||||
sale_reporting.SubdivisionTimeseries,
|
||||
sale_reporting.Region,
|
||||
Invoice,
|
||||
InvoiceLine,
|
||||
invoice.Invoice,
|
||||
invoice.Line,
|
||||
module='sale', type_='model')
|
||||
Pool.register(
|
||||
OpenCustomer,
|
||||
HandleShipmentException,
|
||||
HandleInvoiceException,
|
||||
ReturnSale,
|
||||
ModifyHeader,
|
||||
party.PartyReplace,
|
||||
party.PartyErase,
|
||||
sale.OpenCustomer,
|
||||
sale.HandleShipmentException,
|
||||
sale.HandleInvoiceException,
|
||||
sale.ReturnSale,
|
||||
sale.ModifyHeader,
|
||||
party.Replace,
|
||||
party.Erase,
|
||||
sale_reporting.OpenRegion,
|
||||
module='sale', type_='wizard')
|
||||
Pool.register(
|
||||
SaleReport,
|
||||
sale.SaleReport,
|
||||
module='sale', type_='report')
|
||||
|
||||
@@ -9,8 +9,6 @@ from trytond.tools.multivalue import migrate_property
|
||||
from trytond.modules.company.model import (
|
||||
CompanyMultiValueMixin, CompanyValueMixin)
|
||||
|
||||
__all__ = ['Configuration',
|
||||
'ConfigurationSequence', 'ConfigurationSaleMethod']
|
||||
sale_invoice_method = fields.Selection(
|
||||
'get_sale_invoice_methods', "Sale Invoice Method")
|
||||
sale_shipment_method = fields.Selection(
|
||||
|
||||
+4
-6
@@ -8,8 +8,6 @@ from trytond.model.exceptions import AccessError
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['Invoice', 'InvoiceLine']
|
||||
|
||||
|
||||
def process_sale(func):
|
||||
@wraps(func)
|
||||
@@ -102,21 +100,21 @@ class Invoice(metaclass=PoolMeta):
|
||||
return super(Invoice, cls).draft(invoices)
|
||||
|
||||
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
class Line(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
|
||||
@property
|
||||
def origin_name(self):
|
||||
pool = Pool()
|
||||
SaleLine = pool.get('sale.line')
|
||||
name = super(InvoiceLine, self).origin_name
|
||||
name = super().origin_name
|
||||
if isinstance(self.origin, SaleLine):
|
||||
name = self.origin.sale.rec_name
|
||||
return name
|
||||
|
||||
@classmethod
|
||||
def _get_origin(cls):
|
||||
models = super(InvoiceLine, cls)._get_origin()
|
||||
models = super()._get_origin()
|
||||
models.append('sale.line')
|
||||
return models
|
||||
|
||||
@@ -128,6 +126,6 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
invoices = (l.invoice for l in cls.browse(lines)
|
||||
if l.type == 'line' and l.invoice)
|
||||
sales = set(s for i in invoices for s in i.sales)
|
||||
super(InvoiceLine, cls).delete(lines)
|
||||
super().delete(lines)
|
||||
if sales:
|
||||
Sale.__queue__.process(sales)
|
||||
|
||||
@@ -5,27 +5,25 @@ from trytond.pool import PoolMeta, Pool
|
||||
|
||||
from trytond.modules.party.exceptions import EraseError
|
||||
|
||||
__all__ = ['PartyReplace', 'PartyErase']
|
||||
|
||||
|
||||
class PartyReplace(metaclass=PoolMeta):
|
||||
class Replace(metaclass=PoolMeta):
|
||||
__name__ = 'party.replace'
|
||||
|
||||
@classmethod
|
||||
def fields_to_replace(cls):
|
||||
return super(PartyReplace, cls).fields_to_replace() + [
|
||||
return super().fields_to_replace() + [
|
||||
('sale.sale', 'party'),
|
||||
('sale.sale', 'shipment_party'),
|
||||
]
|
||||
|
||||
|
||||
class PartyErase(metaclass=PoolMeta):
|
||||
class Erase(metaclass=PoolMeta):
|
||||
__name__ = 'party.erase'
|
||||
|
||||
def check_erase_company(self, party, company):
|
||||
pool = Pool()
|
||||
Sale = pool.get('sale.sale')
|
||||
super(PartyErase, self).check_erase_company(party, company)
|
||||
super().check_erase_company(party, company)
|
||||
|
||||
sales = Sale.search([
|
||||
['OR',
|
||||
|
||||
@@ -20,14 +20,6 @@ from trytond.pyson import Eval, If
|
||||
from trytond.wizard import Wizard, StateTransition, StateAction
|
||||
from trytond.i18n import lazy_gettext
|
||||
|
||||
__all__ = ['Context',
|
||||
'Customer', 'CustomerTimeseries',
|
||||
'Product', 'ProductTimeseries',
|
||||
'Category', 'CategoryTimeseries', 'CategoryTree',
|
||||
'Country', 'CountryTimeseries',
|
||||
'Subdivision', 'SubdivisionTimeseries',
|
||||
'Region', 'OpenRegion']
|
||||
|
||||
|
||||
def pairwise(iterable):
|
||||
a, b = tee(iterable)
|
||||
|
||||
@@ -79,8 +79,8 @@ setup(name=name,
|
||||
keywords='tryton sale',
|
||||
package_dir={'trytond.modules.sale': '.'},
|
||||
packages=(
|
||||
['trytond.modules.sale'] +
|
||||
['trytond.modules.sale.%s' % p for p in find_packages()]
|
||||
['trytond.modules.sale']
|
||||
+ ['trytond.modules.sale.%s' % p for p in find_packages()]
|
||||
),
|
||||
package_data={
|
||||
'trytond.modules.sale': (info.get('xml', [])
|
||||
@@ -94,7 +94,8 @@ setup(name=name,
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Financial and Insurance Industry',
|
||||
'Intended Audience :: Legal Industry',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||
'License :: OSI Approved :: '
|
||||
'GNU General Public License v3 or later (GPLv3+)',
|
||||
'Natural Language :: Bulgarian',
|
||||
'Natural Language :: Catalan',
|
||||
'Natural Language :: Chinese (Simplified)',
|
||||
|
||||
Reference in New Issue
Block a user