From 768556f116ef1a285302836b397fe56abd6b1251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emili=20Garc=C3=ADa?= Date: Wed, 8 Jan 2025 15:03:02 +0100 Subject: [PATCH] =?UTF-8?q?No=20agrupar=20l=C3=ADnies=20en=20cas=20de=20fa?= =?UTF-8?q?ctures=20que=20tinguin=20periode=20entre=20el=20canvi=20d'any?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- som_facturacio_comer/giscedata_facturacio.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/som_facturacio_comer/giscedata_facturacio.py b/som_facturacio_comer/giscedata_facturacio.py index 32e2138fb..9501fa01d 100644 --- a/som_facturacio_comer/giscedata_facturacio.py +++ b/som_facturacio_comer/giscedata_facturacio.py @@ -3,6 +3,7 @@ """ from osv import osv +from datetime import datetime class GiscedataFacturacioFacturador(osv.osv): @@ -53,5 +54,21 @@ def get_discount_line_vals(self, cursor, uid, line, context=None): return vals + def crear_linia(self, cursor, uid, factura_id, vals, context=None): + if not context: + context = {} + + if factura_id or 'factura_id' in vals: + factura_obj = self.pool.get('giscedata.facturacio.factura') + factura_info = factura_obj.read(cursor, uid, factura_id, ['data_inici', 'data_final']) + if factura_info and 'data_inici' in factura_info and 'data_final' in factura_info: + any_desde = datetime.strptime(factura_info['data_inici'], '%Y-%m-%d').year + any_fins = datetime.strptime(factura_info['data_final'], '%Y-%m-%d').year + if any_desde != any_fins: + context.update({'group_line': False}) + return super(GiscedataFacturacioFacturador, self).crear_linia( + cursor, uid, factura_id, vals, context=context + ) + GiscedataFacturacioFacturador()