Skip to content

Instantly share code, notes, and snippets.

@guionardo
Last active December 1, 2022 20:51
Show Gist options
  • Save guionardo/b9223871bd08d1bb27b3e4e1e19a4630 to your computer and use it in GitHub Desktop.
Save guionardo/b9223871bd08d1bb27b3e4e1e19a4630 to your computer and use it in GitHub Desktop.
Bug OS/Contato
@admin.register(OS)
class AdminOS(DjangoObjectActions, AdminBaseModel):
list_display = ['__str__', 'situacao', # 'cliente',
'produto', 'nr_projeto', 'tempo', 'descricao', 'updated']
search_fields = ['nr_os', 'nr_projeto', 'descricao']
list_filter = ['situacao', 'produto__cliente__nome']
readonly_fields_on_update = ['created_by', 'updated'] # , 'cliente'
fields = (('data_abertura', 'solicitante'), # , 'cliente'
('produto', 'nr_projeto'),
'situacao',
'descricao',
'link_manual',
'data_fechamento',
('created_by') # 'created',
)
class Contato(BaseModel):
nome = models.CharField(max_length=100)
telefone = models.CharField(max_length=20)
email = models.CharField(max_length=100, validators=[EmailValidator()])
enabled = models.BooleanField(default=True, verbose_name='Ativo')
cliente = models.ForeignKey(
Cliente, on_delete=models.PROTECT, null=False)
setor = models.CharField(max_length=40, default="")
class OS(BaseModel):
nr_os = models.CharField(max_length=5, unique=True, editable=False)
produto = models.ForeignKey(Produto, on_delete=models.PROTECT)
nr_projeto = models.CharField(
max_length=32, null=False, unique=True, verbose_name='# Projeto')
situacao = models.CharField(
max_length=2, choices=OSSituacaoChoices.choices, default=OSSituacaoChoices.ABERTA)
solicitante = models.ForeignKey(Contato, on_delete=models.PROTECT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment