Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Help

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to change a state when a field in res.partner is updated?

Odoberať

Get notified when there's activity on this post

This question has been flagged
functionpartnercustomerres.partnerodoo10
1 Odpoveď
10034 Zobrazenia
Avatar
wizardz

Hi.

I want to make a little change to the def write() function in res.partner.

My first problem is, that I don't find the function "write" in official Odoo10 module "account" in the partner.py file.

The second problem is, that I don't know how I can check if any field is changed. I need to check that and then when something changed I need to set the "state to draft". 


So for example:

@api.model
def write(self):
self.write({'state': 'draft'})
return True


Thank you


update:

I have this 2 functions:

@api.multi
def confirm_customer(self):
self.state = 'confirmed'
return True
@api.multi
def write(self, data):
res = super(Partner, self).write(data)
if self.state == 'confirmed':
self.state = 'draft'
return res

After I click my button "confirm_customer" it should go to state=confirmed. It works fine without the "def write" function.

But with the write function it doesn't work.

Now it didn't change the "confirm_customer" state to confirm. It stays all the time on draft.







0
Avatar
Zrušiť
Mohammed Amal N

When you use self.a_field = 'some_value' write function is called. So when you call self.state = 'confirm' it will go to write. Write your functions accordingly

also in your write function don't use self.field = 'a_value' pass values by dictionary

wizardz
Autor

so I need to write something like this : vals (dict) vals{'foo': 1, 'bar': "Qux"}

wizardz
Autor

I mean, I have no idea how I can change a value without using the .write() method...

wizardz
Autor

any solution on that problem ?

Avatar
Mohammed Amal N
Best Answer

Hello,

I think you cant use self.write in def write as it will create a recurring problem.

What you can do is to pass values as dictionary in write function

an example to see stage_id and changed stage_id of hr_recruitment

@api.multi
def write(self, data):
res = super(YourClassName, self).write(data)
print data['stage_id'], data['last_stage_id']
return res


2
Avatar
Zrušiť
wizardz
Autor

Thank you Mohammed. I fixed my problem with this: data['state'] = 'draft'

wizardz
Autor

I have a new problem now, my other buttons doesn't work now. because it's going in the write method everytime...

Mohammed Amal N

sorry. i don't get your problem correctly. Can you explain it a little more

wizardz
Autor

I updated the question above , thank you

Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
What is the usefulness of the field "date" in res_partner? Solved
partner customer res.partner
Avatar
Avatar
Avatar
3
feb 18
4633
Field position in Odoo 15
customer res.partner
Avatar
Avatar
1
okt 25
1693
Extending res.partner - first custom field worked, second raises "ProgrammingError: column ... does not exist" - what did I do wrong? Solved
res.partner odoo10
Avatar
Avatar
Avatar
Avatar
Avatar
8
apr 23
19803
Is there a differnce? commercial_company_name vs company_name Solved
res.partner odoo10
Avatar
Avatar
2
dec 16
7146
Add record to Many2many field from Many2one field
partner customer
Avatar
0
mar 16
5492
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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