select target for incoming invoice number
This commit is contained in:
parent
a94c678d33
commit
e8cceb75c1
6 changed files with 73 additions and 2 deletions
|
@ -9,6 +9,11 @@ from trytond.pool import PoolMeta
|
|||
from trytond.model import fields
|
||||
|
||||
|
||||
sel_number_target = [
|
||||
('reference', "in the 'Reference' field"),
|
||||
('number', "in the 'Number' field")]
|
||||
|
||||
|
||||
class Configuration(metaclass=PoolMeta):
|
||||
__name__ = 'document.incoming.configuration'
|
||||
|
||||
|
@ -20,6 +25,19 @@ class Configuration(metaclass=PoolMeta):
|
|||
string='Accept other company',
|
||||
help='Accepts invoices created for a company other ' +
|
||||
'than the current one.')
|
||||
number_target = fields.Selection(
|
||||
string='Invoice number',
|
||||
help='Destination for the invoice number of the supplier invoice.',
|
||||
selection=sel_number_target)
|
||||
|
||||
@classmethod
|
||||
def default_number_target(cls):
|
||||
""" targetfield for incoming invoice number
|
||||
|
||||
Returns:
|
||||
str: field 'reference'
|
||||
"""
|
||||
return 'reference'
|
||||
|
||||
@classmethod
|
||||
def default_create_supplier(cls):
|
||||
|
|
|
@ -311,9 +311,13 @@ class Incoming(metaclass=PoolMeta):
|
|||
msg='invalid type-code: %(code)s (expect: 380, 381)' % {
|
||||
'code': str(inv_code)}))
|
||||
|
||||
invoice.number = self._readxml_getvalue(xmltree, [
|
||||
invoice_number = self._readxml_getvalue(xmltree, [
|
||||
'rsm:CrossIndustryInvoice',
|
||||
'rsm:ExchangedDocument', 'ram:ID'])
|
||||
if config and config.number_target == 'number':
|
||||
invoice.number = invoice_number
|
||||
else:
|
||||
invoice.reference = invoice_number
|
||||
|
||||
# invoice-date
|
||||
date_path = [
|
||||
|
@ -380,6 +384,8 @@ class Incoming(metaclass=PoolMeta):
|
|||
buyer_party[x].replace('\n', '; ')
|
||||
for x in buyer_party.keys()])))
|
||||
|
||||
# lines of invoice
|
||||
|
||||
return invoice
|
||||
|
||||
def _readxml_convertdate(self, date_string):
|
||||
|
|
16
locale/de.po
16
locale/de.po
|
@ -41,3 +41,19 @@ msgstr "anderes Unternehmen akzeptieren"
|
|||
msgctxt "help:document.incoming.configuration,accept_other_company:"
|
||||
msgid "Accepts invoices created for a company other than the current one."
|
||||
msgstr "Akzeptiert Rechnungen welche für ein anderes Unternehmen als das aktuelle erstellt wurden."
|
||||
|
||||
msgctxt "field:document.incoming.configuration,number_target:"
|
||||
msgid "Invoice number"
|
||||
msgstr "Rechnungsnummer"
|
||||
|
||||
msgctxt "help:document.incoming.configuration,number_target:"
|
||||
msgid "Destination for the invoice number of the supplier invoice."
|
||||
msgstr "Ziel für die Rechungsnummer der Lieferantenrechung."
|
||||
|
||||
msgctxt "selection:document.incoming.configuration,number_target:"
|
||||
msgid "in the 'Reference' field"
|
||||
msgstr "in das 'Referenz'-Feld"
|
||||
|
||||
msgctxt "selection:document.incoming.configuration,number_target:"
|
||||
msgid "in the 'Number' field"
|
||||
msgstr "in das 'Nummer'-Feld"
|
||||
|
|
17
locale/en.po
17
locale/en.po
|
@ -33,3 +33,20 @@ msgstr "Accept other company"
|
|||
msgctxt "help:document.incoming.configuration,accept_other_company:"
|
||||
msgid "Accepts invoices created for a company other than the current one."
|
||||
msgstr "Accepts invoices created for a company other than the current one."
|
||||
|
||||
msgctxt "field:document.incoming.configuration,number_target:"
|
||||
msgid "Invoice number"
|
||||
msgstr "Invoice number"
|
||||
|
||||
msgctxt "help:document.incoming.configuration,number_target:"
|
||||
msgid "Destination for the invoice number of the supplier invoice."
|
||||
msgstr "Destination for the invoice number of the supplier invoice."
|
||||
|
||||
msgctxt "selection:document.incoming.configuration,number_target:"
|
||||
msgid "in the 'Reference' field"
|
||||
msgstr "in the 'Reference' field"
|
||||
|
||||
msgctxt "selection:document.incoming.configuration,number_target:"
|
||||
msgid "in the 'Number' field"
|
||||
msgstr "in the 'Number' field"
|
||||
|
||||
|
|
|
@ -129,12 +129,22 @@ class DocumentTestCase(object):
|
|||
|
||||
config.create_supplier = True
|
||||
config.accept_other_company = True
|
||||
config.number_target = 'number'
|
||||
config.save()
|
||||
|
||||
# check target of incoming invoice number
|
||||
invoice = document._process_supplier_invoice()
|
||||
self.assertEqual(invoice.number, 'RE2024.01234')
|
||||
self.assertTrue(not hasattr(invoice, 'reference'))
|
||||
|
||||
config.number_target = 'reference'
|
||||
config.save()
|
||||
|
||||
invoice = document._process_supplier_invoice()
|
||||
print('\n## invoice:', (invoice,))
|
||||
self.assertEqual(invoice.type, 'in')
|
||||
self.assertEqual(invoice.number, 'RE2024.01234')
|
||||
self.assertEqual(invoice.reference, 'RE2024.01234')
|
||||
self.assertTrue(not hasattr(invoice, 'number'))
|
||||
self.assertEqual(invoice.invoice_date, date(2024, 6, 17))
|
||||
self.assertEqual(invoice.currency.name, 'usd')
|
||||
self.assertEqual(invoice.company.rec_name, 'm-ds')
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='default_supplier']" position="after">
|
||||
<label name="number_target"/>
|
||||
<field name="number_target"/>
|
||||
|
||||
<label name="create_supplier"/>
|
||||
<field name="create_supplier"/>
|
||||
<label name="accept_other_company"/>
|
||||
<field name="accept_other_company"/>
|
||||
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
Loading…
Reference in a new issue