[IMP]pms: compute enoguht partner data to invoice

This commit is contained in:
Darío Lodeiros
2022-02-22 23:04:29 +01:00
parent 57c88f7478
commit 2418127f87
2 changed files with 15 additions and 2 deletions

View File

@@ -1797,14 +1797,14 @@ class PmsFolio(models.Model):
self.ensure_one()
pms_property = self.pms_property_id
partner = self.env["res.partner"].browse(partner_invoice_id)
if not partner.document_number_to_invoice and self._context.get("autoinvoice"):
if not partner._enought_invoice_data() and self._context.get("autoinvoice"):
return pms_property.journal_simplified_invoice_id
return pms_property.journal_normal_invoice_id
def _get_default_move_type(self, partner_invoice_id):
self.ensure_one()
partner = self.env["res.partner"].browse(partner_invoice_id)
if not partner.document_number_to_invoice and self._context.get("autoinvoice"):
if not partner._enought_invoice_data() and self._context.get("autoinvoice"):
return "out_receipt"
return "out_invoice"

View File

@@ -554,3 +554,16 @@ class ResPartner(models.Model):
key_fields = super(ResPartner, self)._get_key_fields()
key_fields.extend(["document_number"])
return key_fields
def _enought_invoice_data(self):
self.ensure_one()
if (
self.document_number_to_invoice
and not self.country_id
and not self.state_id
and not self.city
and not self.zip
and not self.street
):
return True
return False