Guard invoice fiscal defaults on partial records
Publicar paquete PyPI / publish (push) Successful in 2m52s

This commit is contained in:
José Arturo García
2026-10-01 00:48:17 -04:00
parent a76e794304
commit 78e6c2bad2
+15 -4
View File
@@ -799,8 +799,9 @@ class Invoice(metaclass=PoolMeta):
"Return an invoice default configured on account configuration." "Return an invoice default configured on account configuration."
Configuration = Pool().get('account.configuration') Configuration = Pool().get('account.configuration')
config = Configuration(1) config = Configuration(1)
company = getattr(self, 'company', None)
company_id = ( company_id = (
self.company.id if self.company company.id if company
else Transaction().context.get('company')) else Transaction().context.get('company'))
if company_id: if company_id:
@@ -814,16 +815,26 @@ class Invoice(metaclass=PoolMeta):
Apply configured fiscal reporting defaults without replacing values Apply configured fiscal reporting defaults without replacing values
already selected by the user or copied from another invoice. already selected by the user or copied from another invoice.
""" """
if self.type == 'out' and not self.revenue_type: invoice_type = getattr(self, 'type', None)
if (
invoice_type == 'out'
and 'revenue_type' in self.__class__._fields
and not getattr(self, 'revenue_type', None)):
self.revenue_type = ( self.revenue_type = (
self._ncf_get_configuration_default_invoice_field( self._ncf_get_configuration_default_invoice_field(
'default_customer_revenue_type')) 'default_customer_revenue_type'))
elif self.type == 'in' and not self.expense_type: elif (
invoice_type == 'in'
and 'expense_type' in self.__class__._fields
and not getattr(self, 'expense_type', None)):
self.expense_type = ( self.expense_type = (
self._ncf_get_configuration_default_invoice_field( self._ncf_get_configuration_default_invoice_field(
'default_supplier_expense_type')) 'default_supplier_expense_type'))
if not self.payment_method: if (
'payment_method' in self.__class__._fields
and not getattr(self, 'payment_method', None)):
self.payment_method = ( self.payment_method = (
self._ncf_get_configuration_default_invoice_field( self._ncf_get_configuration_default_invoice_field(
'default_payment_method')) 'default_payment_method'))