From 3848c409a81640307719fd57e4fa41c698b9973c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Mil=C3=A9o?= Date: Tue, 24 Sep 2024 22:54:07 -0300 Subject: [PATCH 1/2] [FIX] l10n_br_pos_nfce related serie MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Miléo --- l10n_br_pos_nfce/models/pos_config.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/l10n_br_pos_nfce/models/pos_config.py b/l10n_br_pos_nfce/models/pos_config.py index dfbdeef3288a..30099e341d4a 100644 --- a/l10n_br_pos_nfce/models/pos_config.py +++ b/l10n_br_pos_nfce/models/pos_config.py @@ -27,19 +27,13 @@ class PosConfig(models.Model): nfce_document_serie_sequence_number_next = fields.Integer( string="Document Serie Number", - default=lambda self: self._default_next_number(), + related="nfce_document_serie_id.internal_sequence_id.number_next_actual", ) nfce_city_ibge_code = fields.Char( related="company_id.city_id.ibge_code", ) - def _default_next_number(self): - if not self.nfce_document_serie_id: - return 1 - - return self.nfce_document_serie_id.internal_sequence_id.number_next_actual - def update_nfce_serie_number(self, serie_number): if self.nfce_document_serie_sequence_number_next < serie_number: self.nfce_document_serie_sequence_number_next = serie_number From b2b0acb64924fc7a1a19cfa955c400f3c4ecd4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Mil=C3=A9o?= Date: Tue, 24 Sep 2024 22:54:54 -0300 Subject: [PATCH 2/2] [FIX] l10n_br_fiscal check anonymous customer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Miléo --- l10n_br_fiscal/models/res_partner.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/l10n_br_fiscal/models/res_partner.py b/l10n_br_fiscal/models/res_partner.py index b173a2944573..b252c826a584 100644 --- a/l10n_br_fiscal/models/res_partner.py +++ b/l10n_br_fiscal/models/res_partner.py @@ -2,7 +2,7 @@ # Copyright (C) 2020 - TODAY Luis Felipe Mileo - KMEE # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from odoo import api, fields, models +from odoo import _, api, fields, models from ..constants.fiscal import ( FINAL_CUSTOMER, @@ -136,3 +136,9 @@ def _commercial_fields(self): "inscr_est", "inscr_mun", ] + + @api.constrains("is_anonymous_consumer") + def _check_anonymous_consumer(self): + for p in self: + if p.is_anonymous_consumer and p.cnpj_cpf: + raise ValueError(_("Anonymous consumer cannot have a CNPJ/CPF number."))