odoo-addon-l10n-br-fiscal 16.0.1.17.4.1__py3-none-any.whl → 16.0.1.17.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of odoo-addon-l10n-br-fiscal might be problematic. Click here for more details.

@@ -238,32 +238,38 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
238
238
 
239
239
  def _remove_all_fiscal_tax_ids(self):
240
240
  for line in self:
241
- line.fiscal_tax_ids = False
242
-
241
+ to_update = {"fiscal_tax_ids": False}
243
242
  for fiscal_tax_field in FISCAL_TAX_ID_FIELDS:
244
- line[fiscal_tax_field] = False
245
-
246
- self._set_fields_issqn(TAX_DICT_VALUES)
247
- self._set_fields_csll(TAX_DICT_VALUES)
248
- self._set_fields_irpj(TAX_DICT_VALUES)
249
- self._set_fields_inss(TAX_DICT_VALUES)
250
- self._set_fields_icms(TAX_DICT_VALUES)
251
- self._set_fields_icmsfcp(TAX_DICT_VALUES)
252
- self._set_fields_icmsfcpst(TAX_DICT_VALUES)
253
- self._set_fields_icmsst(TAX_DICT_VALUES)
254
- self._set_fields_icmssn(TAX_DICT_VALUES)
255
- self._set_fields_ipi(TAX_DICT_VALUES)
256
- self._set_fields_ii(TAX_DICT_VALUES)
257
- self._set_fields_pis(TAX_DICT_VALUES)
258
- self._set_fields_pisst(TAX_DICT_VALUES)
259
- self._set_fields_cofins(TAX_DICT_VALUES)
260
- self._set_fields_cofinsst(TAX_DICT_VALUES)
261
- self._set_fields_issqn_wh(TAX_DICT_VALUES)
262
- self._set_fields_pis_wh(TAX_DICT_VALUES)
263
- self._set_fields_cofins_wh(TAX_DICT_VALUES)
264
- self._set_fields_csll_wh(TAX_DICT_VALUES)
265
- self._set_fields_irpj_wh(TAX_DICT_VALUES)
266
- self._set_fields_inss_wh(TAX_DICT_VALUES)
243
+ to_update[fiscal_tax_field] = False
244
+ tax_methods = [
245
+ self._prepare_fields_issqn,
246
+ self._prepare_fields_csll,
247
+ self._prepare_fields_irpj,
248
+ self._prepare_fields_inss,
249
+ self._prepare_fields_icms,
250
+ self._prepare_fields_icmsfcp,
251
+ self._prepare_fields_icmsfcpst,
252
+ self._prepare_fields_icmsst,
253
+ self._prepare_fields_icmssn,
254
+ self._prepare_fields_ipi,
255
+ self._prepare_fields_ii,
256
+ self._prepare_fields_pis,
257
+ self._prepare_fields_pisst,
258
+ self._prepare_fields_cofins,
259
+ self._prepare_fields_cofinsst,
260
+ self._prepare_fields_issqn_wh,
261
+ self._prepare_fields_pis_wh,
262
+ self._prepare_fields_cofins_wh,
263
+ self._prepare_fields_csll_wh,
264
+ self._prepare_fields_irpj_wh,
265
+ self._prepare_fields_inss_wh,
266
+ ]
267
+ for method in tax_methods:
268
+ prepared_fields = method(TAX_DICT_VALUES)
269
+ if prepared_fields:
270
+ to_update.update(prepared_fields)
271
+ # Update all fields at once
272
+ line.update(to_update)
267
273
 
268
274
  def _update_fiscal_tax_ids(self, taxes):
269
275
  for line in self:
@@ -276,24 +282,37 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
276
282
  def _update_fiscal_taxes(self):
277
283
  for line in self:
278
284
  compute_result = self._compute_taxes(line.fiscal_tax_ids)
