@@ -94,15 +94,20 @@ def is_module_installed(self, module):
9494 )
9595 return True if module_installed else False
9696
97- @api .onchange ("date_order" )
97+ @api .onchange ("date_order" , "commercial_partner_id" )
9898 def _l10n_ar_recompute_fiscal_position_taxes (self ):
99- """Recalculamos las percepciones si cambiamos la fecha de la orden de venta. Para ello nos basamos en los
100- impuestos de la posicion fiscal, buscamos si hay impuestos existentes para los tax groups involucrados y los
101- reemplazamos por los nuevos impuestos.
99+ """Recalculamos las percepciones si cambiamos la fecha de la orden de venta o el commercial partner.
100+ Para ello nos basamos en los impuestos de la posicion fiscal, buscamos si hay impuestos existentes para los tax groups involucrados y los
101+ reemplazamos por los nuevos impuestos.
102+ NO lo hacemos para el cambio de fiscal_position_id porque el onchange de fiscal_position_id implementado en sale_ux ya recomputa todos los taxes
103+ NOTA: en facturas no tenemos approach exactamente igual ya que en facturas es opcional el auto update a través del módulo
104+ account_invoice_fiscal_position_update
102105 """
103106 for rec in self .filtered (
104- lambda x : x .fiscal_position_id .l10n_ar_tax_ids .filtered (lambda x : x .tax_type == "perception" )
105- and x .state not in ["cancel" , "sale" ]
107+ lambda x : (
108+ x .fiscal_position_id .l10n_ar_tax_ids .filtered (lambda x : x .tax_type == "perception" )
109+ and x .state not in ["cancel" , "sale" ]
110+ )
106111 ):
107112 fp_tax_groups = rec .fiscal_position_id .l10n_ar_tax_ids .filtered (
108113 lambda x : x .tax_type == "perception"
@@ -112,9 +117,17 @@ def _l10n_ar_recompute_fiscal_position_taxes(self):
112117 for line in rec .order_line :
113118 to_unlink = line .tax_ids .filtered (lambda x : x .tax_group_id in fp_tax_groups )
114119 if to_unlink ._origin != new_taxes :
120+ < << << << cd2a37f9d3f1e30d6bd3e5cc909f99b6bc818300
115121 line .tax_ids = [(3 , tax .id ) for tax in to_unlink ] + [
116122 (4 , tax .id ) for tax in new_taxes if tax not in line .tax_ids
117123 ]
124+ | | | | | | | 69 ab90fcc6216e25bdf175730f36b6d7920c4eb3
125+ line .tax_id = [(3 , tax .id ) for tax in to_unlink ] + [
126+ (4 , tax .id ) for tax in new_taxes if tax not in line .tax_id
127+ ]
128+ == == == =
129+ line .tax_id = (line .tax_id - to_unlink ) | new_taxes
130+ >> >> >> > f8c61fc88f4b7c55caadfb636f575b91d8aef39c
118131
119132 def copy (self , default = None ):
120133 """Re computamos las percepciones al duplicar una venta porque puede ser que la orden venga de otro periodo
0 commit comments