odoo-addon-l10n-br-fiscal 18.0.2.1.0__py3-none-any.whl → 18.0.3.1.0.1__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.

Files changed (26) hide show
  1. odoo/addons/l10n_br_fiscal/README.rst +1 -1
  2. odoo/addons/l10n_br_fiscal/__manifest__.py +1 -1
  3. odoo/addons/l10n_br_fiscal/demo/fiscal_document_demo.xml +2 -90
  4. odoo/addons/l10n_br_fiscal/demo/fiscal_document_nfse_demo.xml +0 -4
  5. odoo/addons/l10n_br_fiscal/demo/fiscal_operation_demo.xml +2 -2
  6. odoo/addons/l10n_br_fiscal/i18n/l10n_br_fiscal.pot +24 -24
  7. odoo/addons/l10n_br_fiscal/i18n/pt_BR.po +33 -24
  8. odoo/addons/l10n_br_fiscal/migrations/18.0.3.0.0/pre-migration.py +30 -0
  9. odoo/addons/l10n_br_fiscal/models/document.py +1 -6
  10. odoo/addons/l10n_br_fiscal/models/document_line.py +35 -5
  11. odoo/addons/l10n_br_fiscal/models/document_line_mixin.py +63 -12
  12. odoo/addons/l10n_br_fiscal/models/document_line_mixin_methods.py +74 -52
  13. odoo/addons/l10n_br_fiscal/models/document_mixin.py +3 -3
  14. odoo/addons/l10n_br_fiscal/models/document_mixin_methods.py +28 -142
  15. odoo/addons/l10n_br_fiscal/models/document_related.py +1 -1
  16. odoo/addons/l10n_br_fiscal/static/description/index.html +1 -1
  17. odoo/addons/l10n_br_fiscal/tests/test_document_edition.py +113 -0
  18. odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_generic.py +0 -11
  19. odoo/addons/l10n_br_fiscal/tests/test_fiscal_document_nfse.py +0 -1
  20. odoo/addons/l10n_br_fiscal/tests/test_tax_benefit.py +0 -1
  21. odoo/addons/l10n_br_fiscal/views/document_line_view.xml +3 -3
  22. odoo/addons/l10n_br_fiscal/views/document_view.xml +6 -6
  23. {odoo_addon_l10n_br_fiscal-18.0.2.1.0.dist-info → odoo_addon_l10n_br_fiscal-18.0.3.1.0.1.dist-info}/METADATA +2 -2
  24. {odoo_addon_l10n_br_fiscal-18.0.2.1.0.dist-info → odoo_addon_l10n_br_fiscal-18.0.3.1.0.1.dist-info}/RECORD +26 -25
  25. {odoo_addon_l10n_br_fiscal-18.0.2.1.0.dist-info → odoo_addon_l10n_br_fiscal-18.0.3.1.0.1.dist-info}/WHEEL +0 -0
  26. {odoo_addon_l10n_br_fiscal-18.0.2.1.0.dist-info → odoo_addon_l10n_br_fiscal-18.0.3.1.0.1.dist-info}/top_level.txt +0 -0
@@ -36,7 +36,6 @@ from ..constants.icms import (
36
36
  ICMS_BASE_TYPE,
37
37
  ICMS_BASE_TYPE_DEFAULT,
38
38
  ICMS_ORIGIN,
39
- ICMS_ORIGIN_DEFAULT,
40
39
  ICMS_ST_BASE_TYPE,
41
40
  ICMS_ST_BASE_TYPE_DEFAULT,
42
41
  )
@@ -135,16 +134,31 @@ class FiscalDocumentLineMixin(models.AbstractModel):
135
134
 
136
135
  partner_company_type = fields.Selection(related="partner_id.company_type")
137
136
 
138
- uom_id = fields.Many2one(comodel_name="uom.uom", string="UOM")
137
+ uom_id = fields.Many2one(
138
+ comodel_name="uom.uom",
139
+ string="UOM",
140
+ )
139
141
 
140
142
  quantity = fields.Float(
141
143
  digits="Product Unit of Measure",
142
144
  )