279
- computed_taxes = compute_result.get("taxes", {})
280
- line.amount_tax_included = compute_result.get("amount_included", 0.0)
281
- line.amount_tax_not_included = compute_result.get(
282
- "amount_not_included", 0.0
283
- )
284
- line.amount_tax_withholding = compute_result.get("amount_withholding", 0.0)
285
- line.estimate_tax = compute_result.get("estimate_tax", 0.0)
286
- for tax in line.fiscal_tax_ids:
287
- computed_tax = computed_taxes.get(tax.tax_domain, {})
288
- if hasattr(line, "%s_tax_id" % (tax.tax_domain,)):
289
- # since v13, when line is a new record,
290
- # line.fiscal_tax_ids recordset is made of
291
- # NewId records with an origin pointing back to the original
292
- # tax. tax.ids[0] is a way to the the single original tax back.
293
- setattr(line, "%s_tax_id" % (tax.tax_domain,), tax.ids[0])
294
- method = getattr(self, "_set_fields_%s" % (tax.tax_domain,))
295
- if method:
296
- method(computed_tax)
285
+ to_update = {
286
+ "amount_tax_included": compute_result.get("amount_included", 0.0),
287
+ "amount_tax_not_included": compute_result.get(
288
+ "amount_not_included", 0.0
289
+ ),
290
+ "amount_tax_withholding": compute_result.get("amount_withholding", 0.0),
291
+ "estimate_tax": compute_result.get("estimate_tax", 0.0),
292
+ }
293
+ to_update.update(line._prepare_tax_fields(compute_result))
294
+
295
+ in_draft_mode = self != self._origin
296
+ if in_draft_mode:
297
+ line.update(to_update)
298
+ else:
299
+ line.write(to_update)
300
+
301
+ def _prepare_tax_fields(self, compute_result):
302
+ self.ensure_one()
303
+ computed_taxes = compute_result.get("taxes", {})
304
+ tax_values = {}
305
+ for tax in self.fiscal_tax_ids:
306
+ computed_tax = computed_taxes.get(tax.tax_domain, {})
307
+ tax_field_name = f"{tax.tax_domain}_tax_id"
308
+ if hasattr(self, tax_field_name):
309
+ tax_values[tax_field_name] = tax.ids[0]
310
+ method = getattr(self, f"_prepare_fields_{tax.tax_domain}", None)
311
+ if method and computed_tax:
312
+ prepared_fields = method(computed_tax)
313
+ if prepared_fields:
314
+ tax_values.update(prepared_fields)
315
+ return tax_values
297
316
 
298
317
  def _get_product_price(self):
299
318
  self.ensure_one()
@@ -408,25 +427,27 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
408
427
  self._get_product_price()
409
428
  self._onchange_fiscal_operation_id()
410
429
 
411
- def _set_fields_issqn(self, tax_dict):
430
+ def _prepare_fields_issqn(self, tax_dict):
412
431
  self.ensure_one()
413
- if tax_dict:
414
- self.issqn_base = tax_dict.get("base")
415
- self.issqn_percent = tax_dict.get("percent_amount")
416
- self.issqn_reduction = tax_dict.get("percent_reduction")
417
- self.issqn_value = tax_dict.get("tax_value")
432
+ return {
433
+ "issqn_base": tax_dict.get("base"),
434
+ "issqn_percent": tax_dict.get("percent_amount"),
435
+ "issqn_reduction": tax_dict.get("percent_reduction"),
436
+ "issqn_value": tax_dict.get("tax_value"),
437
+ }
418
438
 
419
439
  @api.onchange("issqn_base", "issqn_percent", "issqn_reduction", "issqn_value")
420
440
  def _onchange_issqn_fields(self):
421
441
  pass
422
442
 
423
- def _set_fields_issqn_wh(self, tax_dict):
443
+ def _prepare_fields_issqn_wh(self, tax_dict):
424
444
  self.ensure_one()
425
- if tax_dict:
426
- self.issqn_wh_base = tax_dict.get("base")
427
- self.issqn_wh_percent = tax_dict.get("percent_amount")
428
- self.issqn_wh_reduction = tax_dict.get("percent_reduction")
429
- self.issqn_wh_value = tax_dict.get("tax_value")
445
+ return {
446
+ "issqn_wh_base": tax_dict.get("base"),
447
+ "issqn_wh_percent": tax_dict.get("percent_amount"),
448
+ "issqn_wh_reduction": tax_dict.get("percent_reduction"),
449
+ "issqn_wh_value": tax_dict.get("tax_value"),
450
+ }
430
451
 
