Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

From Python, how to link stages to project?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
projectstagespythontask
3 Risposte
8700 Visualizzazioni
Avatar
Kevin Lemaire

For each Project, I have a list of Stages that needs to be created. For each of those Stages, I will also have Tasks... From python, how do I link Stages to Project?


Currently, in a module that inherit from "project.project", I simply do:

self.env['project.task.type'].create({'name': stage_name})

I've seen that stage model have a 'project_ids' field but I don't succeed to append to it from python.
​

Any help will be appreciated

0
Avatar
Abbandona
Avatar
Ajeet Yadav (Softprime Consulting Pvt Ltd)
Risposta migliore

In stage there is project_ids field M2M with project. This is the stages that show in projects's task.

You need to link project in state for link all their tasks.

Below module also usefull for define default stage of each new project-

https://www.odoo.com/apps/modules/12.0/project_task_default_stage/

4
Avatar
Abbandona
Avatar
Samo Arko
Risposta migliore

I have a default field in the project.task.type model to define that the stage is on a new project and normally another many2one field to define the stage usage. 

default_stage = fields.Boolean(string='Stage on new project', default=False)

Then I just extended the project create method to add the default stages to new projects.

@api.model
def create(self, vals):
    ir_values = self.env['ir.values'].get_default('project.config.settings', 'generate_project_alias')
    if ir_values:
         vals['alias_name'] = vals.get('alias_name') or vals.get('name')
         # Prevent double project creation when 'use_tasks' is checked
         self = self.with_context(project_creation_in_progress=True, mail_create_nosubscribe=True)

         default_stages = self.env['project.task.type'].sudo().search([('default_stage', '=', True)])
         stages_list = list()
         for stage in default_stages:
            stages_list.append((4, stage.id))

         if len(stages_list) > 0:
            vals['stage_ids'] = stages_list

         new_project = super(TablaProjectProjectExtension, self).create(vals)
         return new_project 

0
Avatar
Abbandona
Avatar
SLIFE AFRICA
Risposta migliore

Try this code please :)


from odoo import models, api, fields, SUPERUSER_ID, _

class ProjectTaskType(models.Model):
_inherit = 'project.task.type'

# Step specific code to identify it
code = fields.Char('Code')

_sql_constraints = [
('code_uniq', 'unique (code)', "Stage code already exists!"),
]

class Project(models.Model):
_inherit = 'project.project'

@api.model
def _read_group_stage_ids(self, stages, domain, order):
# Call Super Function
response = super(Task, self)._read_group_stage_ids(stages, domain, order)
search_domain = [('id', 'in', response.ids)]
# Append my specifik stages [Stages whose code is equal to todo or inprogress or done or canceled]
search_domain = ['|', ('code', 'in', ['todo', 'inprogress', 'done', 'canceled'])] + search_domain
stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID)
return stages.browse(stage_ids)
0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Allow "Project / Users" creating new task stages (Kanban view) Risolto
project stages task groups
Avatar
Avatar
Avatar
2
mar 25
3211
How to "lock" task at a certain stage. Risolto
project stages task odoo10
Avatar
Avatar
2
ott 24
6716
Why the stages (project_task_type) of project are not reusables?
project stages task type
Avatar
Avatar
1
mar 17
5410
v16 Tasks visibility
project task
Avatar
Avatar
1
giu 23
4133
"Stages" menu is not showing in the Project module. Risolto
project stages
Avatar
Avatar
Avatar
2
mar 23
3449
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now