Skip to content

Commit

Permalink
Merge pull request #788 from Som-Energia/no_agrupar_linies_canvi_peatges
Browse files Browse the repository at this point in the history
No agrupar línies en cas de factures que tinguin periode entre el canvi d'any
  • Loading branch information
FranciscoCubero authored Jan 10, 2025
2 parents 6967f73 + 768556f commit dd1dce2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions som_facturacio_comer/giscedata_facturacio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from osv import osv
from datetime import datetime


class GiscedataFacturacioFacturador(osv.osv):
Expand Down Expand Up @@ -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()

0 comments on commit dd1dce2

Please sign in to comment.