From 9ad8af0fa64dc40d6d304db424a9d65a9d056c2a Mon Sep 17 00:00:00 2001 From: Carlos G?lvez Date: Thu, 7 Feb 2019 14:01:59 +0100 Subject: [PATCH] Get the point of sale code of the invoice based on the shipping of the first line of invoice. #036530 --- invoice.py | 15 +++++++++++++++ template_facturae_3.2.xml | 2 +- tryton.cfg | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/invoice.py b/invoice.py index 9be68b7..ba0a567 100644 --- a/invoice.py +++ b/invoice.py @@ -1,6 +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.pool import PoolMeta +from trytond.model import fields from trytond.config import config import os from jinja2 import Environment, FileSystemLoader @@ -17,6 +18,9 @@ class Invoice: __metaclass__ = PoolMeta __name__ = 'account.invoice' + sale_point_code = fields.Function(fields.Char('Sale Point Code'), + 'get_sale_point_code') + @classmethod def __setup__(cls): super(Invoice, cls).__setup__() @@ -29,6 +33,17 @@ class Invoice: 'review the tab General of this party: "%(field)s"') }) + @classmethod + def get_sale_point_code(cls, invoices, name): + sale_points = {} + for invoice in invoices: + sale_point = u'' + address = invoice.shipment_origin_address + if address: + sale_point = address.electronet_sale_point + sale_points[invoice.id] = sale_point + return sale_points + @classmethod def generate_facturae_electronet(cls, invoices, certificate_password=None): to_write = ([],) diff --git a/template_facturae_3.2.xml b/template_facturae_3.2.xml index 3df5a25..4aa6828 100644 --- a/template_facturae_3.2.xml +++ b/template_facturae_3.2.xml @@ -71,7 +71,7 @@ {% if invoice.party.oficina_contable %}{{ administrative_center(invoice.party.oficina_contable, '01', invoice.party) }}{% endif %} {% if invoice.party.organo_gestor %}{{ administrative_center(invoice.party.organo_gestor, '02', invoice.party) }}{% endif %} {% if invoice.party.unidad_tramitadora %}{{ administrative_center(invoice.party.unidad_tramitadora, '03', invoice.party) }}{% endif %} - {% if invoice.invoice_address.electronet_sale_point %}{{ administrative_center(invoice.invoice_address.electronet_sale_point, '04', invoice.party) }}{% endif %} + {% if invoice.sale_point_code %}{{ administrative_center(invoice.sale_point_code, '04', invoice.party) }}{% endif %} {{ invoice.party.name and invoice.party.name[:80] or invoice.party.code[:80] }} diff --git a/tryton.cfg b/tryton.cfg index 41af0e7..7598652 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -3,6 +3,7 @@ version=4.8.0 depends: ir account_invoice_facturae + account_invoice_shipment account_invoice_sale_relation stock_origin_sale xml: