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

Field default do not work

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
invoicedefaultinheritanceodoo12
4 Odpowiedzi
8737 Widoki
Awatar
Maks

I've been working on a module for interests. What I have to do is to make possible to create an invoice which has interests from overdue invoices as invoice lines. To do this, I need to pass few fields to another window with new invoice creation. Here is my problem. I tried to pass field value of invoice comment as a test. But when I add comment field with additional default, I noticed, that default is not read at all. When I edit this field in different way (e.g. I add readonly=False) then changes are visible. Only default do not work. Anyone know why?

Original field:

comment = fields.Text('Additional Information', readonly=True, states={'draft': [('readonly', False)]})


Class that inherit account.invoice:


class InterestNote(models.Model):
_inherit = 'account.invoice'
_translate = True

interest_paid = fields.Boolean(string='Are interests paid?', help='Boolean to see if interests are already paid.',
default=False)

@api.multi
def interest_note(self):
_logger.info(f'ID FAKTURY: {self.id}')
_logger.info(f'NUMER FAKTURY: {self.number}')
_logger.info(f'PARTNER: {self.partner_id}')
_logger.info(f'COMMENT: {self.comment}')
_logger.info(f'COMMENT TYP: {type(self.comment)}')
com = self.comment
_logger.info(f'COM: {com}')
_logger.info(f'COM TYPE: {type(com)}')

return {
'name': 'Create new interest note',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'account.invoice',
'context': {'t_comment': com},
'target': 'new'
}

@api.model
def get_comment_test(self):
_logger.info('FUNKCJA TEST ROZPOCZYNA SIĘ')
test_com = self.env.context.get('t_comment')
_logger.info(f'TEST COM: {test_com}')
_logger.info(f'TEST COM TYPE: {type(test_com)}')

if not test_com:
test_com = ''

return test_com

comment = fields.Text('Additional Information', default=get_comment_test,
readonly=False, states={'draft': [('readonly', False)]})

Method interest_note works fine, it is callable but button and when I clicked it, the log messages appear normally. What should happen, is after clicking the button, new windows to create an invoice pop up, with filled comment field, after the invoice from which the button was clicked. When I write default='get_comment_test' it also do not work. So the get_comment_test method, but with default. Logger message from this method never showed up on logs. Funny thing is that in Odoo 11 I've done something almost identical and it worked. Only in 12 I have this issue. Anyone have an idea what is going on?

0
Awatar
Odrzuć
Gleb

Here is an example (odoo v12):

Call new form and set three fields by default value (order_id, partner_id, order_line)

