Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to transfer/reflect documents from sale.order to project.task

Odebírat

Get notified when there's activity on this post

This question has been flagged
sale.orderproject.taskir.attachmentodoo16features
1 Odpovědět
2982 Zobrazení
Avatar
Alark Kulkarni

How to transfer/reflect documents from sale.order to project.task model? I am unable to achieve the result with my code.

The documents should not get jumbled. If sale order S0001 contains 3 documents then the project task related to S0001 should reflect 3 documents and if sale order S0003 contains 0 documents then the project task related to S0003 should reflect 0.

Please find the xml & py code below:



# -*- coding: utf-8 -*-
from odoo import api, fields, models, _

from Odoo16_Community.odoo.odoo.exceptions import AccessError


class ProjectTask(models.Model):
_inherit = 'project.task'
_description = 'Display smart button for attachments'

sale_line_id = fields.Many2one(
'sale.order.line', 'Sales Order Item',
copy=True, tracking=True, index='btree_not_null', recursive=True, store=True, readonly=True)
sale_order_id = fields.Many2one('sale.order', 'Sales Order', store=True,
help="Sales order to which the task is linked.")

display_attachment_button = fields.Boolean(string='Display Attachments',
compute='_compute_display_attachments_button')
attachment_count = fields.Integer('Attachments Count', compute='_compute_attachment_count')
attachments = fields.Char("Attachments Name", compute='_compute_attachment_name')
attachment_ids = fields.One2many(
'ir.attachment',
'res_id',
domain=[('res_model', '=', 'sale.order')],
string='Attachments'
)

def _compute_attachment_name(self):
for rec in self:
attachments = self.env['ir.attachment'].search([('res_model', '=', 'sale.order'), ('res_id', '=', rec.id)])
rec.attachments = attachments[0].name if rec.attachment_count
def _compute_attachment_count(self):
for rec in self:
attachments = self.env['ir.attachment'].search_count(
[('res_model', '=', 'sale.order'), ('res_id', '=', rec.id)])
rec.attachment_count = attachments

@api.depends('sale_line_id')
def _compute_display_attachments_button(self):
if not self.sale_line_id:
self.display_attachment_button = False
return
try:
sale_line = self.env['sale.order.line'].search([('id', 'in', self.sale_line_id.ids)])
for task in self:
task.display_attachment_button = task.sale_line_id in sale_line
except AccessError:
self.display_attachment_button = False

def action_show_attachments(self):
return {
'name': _('Attachments'),
'view_mode': 'kanban,form',
'res_model': 'ir.attachment',
'type': 'ir.actions.act_window',
'domain': [('res_model', '=', 'sale.order'), ('res_id', '=', self.id)]
}

def action_view_so(self):
return {
"type": "ir.actions.act_window",
"res_model": "sale.order",
"name": _("Sales Order"),
"views": [[False, "tree"], [False, "kanban"], [False, "form"]],
"context": {"create": False, "show_sale": True},
}

Thank you in advance.


0
Avatar
Zrušit
Avatar
Maciej Burzymowski
Nejlepší odpověď

To transfer documents from sale.order to project.task in Odoo, you need to create a relationship between these two models. This can be achieved by creating a One2many or Many2many field in the sale.order model that references the project.task model.

Here is a basic example of how you might set up this relationship in your models:


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    task_ids = fields.One2many('project.task', 'sale_order_id', string='Tasks')


class ProjectTask(models.Model):

    _inherit = 'project.task'


    sale_order_id = fields.Many2one('sale.order', string='Sale Order')

    document_ids = fields.Many2many('ir.attachment', string='Documents')


In this example, task_ids is a One2many field that gets the tasks related to the sale order, and sale_order_id is a Many2one field that gets the sale order related to the task. document_ids is a Many2many field that gets the documents related to the task.

You can then override the create and write methods in the sale.order model to update the document_ids field in the related tasks whenever a sale order is created or updated.


0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Show rental orders on main Odoo Calendar module
sale.order odoo16features
Avatar
0
dub 24
933
I want to attach a static pdf file in the Sale Order Email
email sale.order ir.attachment
Avatar
0
zář 23
2377
how to set a button in email redirecting the the sales order url Vyřešeno
sale.order mailtemplate odoo16features
Avatar
Avatar
1
zář 23
5141
Automated Action to clone a task and adding days to due date Vyřešeno
project.task AutomatedActions odoo16features
Avatar
1
lis 22
3597
What types of files will be saved when defining the path for the data_dir option in odoo.conf
attachment config ir.attachment odoo16features
Avatar
Avatar
1
bře 24
4011
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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