Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How do I load the current data when I opening or clicking on a fields.One2many in odoo.sh 18?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
purchasedevelopment
1 Atsakyti
1069 Rodiniai
Portretas
Martin Bando

Hello everyone,


At the moment I can see all the PCs entered in my list, regardless of which customer is selected in the column. However, I would like the PCs to be loaded and displayed only for the selected customers when I click on the x_studio_pc field. How do I do this? Do I have to use OWL? If so, how do I do this? I have no experience with OWL so far.


class ProductTemplate(models.Model):

    _inherit = 'product.template'


    x_studio_pc_liste = fields.One2many('product.template.line', 'x_product_template_id', string='PC Liste')


class ProductTemplateLine(models.Model):

    _name = 'product.template.line'

    _description = 'Product Template Line Modul'

    _order = 'x_product_template_id, x_studio_sequence, id'

    _rec_name = 'x_name'


    x_product_template_id = fields.Many2one('product.template', string='X Product Template', ondelete='cascade')


    x_studio_info = fields.Char(string='Info', default='Please enter the PC in Name', required=True)


    x_studio_sequence = fields.Integer(string='Sequence', default=10)


    x_name = fields.Char(string='Description', required=True)


    x_studio_distribution = fields.Selection(

        [

            ('5575', 'Test1'),

            ('5581', 'Test2'),

            ('5559', 'Test3'),

        ],

        string='Distribution',

        required=True

    )


    x_studio_note = fields.Text(string='Note')


class PurchaseOrderLine(models.Model):

    _inherit = 'purchase.order.line'


    x_studio_pc = fields.Many2one(

        'product.template.line',

        string='PC'

    )


    @api.onchange('product_id')

    def _onchange_product_id_set_pc_domain(self):

        tmpl = self.product_id.product_tmpl_id

       

        if tmpl and hasattr(tmpl, 'x_pc_liste') and tmpl.x_pc_liste:           

            pc_ids = tmpl.x_pc_liste.ids

            return {

                'domain': {

                    'x_studio_pc': [('id', 'in', pc_ids)]

                }

            }

        else:

            return {

                'domain': {

                    'x_studio_pc': []

                }

            }

0
Portretas
Atmesti
Portretas
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Please refer to the code below:


Model: Product template line

- Added new field for customer.

from odoo import models, fields

class ProductTemplateLine(models.Model):
_name = 'product.template.line'
_description = 'Product Template Line Modul'
_order = 'x_product_template_id, x_studio_sequence, id'
_rec_name = 'x_name'

x_product_template_id = fields.Many2one('product.template', string='Product Template', ondelete='cascade')
partner_id = fields.Many2one('res.partner', string='Customer') #ADD THIS LINE
x_studio_info = fields.Char(string='Info', default='Please enter the PC in Name', required=True)
x_studio_sequence = fields.Integer(string='Sequence', default=10)
x_name = fields.Char(string='Description', required=True)
x_studio_distribution = fields.Selection([
('5575', 'Test1'),
('5581', 'Test2'),
('5559', 'Test3'),
], string='Distribution', required=True)
x_studio_note = fields.Text(string='Note')

Model: purchase order line

from odoo import models, fields, api

class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

x_studio_pc = fields.Many2one('product.template.line', string='PC')

@api.onchange('product_id', 'order_id.partner_id')
def _onchange_product_or_partner(self):
"""
Dynamically filters the available options for the 'x_studio_pc' field
based on the selected product and customer.

Only shows PC entries (product.template.line records) that are linked
to both the selected product template and the selected customer (partner).
If either is not selected, the PC dropdown is emptied.
"""
if self.product_id and self.order_id.partner_id:
tmpl = self.product_id.product_tmpl_id
partner = self.order_id.partner_id
pc_ids = self.env['product.template.line'].search([
('x_product_template_id', '=', tmpl.id),
('partner_id', '=', partner.id)
]).ids
return {'domain': {'x_studio_pc': [('id', 'in', pc_ids)]}}
else:
return {'domain': {'x_studio_pc': []}}

Hope it helps.

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

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

Registracija
Related Posts Replies Rodiniai Veikla
How can i change the description of the field 'product_uom' in model 'purchase.order'? Solved
purchase development
Portretas
Portretas
Portretas
2
liep. 25
1063
Forbidden Opcode in Server Action when Trying to Update Fields in Odoo 16
purchase development accounting
Portretas
Portretas
2
vas. 25
4246
How to convert or update purchase_double_validation to triple validation in openerp 7?
purchase development validate
Portretas
0
kov. 15
4333
MrpBom _skip_bom_line skips line of product that has two multi-choice attribute values when both are selected in Apply to variant
development
Portretas
1
lapkr. 25
136
How to make all branches for user active automatically after login his account?
development
Portretas
0
lapkr. 25
150
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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