431
452
  @api.onchange(
432
453
  "issqn_wh_base", "issqn_wh_percent", "issqn_wh_reduction", "issqn_wh_value"
@@ -434,25 +455,27 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
434
455
  def _onchange_issqn_wh_fields(self):
435
456
  pass
436
457
 
437
- def _set_fields_csll(self, tax_dict):
458
+ def _prepare_fields_csll(self, tax_dict):
438
459
  self.ensure_one()
439
- if tax_dict:
440
- self.csll_base = tax_dict.get("base")
441
- self.csll_percent = tax_dict.get("percent_amount")
442
- self.csll_reduction = tax_dict.get("percent_reduction")
443
- self.csll_value = tax_dict.get("tax_value")
460
+ return {
461
+ "csll_base": tax_dict.get("base"),
462
+ "csll_percent": tax_dict.get("percent_amount"),
463
+ "csll_reduction": tax_dict.get("percent_reduction"),
464
+ "csll_value": tax_dict.get("tax_value"),
465
+ }
444
466
 
445
467
  @api.onchange("csll_base", "csll_percent", "csll_reduction", "csll_value")
446
468
  def _onchange_csll_fields(self):
447
469
  pass
448
470
 
449
- def _set_fields_csll_wh(self, tax_dict):
471
+ def _prepare_fields_csll_wh(self, tax_dict):
450
472
  self.ensure_one()
451
- if tax_dict:
452
- self.csll_wh_base = tax_dict.get("base")
453
- self.csll_wh_percent = tax_dict.get("percent_amount")
454
- self.csll_wh_reduction = tax_dict.get("percent_reduction")
455
- self.csll_wh_value = tax_dict.get("tax_value")
473
+ return {
474
+ "csll_wh_base": tax_dict.get("base"),
475
+ "csll_wh_percent": tax_dict.get("percent_amount"),
476
+ "csll_wh_reduction": tax_dict.get("percent_reduction"),
477
+ "csll_wh_value": tax_dict.get("tax_value"),
478
+ }
456
479
 
457
480
  @api.onchange(
458
481
  "csll_wh_base", "csll_wh_percent", "csll_wh_reduction", "csll_wh_value"
@@ -460,25 +483,27 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
460
483
  def _onchange_csll_wh_fields(self):
461
484
  pass
462
485
 
463
- def _set_fields_irpj(self, tax_dict):
486
+ def _prepare_fields_irpj(self, tax_dict):
464
487
  self.ensure_one()
465
- if tax_dict:
466
- self.irpj_base = tax_dict.get("base")
467
- self.irpj_percent = tax_dict.get("percent_amount")
468
- self.irpj_reduction = tax_dict.get("percent_reduction")
469
- self.irpj_value = tax_dict.get("tax_value")
488
+ return {
489
+ "irpj_base": tax_dict.get("base"),
490
+ "irpj_percent": tax_dict.get("percent_amount"),
491
+ "irpj_reduction": tax_dict.get("percent_reduction"),
492
+ "irpj_value": tax_dict.get("tax_value"),
493
+ }
470
494
 
471
495
  @api.onchange("irpj_base", "irpj_percent", "irpj_reduction", "irpj_value")
472
496
  def _onchange_irpj_fields(self):
473
497
  pass
474
498
 
475
- def _set_fields_irpj_wh(self, tax_dict):
499
+ def _prepare_fields_irpj_wh(self, tax_dict):
476
500
  self.ensure_one()
477
- if tax_dict:
478
- self.irpj_wh_base = tax_dict.get("base")
479
- self.irpj_wh_percent = tax_dict.get("percent_amount")
480
- self.irpj_wh_reduction = tax_dict.get("percent_reduction")
481
- self.irpj_wh_value = tax_dict.get("tax_value")
501
+ return {
502
+ "irpj_wh_base": tax_dict.get("base"),
503
+ "irpj_wh_percent": tax_dict.get("percent_amount"),
504
+ "irpj_wh_reduction": tax_dict.get("percent_reduction"),
505
+ "irpj_wh_value": tax_dict.get("tax_value"),
506
+ }
482
507
 
483
508
  @api.onchange(
484
509
  "irpj_wh_base", "irpj_wh_percent", "irpj_wh_reduction", "irpj_wh_value"
@@ -486,25 +511,27 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
486
511
  def _onchange_irpj_wh_fields(self):
487
512
  pass
488
513
 
489
- def _set_fields_inss(self, tax_dict):
514
+ def _prepare_fields_inss(self, tax_dict):
490
515
  self.ensure_one()
491
- if tax_dict:
492
- self.inss_base = tax_dict.get("base")
493
- self.inss_percent = tax_dict.get("percent_amount")
494
- self.inss_reduction = tax_dict.get("percent_reduction")
495
- self.inss_value = tax_dict.get("tax_value")
516
+ return {
517
+ "inss_base": tax_dict.get("base"),
518
+ "inss_percent": tax_dict.get("percent_amount"),
519
+ "inss_reduction": tax_dict.get("percent_reduction"),
520
+ "inss_value": tax_dict.get("tax_value"),
521
+ }
496
522
 
497
523
  @api.onchange("inss_base", "inss_percent", "inss_reduction", "inss_value")
498
524
  def _onchange_inss_fields(self):
499
525
  pass
500
526
 
501
- def _set_fields_inss_wh(self, tax_dict):
527
+ def _prepare_fields_inss_wh(self, tax_dict):
502
528
  self.ensure_one()
503
- if tax_dict:
504
- self.inss_wh_base = tax_dict.get("base")
505
- self.inss_wh_percent = tax_dict.get("percent_amount")
506
- self.inss_wh_reduction = tax_dict.get("percent_reduction")
507
- self.inss_wh_value = tax_dict.get("tax_value")
529
+ return {
530
+ "inss_wh_base": tax_dict.get("base"),
531
+ "inss_wh_percent": tax_dict.get("percent_amount"),
532
+ "inss_wh_reduction": tax_dict.get("percent_reduction"),
533
+ "inss_wh_value": tax_dict.get("tax_value"),
534
+ }
508
535
 
509
536
  @api.onchange(
510
537
  "inss_wh_base", "inss_wh_percent", "inss_wh_reduction", "inss_wh_value"
@@ -512,42 +539,24 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
512
539
  def _onchange_inss_wh_fields(self):
513
540
  pass
514
541
 
515
- def _set_fields_icms(self, tax_dict):
542
+ def _prepare_fields_icms(self, tax_dict):
516
543
  self.ensure_one()
517
- if tax_dict:
518
- self.icms_cst_id = tax_dict.get("cst_id")
519
- self.icms_base_type = tax_dict.get("icms_base_type", ICMS_BASE_TYPE_DEFAULT)
520
- self.icms_base = tax_dict.get("base")
521
- self.icms_percent = tax_dict.get("percent_amount")
522
- self.icms_reduction = tax_dict.get("percent_reduction")
523
- self.icms_value = tax_dict.get("tax_value")
524
-
525
- # vBCUFDest - Valor da BC do ICMS na UF de destino
526
- if tax_dict.get("icms_dest_base") is not None:
527
- self.icms_destination_base = tax_dict.get("icms_dest_base")
528
-
529
- # pICMSUFDest - Alíquota interna da UF de destino
530
- self.icms_origin_percent = tax_dict.get("icms_origin_perc")
531
-
532
- # pICMSInter - Alíquota interestadual das UF envolvidas
533
- self.icms_destination_percent = tax_dict.get("icms_dest_perc")
534
-
535
- # pICMSInterPart - Percentual provisório de partilha
536
- # do ICMS Interestadual
537
- self.icms_sharing_percent = tax_dict.get("icms_sharing_percent")
538
-
539
- # vICMSUFRemet - Valor do ICMS Interestadual
540
- # para a UF do remetente
541
- if tax_dict.get("icms_origin_value") is not None:
542
- self.icms_origin_value = tax_dict.get("icms_origin_value")
543
-
544
- # vICMSUFDest - Valor do ICMS Interestadual para a UF de destino
545
- if tax_dict.get("icms_dest_value") is not None:
546
- self.icms_destination_value = tax_dict.get("icms_dest_value")
547
-
548
- # Valor da desoneração do ICMS
549
- if tax_dict.get("icms_relief") is not None:
550
- self.icms_relief_value = tax_dict.get("icms_relief")
544
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
545
+ return {
546
+ "icms_cst_id": cst_id,
547
+ "icms_base_type": tax_dict.get("icms_base_type", ICMS_BASE_TYPE_DEFAULT),
548
+ "icms_base": tax_dict.get("base", 0.0),
549
+ "icms_percent": tax_dict.get("percent_amount", 0.0),
550
+ "icms_reduction": tax_dict.get("percent_reduction", 0.0),
551
+ "icms_value": tax_dict.get("tax_value", 0.0),
552
+ "icms_origin_percent": tax_dict.get("icms_origin_perc", 0.0),
553
+ "icms_destination_percent": tax_dict.get("icms_dest_perc", 0.0),
554
+ "icms_sharing_percent": tax_dict.get("icms_sharing_percent", 0.0),
555
+ "icms_destination_base": tax_dict.get("icms_dest_base", 0.0),
556
+ "icms_origin_value": tax_dict.get("icms_origin_value", 0.0),
557
+ "icms_destination_value": tax_dict.get("icms_dest_value", 0.0),
558
+ "icms_relief_value": tax_dict.get("icms_relief", 0.0),
559
+ }
551
560
 
552
561
  @api.onchange(
553
562
  "icms_base",
@@ -565,15 +574,22 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
565
574
  if self.icms_tax_benefit_id:
566
575
  self.icms_tax_id = self.icms_tax_benefit_id.tax_id
567
576
 
568
- def _set_fields_icmssn(self, tax_dict):
577
+ def _prepare_fields_icmssn(self, tax_dict):
569
578
  self.ensure_one()
570
- self.icms_cst_id = tax_dict.get("cst_id")
571
- self.icmssn_base = tax_dict.get("base")
572
- self.icmssn_percent = tax_dict.get("percent_amount")
573
- self.icmssn_reduction = tax_dict.get("percent_reduction")
574
- self.icmssn_credit_value = tax_dict.get("tax_value")
575
- self.simple_value = self.icmssn_base * self.icmssn_range_id.total_tax_percent
576
- self.simple_without_icms_value = self.simple_value - self.icmssn_credit_value
579
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
580
+ icmssn_base = tax_dict.get("base", 0.0)
581
+ icmssn_credit_value = tax_dict.get("tax_value", 0.0)
582
+ simple_value = icmssn_base * self.icmssn_range_id.total_tax_percent
583
+ simple_without_icms_value = simple_value - icmssn_credit_value
584
+ return {
585
+ "icms_cst_id": cst_id,
586
+ "icmssn_base": icmssn_base,
587
+ "icmssn_percent": tax_dict.get("percent_amount"),
588
+ "icmssn_reduction": tax_dict.get("percent_reduction"),
589
+ "icmssn_credit_value": icmssn_credit_value,
590
+ "simple_value": simple_value,
591
+ "simple_without_icms_value": simple_without_icms_value,
592
+ }
577
593
 
578
594
  @api.onchange(
579
595
  "icmssn_base", "icmssn_percent", "icmssn_reduction", "icmssn_credit_value"
@@ -581,20 +597,18 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
581
597
  def _onchange_icmssn_fields(self):
582
598
  pass
583
599
 
584
- def _set_fields_icmsst(self, tax_dict):
600
+ def _prepare_fields_icmsst(self, tax_dict):
585
601
  self.ensure_one()
586
- self.icmsst_base_type = tax_dict.get(
587
- "icmsst_base_type", ICMS_ST_BASE_TYPE_DEFAULT
588
- )
589
- self.icmsst_mva_percent = tax_dict.get("icmsst_mva_percent")
590
- self.icmsst_percent = tax_dict.get("percent_amount")
591
- self.icmsst_reduction = tax_dict.get("percent_reduction")
592
- self.icmsst_base = tax_dict.get("base")
593
- self.icmsst_value = tax_dict.get("tax_value")
594
-
595
- # TODO - OTHER TAX icmsst_wh_tax_id
596
- # self.icmsst_wh_base
597
- # self.icmsst_wh_value
602
+ return {
603
+ "icmsst_base_type": tax_dict.get(
604
+ "icmsst_base_type", ICMS_ST_BASE_TYPE_DEFAULT
605
+ ),
606
+ "icmsst_mva_percent": tax_dict.get("icmsst_mva_percent"),
607
+ "icmsst_percent": tax_dict.get("percent_amount"),
608
+ "icmsst_reduction": tax_dict.get("percent_reduction"),
609
+ "icmsst_base": tax_dict.get("base"),
610
+ "icmsst_value": tax_dict.get("tax_value"),
611
+ }
598
612
 
599
613
  @api.onchange(
600
614
  "icmsst_base_type",
@@ -609,56 +623,65 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
609
623
  def _onchange_icmsst_fields(self):
610
624
  pass
611
625
 
612
- def _set_fields_icmsfcp(self, tax_dict):
626
+ def _prepare_fields_icmsfcp(self, tax_dict):
613
627
  self.ensure_one()
614
- self.icmsfcp_base = tax_dict.get("base", 0.0)
615
- self.icmsfcp_percent = tax_dict.get("percent_amount", 0.0)
616
- self.icmsfcp_value = tax_dict.get("tax_value", 0.0)
628
+ return {
629
+ "icmsfcp_base": tax_dict.get("base", 0.0),
630
+ "icmsfcp_percent": tax_dict.get("percent_amount", 0.0),
631
+ "icmsfcp_value": tax_dict.get("tax_value", 0.0),
632
+ }
617
633
 
618
- def _set_fields_icmsfcpst(self, tax_dict):
634
+ def _prepare_fields_icmsfcpst(self, tax_dict):
619
635
  self.ensure_one()
620
- self.icmsfcpst_base = self.icmsst_base
621
- self.icmsfcpst_percent = tax_dict.get("percent_amount", 0.0)
622
- self.icmsfcpst_value = tax_dict.get("tax_value", 0.0)
636
+ return {
637
+ "icmsfcpst_base": self.icmsst_base,
638
+ "icmsfcpst_percent": tax_dict.get("percent_amount", 0.0),
639
+ "icmsfcpst_value": tax_dict.get("tax_value", 0.0),
640
+ }
623
641
 
624
642
  @api.onchange("icmsfcp_percent", "icmsfcp_value")
625
643
  def _onchange_icmsfcp_fields(self):
626
644
  pass
627
645
 
628
- def _set_fields_ipi(self, tax_dict):
646
+ def _prepare_fields_ipi(self, tax_dict):
629
647
  self.ensure_one()
630
- if tax_dict:
631
- self.ipi_cst_id = tax_dict.get("cst_id")
632
- self.ipi_base_type = tax_dict.get("base_type", False)
633
- self.ipi_base = tax_dict.get("base", 0.00)
634
- self.ipi_percent = tax_dict.get("percent_amount", 0.00)
635
- self.ipi_reduction = tax_dict.get("percent_reduction", 0.00)
636
- self.ipi_value = tax_dict.get("tax_value", 0.00)
648
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
649
+ return {
650
+ "ipi_cst_id": cst_id,
651
+ "ipi_base_type": tax_dict.get("base_type", False),
652
+ "ipi_base": tax_dict.get("base", 0.00),
653
+ "ipi_percent": tax_dict.get("percent_amount", 0.00),
654
+ "ipi_reduction": tax_dict.get("percent_reduction", 0.00),
655
+ "ipi_value": tax_dict.get("tax_value", 0.00),
656
+ }
637
657
 
638
658
  @api.onchange("ipi_base", "ipi_percent", "ipi_reduction", "ipi_value")
639
659
  def _onchange_ipi_fields(self):
640
660
  pass
641
661
 
642
- def _set_fields_ii(self, tax_dict):
662
+ def _prepare_fields_ii(self, tax_dict):
643
663
  self.ensure_one()
644
- if tax_dict:
645
- self.ii_base = tax_dict.get("base", 0.00)
646
- self.ii_percent = tax_dict.get("percent_amount", 0.00)
647
- self.ii_value = tax_dict.get("tax_value", 0.00)
664
+ return {
665
+ "ii_base": tax_dict.get("base", 0.00),
666
+ "ii_percent": tax_dict.get("percent_amount", 0.00),
667
+ "ii_value": tax_dict.get("tax_value", 0.00),
668
+ }
648
669
 
649
670
  @api.onchange("ii_base", "ii_percent", "ii_value")
650
671
  def _onchange_ii_fields(self):
651
672
  pass
652
673
 
653
- def _set_fields_pis(self, tax_dict):
674
+ def _prepare_fields_pis(self, tax_dict):
654
675
  self.ensure_one()
655
- if tax_dict:
656
- self.pis_cst_id = tax_dict.get("cst_id")
657
- self.pis_base_type = tax_dict.get("base_type")
658
- self.pis_base = tax_dict.get("base", 0.00)
659
- self.pis_percent = tax_dict.get("percent_amount", 0.00)
660
- self.pis_reduction = tax_dict.get("percent_reduction", 0.00)
661
- self.pis_value = tax_dict.get("tax_value", 0.00)
676
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
677
+ return {
678
+ "pis_cst_id": cst_id,
679
+ "pis_base_type": tax_dict.get("base_type"),
680
+ "pis_base": tax_dict.get("base", 0.00),
681
+ "pis_percent": tax_dict.get("percent_amount", 0.00),
682
+ "pis_reduction": tax_dict.get("percent_reduction", 0.00),
683
+ "pis_value": tax_dict.get("tax_value", 0.00),
684
+ }
662
685
 
663
686
  @api.onchange(
664
687
  "pis_base_type", "pis_base", "pis_percent", "pis_reduction", "pis_value"
@@ -666,14 +689,15 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
666
689
  def _onchange_pis_fields(self):
667
690
  pass
668
691
 
669
- def _set_fields_pis_wh(self, tax_dict):
692
+ def _prepare_fields_pis_wh(self, tax_dict):
670
693
  self.ensure_one()
671
- if tax_dict:
672
- self.pis_wh_base_type = tax_dict.get("base_type")
673
- self.pis_wh_base = tax_dict.get("base", 0.00)
674
- self.pis_wh_percent = tax_dict.get("percent_amount", 0.00)
675
- self.pis_wh_reduction = tax_dict.get("percent_reduction", 0.00)
676
- self.pis_wh_value = tax_dict.get("tax_value", 0.00)
694
+ return {
695
+ "pis_wh_base_type": tax_dict.get("base_type"),
696
+ "pis_wh_base": tax_dict.get("base", 0.00),
697
+ "pis_wh_percent": tax_dict.get("percent_amount", 0.00),
698
+ "pis_wh_reduction": tax_dict.get("percent_reduction", 0.00),
699
+ "pis_wh_value": tax_dict.get("tax_value", 0.00),
700
+ }
677
701
 
678
702
  @api.onchange(
679
703
  "pis_wh_base_type",
@@ -685,15 +709,17 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
685
709
  def _onchange_pis_wh_fields(self):
686
710
  pass
687
711
 
688
- def _set_fields_pisst(self, tax_dict):
712
+ def _prepare_fields_pisst(self, tax_dict):
689
713
  self.ensure_one()
690
- if tax_dict:
691
- self.pisst_cst_id = tax_dict.get("cst_id")
692
- self.pisst_base_type = tax_dict.get("base_type")
693
- self.pisst_base = tax_dict.get("base", 0.00)
694
- self.pisst_percent = tax_dict.get("percent_amount", 0.00)
695
- self.pisst_reduction = tax_dict.get("percent_reduction", 0.00)
696
- self.pisst_value = tax_dict.get("tax_value", 0.00)
714
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
715
+ return {
716
+ "pisst_cst_id": cst_id,
717
+ "pisst_base_type": tax_dict.get("base_type"),
718
+ "pisst_base": tax_dict.get("base", 0.00),
719
+ "pisst_percent": tax_dict.get("percent_amount", 0.00),
720
+ "pisst_reduction": tax_dict.get("percent_reduction", 0.00),
721
+ "pisst_value": tax_dict.get("tax_value", 0.00),
722
+ }
697
723
 
698
724
  @api.onchange(
699
725
  "pisst_base_type",
@@ -705,15 +731,17 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
705
731
  def _onchange_pisst_fields(self):
706
732
  pass
707
733
 
708
- def _set_fields_cofins(self, tax_dict):
734
+ def _prepare_fields_cofins(self, tax_dict):
709
735
  self.ensure_one()
710
- if tax_dict:
711
- self.cofins_cst_id = tax_dict.get("cst_id")
712
- self.cofins_base_type = tax_dict.get("base_type")
713
- self.cofins_base = tax_dict.get("base", 0.00)
714
- self.cofins_percent = tax_dict.get("percent_amount", 0.00)
715
- self.cofins_reduction = tax_dict.get("percent_reduction", 0.00)
716
- self.cofins_value = tax_dict.get("tax_value", 0.00)
736
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
737
+ return {
738
+ "cofins_cst_id": cst_id,
739
+ "cofins_base_type": tax_dict.get("base_type"),
740
+ "cofins_base": tax_dict.get("base", 0.00),
741
+ "cofins_percent": tax_dict.get("percent_amount", 0.00),
742
+ "cofins_reduction": tax_dict.get("percent_reduction", 0.00),
743
+ "cofins_value": tax_dict.get("tax_value", 0.00),
744
+ }
717
745
 
718
746
  @api.onchange(
719
747
  "cofins_base_type",
@@ -725,14 +753,15 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
725
753
  def _onchange_cofins_fields(self):
726
754
  pass
727
755
 
728
- def _set_fields_cofins_wh(self, tax_dict):
756
+ def _prepare_fields_cofins_wh(self, tax_dict):
729
757
  self.ensure_one()
730
- if tax_dict:
731
- self.cofins_wh_base_type = tax_dict.get("base_type")
732
- self.cofins_wh_base = tax_dict.get("base", 0.00)
733
- self.cofins_wh_percent = tax_dict.get("percent_amount", 0.00)
734
- self.cofins_wh_reduction = tax_dict.get("percent_reduction", 0.00)
735
- self.cofins_wh_value = tax_dict.get("tax_value", 0.00)
758
+ return {
759
+ "cofins_wh_base_type": tax_dict.get("base_type"),
760
+ "cofins_wh_base": tax_dict.get("base", 0.00),
761
+ "cofins_wh_percent": tax_dict.get("percent_amount", 0.00),
762
+ "cofins_wh_reduction": tax_dict.get("percent_reduction", 0.00),
763
+ "cofins_wh_value": tax_dict.get("tax_value", 0.00),
764
+ }
736
765
 
737
766
  @api.onchange(
738
767
  "cofins_wh_base_type",
@@ -744,15 +773,17 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
744
773
  def _onchange_cofins_wh_fields(self):
745
774
  pass
746
775
 
747
- def _set_fields_cofinsst(self, tax_dict):
776
+ def _prepare_fields_cofinsst(self, tax_dict):
748
777
  self.ensure_one()
749
- if tax_dict:
750
- self.cofinsst_cst_id = tax_dict.get("cst_id")
751
- self.cofinsst_base_type = tax_dict.get("base_type")
752
- self.cofinsst_base = tax_dict.get("base", 0.00)
753
- self.cofinsst_percent = tax_dict.get("percent_amount", 0.00)
754
- self.cofinsst_reduction = tax_dict.get("percent_reduction", 0.00)
755
- self.cofinsst_value = tax_dict.get("tax_value", 0.00)
778
+ cst_id = tax_dict.get("cst_id").id if tax_dict.get("cst_id") else False
779
+ return {
780
+ "cofinsst_cst_id": cst_id,
781
+ "cofinsst_base_type": tax_dict.get("base_type"),
782
+ "cofinsst_base": tax_dict.get("base", 0.00),
783
+ "cofinsst_percent": tax_dict.get("percent_amount", 0.00),
784
+ "cofinsst_reduction": tax_dict.get("percent_reduction", 0.00),
785
+ "cofinsst_value": tax_dict.get("tax_value", 0.00),
786
+ }
756
787
 
757
788
  @api.onchange(
758
789
  "cofinsst_base_type",
@@ -367,7 +367,7 @@ ul.auto-toc {
367
367
  !! This file is generated by oca-gen-addon-readme !!
368
368
  !! changes will be overwritten. !!
369
369
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370
- !! source digest: sha256:a47b3f8cc730d7be7e324351edcbe82bcec9115e8c4e60ca69494360ab1f6d9f
370
+ !! source digest: sha256:3c21c6738bbe8646e9e9a35e71240b8cd6904e4e21600dc2aa9936167de226a9
371
371
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372
372
  <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-brazil/tree/16.0/l10n_br_fiscal"><img alt="OCA/l10n-brazil" src="https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-brazil-16-0/l10n-brazil-16-0-l10n_br_fiscal"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373
373
  <img alt="https://raw.githubusercontent.com/OCA/l10n-brazil/16.0/l10n_br_fiscal/static/img/fiscal_dashboard.png" src="https://raw.githubusercontent.com/OCA/l10n-brazil/16.0/l10n_br_fiscal/static/img/fiscal_dashboard.png" />