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

subtraction of invoice tamount_total from custom model amount field

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
2 Odpowiedzi
990 Widoki
Awatar
Deen Islam
def action_generate_bill(self):
# Assuming you have necessary information for creating the invoice
invoice_data = {
# 'payment_reference': self.type_id.id, # Replace with the actual partner field in your model
# 'partner_id': self.user_id.id, # Replace with other necessary fields
'move_type': 'out_invoice' # if it is an invoice otherwise in_invoice if it is a bill
# Add more fields as needed
}

# Create a new invoice
new_invoice = self.env['account.move'].create(invoice_data)

# Find the corresponding baba.approve record based on type_id

approve_record = self.env['baba.approval'].search([('type_id', '=', self.type_id.id)])

# If a matching record is found, create invoice lines with adjusted amounts
if approve_record:
for line in new_invoice.invoice_line_ids:
line.price_unit -= approve_record.approve_amount

# Open the form view of the newly created invoice
action = {
'type': 'ir.actions.act_window',
'res_model': 'account.move',
'view_mode': 'form',
'res_id': new_invoice.id,
}

return action
here is my function when i clcik on this button then it take me to account.nove invoice
i have add a a many2one field in both model to tract the same
class MultiApproval(models.Model):
_name = 'baba.approval'
type_id = fields.Many2one(
string="Type", comodel_name="baba.approval.type", required=True)
class AccountAmount(models.Model):
_inherit = "account.move"
type_id = fields.Many2one(
string="Type", comodel_name="baba.approval.type", required=True)
in my baba.approval model there is a field
approve_amount = fields.Float('Approved Amount') here i define the amount now i want when type_id is same in the both model then what price i add in the account.move model amount_total filed value is subtraction from approve_amount
examle is my approve amount is 5000 and in the same type_id amount_total is 3000 then my approve_amount automatically will be 2000 when this invoice is in posted state
how i do this


0
Awatar
Odrzuć
Awatar
Deen Islam
Autor Najlepsza odpowiedź

hi james 
thanks for your support 

type_id = fields.Many2one(
string="Type", comodel_name="baba.approval.type", required=True)
approve_amount = fields.Float('Approved Amount',compute='_compute_approve_amount')

@api.depends('type_id')
def _compute_approve_amount(self):
if self.new_invoice.state == 'posted' and self.new_invoice and self.type_id == self.new_invoice.type_id:
self.approve_amount = self.approve_amount - self.new_invoice.amount_total
def action_generate_bill(self):
# Assuming you have necessary information for creating the invoice
invoice_data = {
# 'payment_reference': self.type_id.id, # Replace with the actual partner field in your model
# 'partner_id': self.user_id.id, # Replace with other necessary fields
'move_type': 'out_invoice' # if it is an invoice otherwise in_invoice if it is a bill
# Add more fields as needed
}

# Create a new invoice
new_invoice = self.env['account.move'].create(invoice_data)

# Find the corresponding baba.approve record based on type_id
approve_record = self.env['baba.approval'].search([('type_id', '=', self.type_id.id)])

# If a matching record is found, create invoice lines with adjusted amounts
if approve_record:
for line in new_invoice.invoice_line_ids:
line.price_unit -= approve_record.approve_amount

# Open the form view of the newly created invoice
action = {
'type': 'ir.actions.act_window',
'res_model': 'account.move',
'view_mode': 'form',
'res_id': new_invoice.id,
}

return action
i have try this but its not wokring
here i want from my approve_amount field of same type_Id in account.move model amount_total will be substraction when the innvoice is in posted state



0
Awatar
Odrzuć
Awatar
Mily Shajan
Najlepsza odpowiedź

Hi Deen 

check the code following, 

assign created new_invoice record to a many2one of 'account.move'  in your model 

class MultiApproval(models.Model):
_name = 'baba.approval'

type_id = fields.Many2one(
string="Type", comodel_name="baba.approval.type", required=True)
approve_amount = fields.Float('Approved Amount',compute='_compute_approve_amount')

@api.depends('type_id')
def _compute_approve_amount(self):
if self.new_invoice.state == 'posted' and self.new_invoice and self.type_id == self.new_invoice.type_id:
self.approve_amount = self.approve_amount - self.new_invoice.amount_total

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ę
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