Sari la conținut
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Property Management
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Toate postările Oameni Insigne
Etichete (Vezi tot)
odoo accounting v14 pos v15
Despre acest forum
Suport

Python code from odoo16 does not work at odoo 17.

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
v17
1 Răspunde
1924 Vizualizări
Imagine profil
MT Tech, Htet Aung Shane

I have a module to hide the buttons and tab and this custom code works at odoo16, but not at odoo17

from odoo import fields, models, api, _from lxml import etree


class HideViewNodes(models.Model): _name = 'hide.view.nodes' _description = 'Hide View Nodes'

access_rights_management_id = fields.Many2one('access.rights.management', 'Access Management') model_id = fields.Many2one('ir.model', string='Model', index=True, required=True, ondelete='cascade') model_name = fields.Char(string='Model Name', related='model_id.model', readonly=True, store=True)

btn_store_model_nodes_ids = fields.Many2many('store.model.nodes', 'btn_hide_view_nodes_store_model_nodes_rel', 'hide_id', 'store_id', string='Hide Button', domain="[('node_option','=','button')]") page_store_model_nodes_ids = fields.Many2many('store.model.nodes', 'page_hide_view_nodes_store_model_nodes_rel', 'hide_id', 'store_id', string='Hide Tab/Page', domain="[('node_option','=','page')]")

def _store_btn_data(self, btn, smart_button=False, smart_button_string=False): # string_value is used in case of kanban view button store, string_value = 'string_value' in self._context.keys() and self._context['string_value'] or False

store_model_button_obj = self.env['store.model.nodes'] name = btn.get('string') or string_value if smart_button: name = smart_button_string store_model_button_obj.create({ 'model_id': self.model_id.id, 'node_option': 'button', 'attribute_name': btn.get('name'), 'attribute_string': name, 'button_type': btn.get('type'), 'is_smart_button': smart_button, })

def _get_smart_btn_string(self, btn_list, type=False): store_model_button_obj = self.env['store.model.nodes']

def _get_span_text(span_list): name = '' for sp in span_list: if sp.text: name = name + ' ' + sp.text name = name.strip() return name

for btn in btn_list: name = '' field_list = btn.findall('field') if field_list: name = field_list[0].get('string') else: span_list = btn.findall('span') if span_list: name = _get_span_text(span_list) else: div_list = btn.findall('div') if div_list: span_list = div_list[0].findall('span') if span_list: name = _get_span_text(span_list) if not name: try: name = btn.get('string') except: pass if name and (type == 'object' or type == 'action'): domain = [('button_type', '=', btn.get('type')), ('attribute_string', '=', name), ('model_id', '=', self.model_id.id), ('node_option', '=', 'button')] if type == 'object': domain += [('attribute_name', '=', btn.get('name'))] if type == 'action': domain += [('attribute_name', '=', btn.get('name'))] smart_button_id = store_model_button_obj.search(domain) if not smart_button_id: self._store_btn_data(btn, smart_button=True, smart_button_string=name) else: smart_button_id[0].is_smart_button = True

@api.onchange('model_id') def _get_button(self): if self.model_id and self.model_name: store_model_nodes_obj = self.env['store.model.nodes'] view_obj = self.env['ir.ui.view'] view_list = ['form', 'tree', 'kanban'] for view in view_list: for views in view_obj.search( [('model', '=', self.model_name), ('type', '=', view), ('inherit_id', '=', False)]): res = self.env[self.model_name].sudo().get_view(view_id=views.id, view_type=view) print("REs is arch ======",res['arch'])

doc = etree.XML(res['arch']) # print(doc)

object_button = doc.xpath("//button[@type='object']") for btn in object_button: string_value = btn.get('string') print("object button",string_value) if btn.get('name') and string_value: domain = [('button_type', '=', btn.get('type')), ('attribute_string', '=', string_value), ('attribute_name', '=', btn.get('name')), ('model_id', '=', self.model_id.id), ('node_option', '=', 'button')] # print(domain) if not store_model_nodes_obj.search(domain): self.with_context(string_value=string_value)._store_btn_data(btn)

action_button = doc.xpath("//button[@type='action']") for btn in action_button: string_value = btn.get('string') if view == 'kanban' and not string_value: try: string_value = btn.text if not btn.text.startswith('\n') else False except: pass if btn.get('name') and string_value: domain = [('button_type', '=', btn.get('type')), ('attribute_string', '=', string_value), ('attribute_name', '=', btn.get('name')), ('model_id', '=', self.model_id.id), ('node_option', '=', 'button')] if not store_model_nodes_obj.search(domain): self.with_context(string_value=string_value)._store_btn_data(btn)

## Tab Extraction page_list = doc.xpath("//page") if page_list: for page in page_list: if page.get('string'): domain = [('attribute_string', '=', page.get('string')), ('model_id', '=', self.model_id.id), ('node_option', '=', 'page')] if page.get('name'): domain += [('attribute_name', '=', page.get('name'))] store_model_nodes_id = store_model_nodes_obj.search(domain, limit=1) if not store_model_nodes_id: store_model_nodes_obj.create({ 'model_id': self.model_id.id, 'attribute_name': page.get('name'), 'attribute_string': page.get('string'), 'node_option': 'page', })

0
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

Hi,

In Odoo 17, many changes have occurred compared to Odoo 16. There are changes in functions, decorators, field attributes, and in XML templates, 'attrs' and 'states' are no longer used. Due to these significant changes, instead of sharing your code, you could also share the errors encountered while migrating from V17 to V16. This may help in resolving your query.


Hope it helps

0
Imagine profil
Abandonează
Îți place discuția? Nu doar citi, alătură-te!

Creează-ți un cont astăzi pentru a beneficia de funcții exclusive și a interacționa cu minunata noastră comunitate!

Înscrie-te
Postări similare Răspunsuri Vizualizări Activitate
Ya es posible hacer Upgrade de v17 a v17.1 ?
v17
Imagine profil
Imagine profil
1
oct. 25
2491
How to add a new Many2one field in res.config.settings? Rezolvat
v17
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
oct. 25
5499
Add field to ALL models in Odoo
v17
Imagine profil
Imagine profil
Imagine profil
2
sept. 25
3872
How to disable Email notification - You have been assigned to Rezolvat
v17
Imagine profil
Imagine profil
Imagine profil
3
apr. 26
10111
Selection Field Options Disappear from Database (PostgreSQL enum) on Module Upgrade
v17
Imagine profil
0
aug. 25
2568
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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