From d73a0d32f39b9747e7427316639aada2a149fbf9 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 f4cc896..36eb913 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 @@ -18,6 +19,20 @@ MODULE_PATH = os.path.dirname(os.path.abspath(__file__)) class Invoice(metaclass=PoolMeta): __name__ = 'account.invoice' + sale_point_code = fields.Function(fields.Char('Sale Point Code'), + 'get_sale_point_code') + + @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 163446d..91d0a8a 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -3,6 +3,7 @@ version=5.1.0 depends: ir account_invoice_facturae + account_invoice_shipment account_invoice_sale_relation stock_origin_sale xml: