# -*- coding: utf-8 -*- # This file is part of the document-incoming-invoice-xml-module # from m-ds for Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from trytond.pool import PoolMeta from trytond.model import fields, ModelSQL sel_number_target = [ ('reference', "in the 'Reference' field"), ('number', "in the 'Number' field")] class Configuration(metaclass=PoolMeta): __name__ = 'document.incoming.configuration' create_supplier = fields.Boolean( string='Create Supplier Party', help='Creates the vendor party if it does not exist. ' + 'Generates an import error when turned off and the party is missing.') accept_other_company = fields.Boolean( string='Accept other company', help='Accepts invoices created for a company other ' + 'than the current one.') accept_incomplete_tax = fields.Boolean( string='Incomplete tax data', help='Accepts incomplete data in the taxes of invoice lines.') number_target = fields.Selection( string='Invoice number', help='Destination for the invoice number of the supplier invoice.', selection=sel_number_target) product_category = fields.Many2Many( string='Categories', origin='config', target='category', help='Categories used to determine tax and accounts for a product ' + 'on an invoice line.', filter=[('accounting', '=', True)], relation_name='document.incoming.confprodcat_rel') @classmethod def default_accept_incomplete_tax(cls): """ allow tax on invoice-line by percent, without 'VAT'-type Returns: bool: True """ return True @classmethod def default_number_target(cls): """ targetfield for incoming invoice number Returns: str: field 'reference' """ return 'reference' @classmethod def default_create_supplier(cls): """ auto create supplier party Returns: boolean: True """ return True @classmethod def default_accept_other_company(cls): """ deny import of invoices for other companies Returns: boolean: False """ return False # end Configuration class ConfigProductcategoryRel(ModelSQL): 'Configuration - Product Category - Relation' __name__ = 'document.incoming.confprodcat_rel' config = fields.Many2One( string='Configuration', required=True, ondelete='CASCADE', model_name='document.incoming.configuration') category = fields.Many2One( string='Category', required=True, domain=[('accounting', '=', True)], ondelete='CASCADE', model_name='product.category') # end ConfigProductcategoryRel