143
145
 
144
- fiscal_type = fields.Selection(selection=PRODUCT_FISCAL_TYPE)
146
+ fiscal_type = fields.Selection(
147
+ selection=PRODUCT_FISCAL_TYPE,
148
+ compute="_compute_product_fiscal_fields",
149
+ store=True,
150
+ readonly=False,
151
+ precompute=True,
152
+ )
145
153
 
146
154
  ncm_id = fields.Many2one(
147
- comodel_name="l10n_br_fiscal.ncm", index=True, string="NCM"
155
+ comodel_name="l10n_br_fiscal.ncm",
156
+ index=True,
157
+ string="NCM",
158
+ compute="_compute_product_fiscal_fields",
159
+ store=True,
160
+ readonly=False,
161
+ precompute=True,
148
162
  )
149
163
 
150
164
  nbm_id = fields.Many2one(
@@ -152,6 +166,10 @@ class FiscalDocumentLineMixin(models.AbstractModel):
152
166
  index=True,
153
167
  string="NBM",
154
168
  domain="[('ncm_ids', '=', ncm_id)]",
169
+ compute="_compute_product_fiscal_fields",
170
+ store=True,
171
+ readonly=False,
172
+ precompute=True,
155
173
  )
156
174
 
157
175
  cest_id = fields.Many2one(
@@ -159,10 +177,20 @@ class FiscalDocumentLineMixin(models.AbstractModel):
159
177
  index=True,
160
178
  string="CEST",
161
179
  domain="[('ncm_ids', '=', ncm_id)]",
180
+ compute="_compute_product_fiscal_fields",
181
+ store=True,
182
+ readonly=False,
183
+ precompute=True,
162
184
  )
163
185
 
164
186
  nbs_id = fields.Many2one(
165
- comodel_name="l10n_br_fiscal.nbs", index=True, string="NBS"
187
+ comodel_name="l10n_br_fiscal.nbs",
188
+ index=True,
189
+ string="NBS",
190
+ compute="_compute_product_fiscal_fields",
191
+ store=True,
192
+ readonly=False,
193
+ precompute=True,
166
194
  )
167
195
 
168
196
  fiscal_operation_id = fields.Many2one(
@@ -258,11 +286,11 @@ class FiscalDocumentLineMixin(models.AbstractModel):
258
286
  compute="_compute_fiscal_amounts",
259
287
  )
260
288
 
