store parsed data
This commit is contained in:
parent
174887f87e
commit
2f67ae4425
1 changed files with 9 additions and 2 deletions
11
document.py
11
document.py
|
@ -71,7 +71,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
'document_incoming_invoice_xml.msg_not_implemented',
|
'document_incoming_invoice_xml.msg_not_implemented',
|
||||||
xmltype=xsd_type))
|
xmltype=xsd_type))
|
||||||
# read xml data
|
# read xml data
|
||||||
invoice = xml_read_func(invoice, xmltree)
|
(self.parsed_data, invoice) = xml_read_func(invoice, xmltree)
|
||||||
return invoice
|
return invoice
|
||||||
|
|
||||||
def _readxml_xpath(self, tags):
|
def _readxml_xpath(self, tags):
|
||||||
|
@ -303,6 +303,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
Configuration = Pool().get('document.incoming.configuration')
|
Configuration = Pool().get('document.incoming.configuration')
|
||||||
|
|
||||||
config = Configuration.get_singleton()
|
config = Configuration.get_singleton()
|
||||||
|
parsed_data = {}
|
||||||
|
|
||||||
# rsm:CrossIndustryInvoice
|
# rsm:CrossIndustryInvoice
|
||||||
xpath_cross_ind = ['rsm:CrossIndustryInvoice']
|
xpath_cross_ind = ['rsm:CrossIndustryInvoice']
|
||||||
|
@ -325,6 +326,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
invoice.number = invoice_number
|
invoice.number = invoice_number
|
||||||
else:
|
else:
|
||||||
invoice.reference = invoice_number
|
invoice.reference = invoice_number
|
||||||
|
parsed_data['invoice_number'] = invoice_number
|
||||||
|
|
||||||
# invoice-date
|
# invoice-date
|
||||||
date_path = xpath_exchg_doc + [
|
date_path = xpath_exchg_doc + [
|
||||||
|
@ -337,6 +339,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
'code': str(date_format)}))
|
'code': str(date_format)}))
|
||||||
invoice.invoice_date = self._readxml_convertdate(
|
invoice.invoice_date = self._readxml_convertdate(
|
||||||
self._readxml_getvalue(xmltree, date_path))
|
self._readxml_getvalue(xmltree, date_path))
|
||||||
|
parsed_data['invoice_date'] = invoice.invoice_date
|
||||||
|
|
||||||
# IncludedNote, 1st line --> 'description', 2nd ff. --> 'comment'
|
# IncludedNote, 1st line --> 'description', 2nd ff. --> 'comment'
|
||||||
xpath_notes = xpath_exchg_doc + ['ram:IncludedNote']
|
xpath_notes = xpath_exchg_doc + ['ram:IncludedNote']
|
||||||
|
@ -353,6 +356,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
for y in ['Content', 'ContentCode', 'SubjectCode']
|
for y in ['Content', 'ContentCode', 'SubjectCode']
|
||||||
})
|
})
|
||||||
|
|
||||||
|
parsed_data['note_list'] = note_list
|
||||||
if note_list:
|
if note_list:
|
||||||
invoice.description = note_list[0].get('Content', None)
|
invoice.description = note_list[0].get('Content', None)
|
||||||
invoice.comment = '\n'.join([
|
invoice.comment = '\n'.join([
|
||||||
|
@ -378,6 +382,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
seller_party = self._readxml_party_data(
|
seller_party = self._readxml_party_data(
|
||||||
xmltree, xpath_appl_head_agree + ['ram:SellerTradeParty'],
|
xmltree, xpath_appl_head_agree + ['ram:SellerTradeParty'],
|
||||||
create_party=add_party)
|
create_party=add_party)
|
||||||
|
parsed_data['seller_party'] = seller_party
|
||||||
if seller_party:
|
if seller_party:
|
||||||
if 'party' in seller_party.keys():
|
if 'party' in seller_party.keys():
|
||||||
invoice.party = seller_party['party']
|
invoice.party = seller_party['party']
|
||||||
|
@ -393,6 +398,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
buyer_party = self._readxml_party_data(
|
buyer_party = self._readxml_party_data(
|
||||||
xmltree, xpath_appl_head_agree + ['ram:BuyerTradeParty'],
|
xmltree, xpath_appl_head_agree + ['ram:BuyerTradeParty'],
|
||||||
create_party=False)
|
create_party=False)
|
||||||
|
parsed_data['buyer_party'] = buyer_party
|
||||||
# check if we found our company
|
# check if we found our company
|
||||||
if config and not config.accept_other_company:
|
if config and not config.accept_other_company:
|
||||||
company_party_id = self._readxml_find_party(buyer_party)
|
company_party_id = self._readxml_find_party(buyer_party)
|
||||||
|
@ -417,6 +423,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
for x in range(1, num_lines + 1):
|
for x in range(1, num_lines + 1):
|
||||||
lines_data.append(
|
lines_data.append(
|
||||||
self._readxml_invoice_line(xmltree, xpath_line_item, x))
|
self._readxml_invoice_line(xmltree, xpath_line_item, x))
|
||||||
|
parsed_data['lines_data'] = lines_data
|
||||||
lines = [
|
lines = [
|
||||||
self._readxml_getinvoiceline(invoice, x)
|
self._readxml_getinvoiceline(invoice, x)
|
||||||
for x in lines_data]
|
for x in lines_data]
|
||||||
|
@ -425,7 +432,7 @@ class Incoming(metaclass=PoolMeta):
|
||||||
invoice.lines = lines
|
invoice.lines = lines
|
||||||
|
|
||||||
invoice.on_change_lines()
|
invoice.on_change_lines()
|
||||||
return invoice
|
return (parsed_data, invoice)
|
||||||
|
|
||||||
def _readxml_getinvoiceline(self, invoice, line_data):
|
def _readxml_getinvoiceline(self, invoice, line_data):
|
||||||
""" create invoice line in memory
|
""" create invoice line in memory
|
||||||
|
|
Loading…
Reference in a new issue