return {

'name': _('Check'),

'view_type': 'form',

'view_mode': 'form',

'res_model': 'check.purchase.order.lines',

'views': [

(form_view.id, 'form'),

],

'type': 'ir.actions.act_window',

'target': 'current',

'context': {

'default_order_id': self.id,

'default_partner_id': self.partner_id.id,

'default_order_line': self.get_unverified_record_ids()

},

Standard construction: write 'context': {'default_field_name': value}

In your example: write 'context': {'default_t_comment': com}

Maks
Autor

@Gleb I have no idea what are you writing. It has no connection to invoices... I tried to convert it to my example and it didn't work anyway. My question is simple really. Why it do not work? Show me error in my code, and write correction. Not entire examples, which are not connected to my issue and solving nothing.

Awatar
Maks
Autor Najlepsza odpowiedź

@Zbik

Hello. I tried adding view_id, because everything else I have the same (without target) and still it doesn't work. What I found interesting, is that on one field, my default works just fine. In comment it doesn't.


class InterestNote(models.Model):
_inherit = 'account.invoice'
_translate = True

interest_paid = fields.Boolean(string='Are interests paid?', help='Boolean to see if interests are already paid.',
default=False)
# tester = fields.Text(string='TEST', default=get_comment_test)

@api.multi
def interest_note(self):
_logger.info(f'ID FAKTURY: {self.id}')
_logger.info(f'NUMER FAKTURY: {self.number}')
_logger.info(f'PARTNER: {self.partner_id}')
_logger.info(f'COMMENT: {self.comment}')
_logger.info(f'COMMENT TYP: {type(self.comment)}')
com = self.comment
# ctx = dict(
# type='out_invoice',
# comment=com
# )
_logger.info(f'COM: {com}')
_logger.info(f'COM TYPE: {type(com)}')

# inv_obj = self.env['account.invoice']
# inv = inv_obj.create(ctx)
# _logger.info(f'ID FAKTURY INV: {inv.id}')
# return {'type': 'ir.actions.act_window_close'}

return {
'name': 'Create new interest note',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'view_id': self.env.ref('account.invoice_form').id,
'res_model': 'account.invoice',
'context': {
'type': 'out_invoice',
'default_type': 'out_invoice',
'comment': com,
'default_comment': com
},
'target': 'current'
}

@api.model
def get_comment_test(self):
_logger.info('FUNKCJA TEST ROZPOCZYNA SIĘ')
test_com = self.env.context.get('comment')
_logger.info(f'TEST COM: {test_com}')
_logger.info(f'TEST COM TYPE: {type(test_com)}')

if not test_com:
test_com = '456'

return test_com

comment = fields.Text('Additional Information', default=get_comment_test,
readonly=True, states={'draft': [('readonly', False)]})
tester = fields.Text(string='TEST', default=get_comment_test)

Field comment is still without any values when new invoice, but field tester works. Why is that? It's so confusing right now, I really do not understand why in one field something works, but in another it doesn't.

0
Awatar
Odrzuć
Zbik

Steps:

1. Your module set comment - for example: comment = "XYZ"

2. Now is started method in module sale

3. Field invoice comment is set in module sale - in this case comment = self.env.user.company_id.sale_note

4. sale_note is porobably False => in effect comment = False

Maks
Autor

What? My module is inheriting an "account.invoice", and field comment is also in this module. What I'm trying to do is to create an invoice from within another invoice, and pass a field to newly created one. It has nothing to do with sale. And I already told my issue few times, I really don't know why people on this forum so often act like they don't know the question, but they give an answer anyway. My methods works. Method get_comment_test works. In field tester everything seems fine, default method get_comment_test work. This do not work only in comment. default for comment do not work, where change in readonly is working, so only this default on this particular field cause problems. Does anyone know why, and how to solve it?

Zbik

If you have the module sale installed and field "Default Terms & Conditions" in sale config is checked, value in field comment depends on it. Too bad you do not understand. Insert "LOREM IPSUM" in Default Terms & Conditions and see on effect.

Awatar
Zbik
Najlepsza odpowiedź

Your problem is probably related to something else.
In module sele field comment is redefined too.
See:
def _default_comment(self):
invoice_type = self.env.context.get('type', 'out_invoice')
if invoice_type == 'out_invoice' and self.env['ir.config_parameter'].sudo().get_param('sale.use_sale_note'):
return self.env.user.company_id.sale_note

comment = fields.Text(default=_default_comment)

If your module not depends on sale then result in this field may be different than you expect .

PS. It is easier to use (if sale not inherit, without redefinition the commment field):  

return {
  'name': 'Create new interest note',
  'type': 'ir.actions.act_window',
  'view_type': 'form',
  'view_mode': 'form',
  'view_id': self.env.ref('account.invoice_form').id,
  'res_model': 'account.invoice',
  'context': {'type':'out_invoice', 'default_type': 'out_invoice', 'default_comment': com },
  'target': 'new'
}


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ść
Override journal default on account_invoice
invoice default inheritance models
Awatar
0
lut 16
4211
Override and Change the middle of a function Rozwiązane
inheritance odoo12
Awatar
Awatar
Awatar
Awatar
7
cze 24
26133
Function inheritance
inheritance odoo12
Awatar
0
wrz 20
2982
Open an invoice using XMLRPC
invoice odoo12
Awatar
Awatar
2
maj 20
5811
How to modify validated invoice?
invoice odoo12
Awatar
Awatar
Awatar
2
lis 18
4974
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