261
- amount_untaxed = fields.Monetary(
289
+ fiscal_amount_untaxed = fields.Monetary(
262
290
  compute="_compute_fiscal_amounts",
263
291
  )
264
292
 
265
- amount_tax = fields.Monetary(
293
+ fiscal_amount_tax = fields.Monetary(
266
294
  compute="_compute_fiscal_amounts",
267
295
  )
268
296
 
@@ -270,7 +298,7 @@ class FiscalDocumentLineMixin(models.AbstractModel):
270
298
  compute="_compute_fiscal_amounts",
271
299
  )
272
300
 
273
- amount_total = fields.Monetary(
301
+ fiscal_amount_total = fields.Monetary(
274
302
  compute="_compute_fiscal_amounts",
275
303
  )
276
304
 
@@ -296,7 +324,12 @@ class FiscalDocumentLineMixin(models.AbstractModel):
296
324
  amount_tax_withholding = fields.Monetary(string="Tax Withholding")
297
325
 
298
326
  fiscal_genre_id = fields.Many2one(
299
- comodel_name="l10n_br_fiscal.product.genre", string="Fiscal Product Genre"
327
+ comodel_name="l10n_br_fiscal.product.genre",
328
+ string="Fiscal Product Genre",
329
+ compute="_compute_product_fiscal_fields",
330
+ store=True,
331
+ readonly=False,
332
+ precompute=True,
300
333
  )
301
334
 
302
335
  fiscal_genre_code = fields.Char(
@@ -307,10 +340,19 @@ class FiscalDocumentLineMixin(models.AbstractModel):
307
340
  comodel_name="l10n_br_fiscal.service.type",
308
341
  string="Service Type LC 166",
309
342
  domain="[('internal_type', '=', 'normal')]",
343
+ compute="_compute_product_fiscal_fields",
344
+ store=True,
345
+ readonly=False,
346
+ precompute=True,
310
347
  )
311
348
 
312
349
  city_taxation_code_id = fields.Many2one(
313
- comodel_name="l10n_br_fiscal.city.taxation.code", string="City Taxation Code"
350
+ comodel_name="l10n_br_fiscal.city.taxation.code",
351
+ string="City Taxation Code",
352
+ compute="_compute_product_fiscal_fields",
353
+ store=True,
354
+ readonly=False,
355
+ precompute=True,
314
356
  )
315
357
 
316
358
  partner_order = fields.Char(string="Partner Order (xPed)", size=15)
@@ -331,6 +373,10 @@ class FiscalDocumentLineMixin(models.AbstractModel):
331
373
  issqn_fg_city_id = fields.Many2one(
332
374
  comodel_name="res.city",
333
375
  string="ISSQN City",
376
+ compute="_compute_product_fiscal_fields",
377
+ store=True,
378
+ readonly=False,
379
+ precompute=True,
334
380
  )
335
381
 
336
382
  # vDeducao
@@ -487,7 +533,12 @@ class FiscalDocumentLineMixin(models.AbstractModel):
487
533
  )
488
534
 
489
535
  icms_origin = fields.Selection(
490
- selection=ICMS_ORIGIN, string="ICMS Origin", default=ICMS_ORIGIN_DEFAULT
536
+ selection=ICMS_ORIGIN,
537
+ string="ICMS Origin",
538
+ compute="_compute_product_fiscal_fields",
539
+ store=True,
540
+ readonly=False,
541
+ precompute=True,
491
542
  )
492
543
 
493
544
  # vBC - Valor da base de cálculo do ICMS
@@ -1620,7 +1671,7 @@ class FiscalDocumentLineMixin(models.AbstractModel):
1620
1671
  comodel_name="l10n_br_fiscal.comment",
1621
1672
  string="Comments",
1622
1673
  domain=[("object", "=", FISCAL_COMMENT_LINE)],
1623
- compute="_compute_fiscal_tax_ids",
1674
+ compute="_compute_comment_ids",
1624
1675
  store=True,
1625
1676
  precompute=True,
1626
1677
  readonly=False,
@@ -7,8 +7,12 @@ from lxml import etree
7
7
 
8
8
  from odoo import Command, api, models
9
9
 
10
- from ..constants.fiscal import CFOP_DESTINATION_EXPORT, FISCAL_IN
11
- from ..constants.icms import ICMS_BASE_TYPE_DEFAULT, ICMS_ST_BASE_TYPE_DEFAULT
10
+ from ..constants.fiscal import CFOP_DESTINATION_EXPORT, FISCAL_IN, TAX_DOMAIN_ICMS
11
+ from ..constants.icms import (
12
+ ICMS_BASE_TYPE_DEFAULT,
13
+ ICMS_ORIGIN_DEFAULT,
14
+ ICMS_ST_BASE_TYPE_DEFAULT,
15
+ )
12
16
 
13
17
  FISCAL_TAX_ID_FIELDS = [
14
18
  "cofins_tax_id",
@@ -171,11 +175,11 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
171
175
  # Total value of products or services
172
176
  record.price_gross = round_curr.round(record.price_unit * record.quantity)
173
177
  record.amount_fiscal = record.price_gross - record.discount_value
174
- record.amount_tax = record.amount_tax_not_included
178
+ record.fiscal_amount_tax = record.amount_tax_not_included
175
179
 
176
180
  add_to_amount = sum(record[a] for a in record._add_fields_to_amount())
177
181
  rm_to_amount = sum(record[r] for r in record._rm_fields_to_amount())
178
- record.amount_untaxed = (
182
+ record.fiscal_amount_untaxed = (
179
183
  record.price_gross
180
184
  - record.discount_value
181
185
  + add_to_amount
@@ -183,13 +187,17 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
183
187
  )
184
188
 
185
189
  # Valor do documento (NF)
186
- record.amount_total = record.amount_untaxed + record.amount_tax
190
+ record.fiscal_amount_total = (
191
+ record.fiscal_amount_untaxed + record.fiscal_amount_tax
192
+ )
187
193
 
188
194
  # Valor Liquido (TOTAL + IMPOSTOS - RETENÇÕES)
189
- record.amount_taxed = record.amount_total - record.amount_tax_withholding
195
+ record.amount_taxed = (
196
+ record.fiscal_amount_total - record.amount_tax_withholding
197
+ )
190
198
 
191
199
  # Valor do documento (NF) - RETENÇÕES
192
- record.amount_total = record.amount_taxed
200
+ record.fiscal_amount_total = record.amount_taxed
193
201
 
194
202
  # Valor financeiro
195
203
  if (
@@ -305,11 +313,16 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
305
313
  for tax in mapping_result["taxes"].values():
306
314
  taxes |= tax
307
315
  line.fiscal_tax_ids = taxes
308
- line.comment_ids = line.fiscal_operation_line_id.comment_ids
309
-
310
316
  else:
311
317
  line.fiscal_tax_ids = [Command.clear()]
312
318
 
319
+ @api.depends("fiscal_operation_line_id")
320
+ def _compute_comment_ids(self):
321
+ for line in self:
322
+ line.comment_ids = [
323
+ Command.set(line.fiscal_operation_line_id.comment_ids.ids)
324
+ ]
325
+
313
326
  @api.model
314
327
  def _build_null_mask_dict(self) -> dict:
315
328
  """
@@ -465,48 +478,50 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
465
478
  self.ensure_one()
466
479
  return self.partner_id
467
480
 
468
- @api.onchange("product_id")
469
- def _onchange_product_id_fiscal(self):
470
- if not self.fiscal_operation_id:
481
+ @api.depends("product_id")
482
+ def _compute_product_fiscal_fields(self):
483
+ if self._context.get("skip_compute_product_fiscal_fields"):
471
484
  return
472
- if self.product_id:
473
- self.name = self.product_id.display_name
474
- self.fiscal_type = self.product_id.fiscal_type
475
- self.uom_id = self.product_id.uom_id
476
- self.ncm_id = self.product_id.ncm_id
477
- self.nbm_id = self.product_id.nbm_id
478
- self.tax_icms_or_issqn = self.product_id.tax_icms_or_issqn
479
- self.icms_origin = self.product_id.icms_origin
480
- self.cest_id = self.product_id.cest_id
481
- self.nbs_id = self.product_id.nbs_id
482
- self.fiscal_genre_id = self.product_id.fiscal_genre_id
483
- self.service_type_id = self.product_id.service_type_id
484
- self.uot_id = self.product_id.uot_id or self.product_id.uom_id
485
- if self.product_id.city_taxation_code_ids:
486
- company_city_id = self.company_id.city_id
487
- city_id = self.product_id.city_taxation_code_ids.filtered(
488
- lambda r: r.city_id == company_city_id
485
+ for line in self:
486
+ if not line.product_id:
487
+ # reset to default values:
488
+ line.fiscal_type = False
489
+ line.ncm_id = False
490
+ line.nbm_id = False
491
+ line.tax_icms_or_issqn = TAX_DOMAIN_ICMS
492
+ line.icms_origin = ICMS_ORIGIN_DEFAULT
493
+ line.cest_id = False
494
+ line.nbs_id = False
495
+ line.fiscal_genre_id = False
496
+ line.service_type_id = False
497
+ line.city_taxation_code_id = False
498
+ line.issqn_fg_city_id = False
499
+ continue
500
+
501
+ product = line.product_id
502
+ line.fiscal_type = product.fiscal_type
503
+ line.ncm_id = product.ncm_id
504
+ line.nbm_id = product.nbm_id
505
+ line.tax_icms_or_issqn = product.tax_icms_or_issqn
506
+ line.icms_origin = product.icms_origin
507
+ line.cest_id = product.cest_id
508
+ line.nbs_id = product.nbs_id
509
+ line.fiscal_genre_id = product.fiscal_genre_id
510
+ line.service_type_id = product.service_type_id
511
+ if product.city_taxation_code_ids and line.company_id:
512
+ city = product.city_taxation_code_ids.filtered(
513
+ lambda r, current_line=line: r.city_id
514
+ == current_line.company_id.city_id
489
515
  )
490
- if city_id:
491
- self.city_taxation_code_id = city_id
492
- self.issqn_fg_city_id = company_city_id
493
- else:
494
- self.name = False
495
- self.fiscal_type = False
496
- self.uom_id = False
497
- self.ncm_id = False
498
- self.nbm_id = False
499
- self.tax_icms_or_issqn = False
500
- self.icms_origin = False
501
- self.cest_id = False
502
- self.nbs_id = False
503
- self.fiscal_genre_id = False
504
- self.service_type_id = False
505
- self.city_taxation_code_id = False
506
- self.uot_id = False
507
-
508
- self._compute_price_unit_fiscal()
509
- self._onchange_fiscal_operation_id()
516
+ if city:
517
+ line.city_taxation_code_id = city
518
+ line.issqn_fg_city_id = line.company_id.city_id
519
+ else:
520
+ line.city_taxation_code_id = False
521
+ line.issqn_fg_city_id = False
522
+ else:
523
+ line.city_taxation_code_id = False
524
+ line.issqn_fg_city_id = False
510
525
 
511
526
  def _prepare_fields_issqn(self, tax_dict):
512
527
  self.ensure_one()
@@ -762,11 +777,18 @@ class FiscalDocumentLineMixinMethods(models.AbstractModel):
762
777
  )
763
778
  line.fiscal_tax_ids = fiscal_taxes + taxes
764
779
 
765
- @api.depends("uom_id")
780
+ @api.depends("product_id", "uom_id")
766
781
  def _compute_uot_id(self):
767
782
  for line in self:
768
- if not line.uot_id:
769
- line.uot_id = line.uom_id
783
+ if line.uom_id:
784
+ line.uot_id = line.uom_id.id
785
+ elif line.product_id:
786
+ if line.product_id.uot_id:
787
+ line.uot_id = line.product_id.uot_id.id
788
+ else:
789
+ line.uot_id = line.product_id.uom_id.id
790
+ else:
791
+ line.uot_id = False
770
792
 
771
793
  @api.onchange("price_unit")
772
794
  def _onchange_price_unit_fiscal(self):
@@ -126,7 +126,7 @@ class FiscalDocumentMixin(models.AbstractModel):
126
126
  help="Amount without discount.",
127
127
  )
128
128
 
129
- amount_untaxed = fields.Monetary(
129
+ fiscal_amount_untaxed = fields.Monetary(
130
130
  compute="_compute_fiscal_amount",
131
131
  store=True,
132
132
  )
@@ -394,12 +394,12 @@ class FiscalDocumentMixin(models.AbstractModel):
394
394
  store=True,
395
395
  )
396
396
 
397
- amount_tax = fields.Monetary(
397
+ fiscal_amount_tax = fields.Monetary(
398
398
  compute="_compute_fiscal_amount",
399
399
  store=True,
400
400
  )
401
401
 
402
- amount_total = fields.Monetary(
402
+ fiscal_amount_total = fields.Monetary(
403
403
  compute="_compute_fiscal_amount",
404
404
  store=True,
405
405
  )
@@ -73,7 +73,8 @@ class FiscalDocumentMixinMethods(models.AbstractModel):
73
73
  def _get_amount_fields(self):
74
74
  """Get all fields with 'amount_' prefix"""
75
75
  fields = self.env["l10n_br_fiscal.document.mixin"]._fields.keys()
76
- amount_fields = [f for f in fields if f.startswith("amount_")]
76
+ prefixes = ("amount_", "fiscal_amount_")
77
+ amount_fields = [f for f in fields if f.startswith(prefixes)]
77
78
  return amount_fields
78
79
 
79
80
  @api.depends("document_serie_id", "issuer")
@@ -198,152 +199,37 @@ class FiscalDocumentMixinMethods(models.AbstractModel):
198
199
  elif doc.comment_ids is None:
199
200
  doc.comment_ids = []
200
201
 
201
- def _inverse_amount_freight(self):
202
- for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
203
- if (
202
+ def _distribute_amount_to_lines(self, amount_field_name, line_field_name):
203
+ for record in self:
204
+ if not (
204
205
  record.delivery_costs == "total"
205
206
  or record.force_compute_delivery_costs_by_total
206
207
  ):
207
- amount_freight_value = record.amount_freight_value
208
- if all(record._get_product_amount_lines().mapped("freight_value")):
209
- amount_freight_old = sum(
210
- record._get_product_amount_lines().mapped("freight_value")
211
- )
212
- for line in record._get_product_amount_lines()[:-1]:
213
- line.freight_value = amount_freight_value * (
214
- line.freight_value / amount_freight_old
215
- )
216
- record._get_product_amount_lines()[-1].freight_value = (
217
- amount_freight_value
218
- - sum(
219
- line.freight_value
220
- for line in record._get_product_amount_lines()[:-1]
221
- )
222
- )
223
- else:
224
- amount_total = sum(
225
- record._get_product_amount_lines().mapped("price_gross")
208
+ continue
209
+ lines = record._get_product_amount_lines()
210
+ if not lines:
211
+ continue
212
+ amount_to_distribute = record[amount_field_name]
213
+ total_gross = sum(lines.mapped("price_gross"))
214
+ if total_gross > 0:
215
+ distributed_amount = 0
216
+ for line in lines[:-1]:
217
+ proportional_amount = record.currency_id.round(
218
+ amount_to_distribute * (line.price_gross / total_gross)
226
219
  )
227
- for line in record._get_product_amount_lines()[:-1]:
228
- if line.price_gross and amount_total:
229
- line.freight_value = amount_freight_value * (
230
- line.price_gross / amount_total
231
- )
232
- record._get_product_amount_lines()[-1].freight_value = (
233
- amount_freight_value
234
- - sum(
235
- line.freight_value
236
- for line in record._get_product_amount_lines()[:-1]
237
- )
238
- )
239
- for line in record._get_product_amount_lines():
240
- line._onchange_fiscal_taxes()
241
- record._fields["amount_total"].compute_value(record)
242
- record.write(
243
- {
244
- name: value
245
- for name, value in record._cache.items()
246
- if record._fields[name].compute == "_amount_all"
247
- and not record._fields[name].inverse
248
- }
249
- )
220
+ line[line_field_name] = proportional_amount
221
+ distributed_amount += proportional_amount
222
+ lines[-1][line_field_name] = amount_to_distribute - distributed_amount
223
+ else:
224
+ lines.write({line_field_name: 0.0})
225
+ if lines:
226
+ lines[0][line_field_name] = amount_to_distribute
227
+
228
+ def _inverse_amount_freight(self):
229
+ self._distribute_amount_to_lines("amount_freight_value", "freight_value")
250
230
 
251
231
  def _inverse_amount_insurance(self):
252
- for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
253
- if (
254
- record.delivery_costs == "total"
255
- or record.force_compute_delivery_costs_by_total
256
- ):
257
- amount_insurance_value = record.amount_insurance_value
258
- if all(record._get_product_amount_lines().mapped("insurance_value")):
259
- amount_insurance_old = sum(
260
- record._get_product_amount_lines().mapped("insurance_value")
261
- )
262
- for line in record._get_product_amount_lines()[:-1]:
263
- line.insurance_value = amount_insurance_value * (
264
- line.insurance_value / amount_insurance_old
265
- )
266
- record._get_product_amount_lines()[-1].insurance_value = (
267
- amount_insurance_value
268
- - sum(
269
- line.insurance_value
270
- for line in record._get_product_amount_lines()[:-1]
271
- )
272
- )
273
- else:
274
- amount_total = sum(
275
- record._get_product_amount_lines().mapped("price_gross")
276
- )
277
- for line in record._get_product_amount_lines()[:-1]:
278
- if line.price_gross and amount_total:
279
- line.insurance_value = amount_insurance_value * (
280
- line.price_gross / amount_total
281
- )
282
- record._get_product_amount_lines()[-1].insurance_value = (
283
- amount_insurance_value
284
- - sum(
285
- line.insurance_value
286
- for line in record._get_product_amount_lines()[:-1]
287
- )
288
- )
289
- for line in record._get_product_amount_lines():
290
- line._onchange_fiscal_taxes()
291
- record._fields["amount_total"].compute_value(record)
292
- record.write(
293
- {
294
- name: value
295
- for name, value in record._cache.items()
296
- if record._fields[name].compute == "_amount_all"
297
- and not record._fields[name].inverse
298
- }
299
- )
232
+ self._distribute_amount_to_lines("amount_insurance_value", "insurance_value")
300
233
 
301
234
  def _inverse_amount_other(self):
302
- for record in self.filtered(lambda doc: doc._get_product_amount_lines()):
303
- if (
304
- record.delivery_costs == "total"
305
- or record.force_compute_delivery_costs_by_total
306
- ):
307
- amount_other_value = record.amount_other_value
308
- if all(record._get_product_amount_lines().mapped("other_value")):
309
- amount_other_old = sum(
310
- record._get_product_amount_lines().mapped("other_value")
311
- )
312
- for line in record._get_product_amount_lines()[:-1]:
313
- line.other_value = amount_other_value * (
314
- line.other_value / amount_other_old
315
- )
316
- record._get_product_amount_lines()[-1].other_value = (
317
- amount_other_value
318
- - sum(
319
- line.other_value
320
- for line in record._get_product_amount_lines()[:-1]
321
- )
322
- )
323
- else:
324
- amount_total = sum(
325
- record._get_product_amount_lines().mapped("price_gross")
326
- )
327
- for line in record._get_product_amount_lines()[:-1]:
328
- if line.price_gross and amount_total:
329
- line.other_value = amount_other_value * (
330
- line.price_gross / amount_total
331
- )
332
- record._get_product_amount_lines()[-1].other_value = (
333
- amount_other_value
334
- - sum(
335
- line.other_value
336
- for line in record._get_product_amount_lines()[:-1]
337
- )
338
- )
339
- for line in record._get_product_amount_lines():
340
- line._onchange_fiscal_taxes()
341
- record._fields["amount_total"].compute_value(record)
342
- record.write(
343
- {
344
- name: value
345
- for name, value in record._cache.items()
346
- if record._fields[name].compute == "_amount_all"
347
- and not record._fields[name].inverse
348
- }
349
- )
235
+ self._distribute_amount_to_lines("amount_other_value", "other_value")
@@ -104,7 +104,7 @@ class DocumentRelated(models.Model):
104
104
  return False
105
105
 
106
106
  self.document_type_id = related.document_type_id
107
- self.document_total_amount = related.amount_total
107
+ self.document_total_amount = related.fiscal_amount_total
108
108
  self.document_total_weight = related.total_weight
109
109
 
110
110
  if related.document_type_id.electronic:
@@ -372,7 +372,7 @@ ul.auto-toc {
372
372
  !! This file is generated by oca-gen-addon-readme !!
373
373
  !! changes will be overwritten. !!
374
374
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375
- !! source digest: sha256:6d439f3c16eaafae1797075248c0e7d9e232a6d5c442820570e1862755505c00
375
+ !! source digest: sha256:306bfd80e3ccb9e7d199cfffc21bda642881eece97f1763ad8f6009904d198f4
376
376
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377
377
  <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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-brazil/tree/18.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-18-0/l10n-brazil-18-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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378
378
  <p><img alt="image" src="https://raw.githubusercontent.com/OCA/l10n-brazil/18.0/l10n_br_fiscal/static/img/fiscal_dashboard.png" /></p>