Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Sale order line description to purchase order line.

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
purchasesalesale.order.linepurchase_orderpurchase.order
1 Odpowiedz
5160 Widoki
Awatar
Reddecon s.a.

Hello! 


I´m trying to map the description (record.name) in sale.order.line to description (record.name) in purchase order line when sale order is confirmed.


Thanks for your help!

0
Awatar
Odrzuć
Ankit Vaghela

Hello..!!

can you describe more about your issue?

Reddecon s.a.
Autor

Hi Ankit!

Thanks for your answer. The problem is some of my product have some atributes and values that are not visible in the purchase order request created from confirmed sale order and i need them to be visible for the vendor.

Thanks for your help.

Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

Hi,

For that you will need to customize the default _run_buy function.

Try to rewrite _run_buy function like below.

from collections import defaultdict
from dateutil.relativedelta import relativedelta
from itertools import groupby
from odoo import api, fields, models, SUPERUSER_ID, _
from odoo.addons.stock.models.stock_rule import ProcurementException


class StockRule(models.Model):
_inherit = 'stock.rule'

@api.model
def _run_buy(self, procurements):
""" passing manually entered product description when route is
make_to_order """
procurements_by_po_domain = defaultdict(list)
errors = []
for procurement, rule in procurements:

# Get the schedule date in order to find a valid seller
procurement_date_planned = fields.Datetime.from_string(
procurement.values['date_planned'])
schedule_date = (procurement_date_planned - relativedelta(
days=procurement.company_id.po_lead))

supplier = False
if
procurement.values.get('supplierinfo_id'):
supplier = procurement.values['supplierinfo_id']
else:
supplier = procurement.product_id.with_company(
procurement.company_id.id)._select_seller(
partner_id=procurement.values.get("supplierinfo_name"),
quantity=procurement.product_qty,
date=schedule_date.date(),
uom_id=procurement.product_uom)

# Fall back on a supplier for which no price may be defined.
# Not ideal, but better than blocking the user.
supplier = supplier or procurement.product_id._prepare_sellers(
False).filtered(
lambda
s: not s.company_id or s.company_id == procurement.company_id
)[:1]

if not supplier:
msg = _(
'There is no matching vendor price to generate the purchase'
'order for product %s (no vendor defined, minimum quantity'
'not reached, dates not valid, ...). Go on the product form'
'and complete the list of vendors.'
) % (
procurement.product_id.display_name)
errors.append((procurement, msg))

partner = supplier.name
# we put `supplier_info` in values for extensibility purposes
procurement.values['supplier'] = supplier
procurement.values['propagate_cancel'] = rule.propagate_cancel

domain = rule._make_po_get_domain(procurement.company_id,
procurement.values, partner)
procurements_by_po_domain[domain].append((procurement, rule))

if errors:
raise ProcurementException(errors)

for domain, procurements_rules in procurements_by_po_domain.items():
# Get the procurements for the current domain.
# Get the rules for the current domain. Their only use is to create
# the PO if it does not exist.
procurements, rules = zip(*procurements_rules)

# Get the set of procurement origin for the current domain.
origins = set([p.origin for p in procurements])
# Check if a PO exists for the current domain.
po = self.env['purchase.order'].sudo().search(
[dom for dom in domain], limit=1)
company_id = procurements[0].company_id
if not po:
# We need a rule to generate the PO. However the rule generated
# the same domain for PO and the _prepare_purchase_order method
# should only uses the common rules's fields.
vals = rules[0]._prepare_purchase_order(company_id, origins,
[p.values for p in
procurements])
# The company_id is the same for all procurements since
# _make_po_get_domain add the company in the domain.
# We use SUPERUSER_ID since we don't want the current user to
# be follower of the PO.
# Indeed, the current user may be a user without access to
# Purchase, or even be a portal user.
po = self.env['purchase.order'].with_company(
company_id).with_user(SUPERUSER_ID).create(vals)
else:
# If a purchase order is found, adapt its `origin` field.
if po.origin:
missing_origins = origins - set(po.origin.split(', '))
if missing_origins:
po.write({'origin': po.origin + ', ' + ', '.join(
missing_origins)})
else:
po.write({'origin': ', '.join(origins)})

procurements_to_merge = self._get_procurements_to_merge(
procurements)
procurements = self._merge_procurements(procurements_to_merge)

po_lines_by_product = {}
grouped_po_lines = groupby(po.order_line.filtered(lambda
l: not l.display_type and l.product_uom == l.product_id.uom_po_id).sorted(
lambda l: l.product_id.id), key=lambda l: l.product_id.id)
for product, po_lines in grouped_po_lines:
po_lines_by_product[product] = self.env[
'purchase.order.line'].concat(*list(po_lines))
po_line_values = []
for procurement in procurements:
org_values = self.env['sale.order'].search(
[('name', '=', procurement.origin)])
for org in org_values.order_line:
description = org.name
po_lines = po_lines_by_product.get(
procurement.product_id.id,
self.env[
'purchase.order.line'])
po_line = po_lines._find_candidate(*procurement)

if po_line:
# If the procurement can be merge in an existing line.
# Directly write the new values on it.
vals = self._update_purchase_order_line(
description,
procurement.product_id,
procurement.product_qty, procurement.product_uom,
company_id,
procurement.values, po_line)
po_line.write(vals)
else:
# If it does not exist a PO line for current procurement.
# Generate the create values for it and add it to a list
# in order to create it in batch.
partner = procurement.values['supplier'].name

test = self.env[
'purchase.order.line']._prepare_purchase_order_line_from_procurement(
procurement.product_id, procurement.product_qty,
procurement.product_uom, procurement.company_id,
procurement.values, po)
test.update({'name': procurement.values.get(
'move_dest_ids').sale_line_id.name})
po_line_values.append(test) self.env['purchase.order.line'].sudo().create(po_line_values)

Regards

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Whom Should I Pay? From Purchase to Sale
purchase sale supplier purchase_order
Awatar
0
mar 15
4653
How to autofill sale.order.line from linked purchase.order(.line)?
purchase sale sale.order.line onchange
Awatar
Awatar
1
mar 15
8542
Purchase Create a Purchase Order copy(Sub Purchase Order) after clicking Receive Products Button
purchase purchase_order purchase.order Purchase v15
Awatar
Awatar
1
gru 22
2577
Sale order page configuration
sale.order.line purchase_order
Awatar
Awatar
1
maj 25
1763
How to generate line numbers on quotes Rozwiązane
sale sale.order.line
Awatar
Awatar
1
sty 25
4401
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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