Create Model/DB View Using Query In Odoo || Combine Multiple Model Into One Model || Odoo Training

Поділитися
Вставка
  • Опубліковано 31 жов 2024

КОМЕНТАРІ • 70

  • @RuslanSkiraUkraine
    @RuslanSkiraUkraine 2 роки тому +1

    The hard topic I think and very interesting. Great that you downloaded the video as it is without cutting issues.

    • @OdooMates
      @OdooMates  2 роки тому

      ❤️ so I hope this video will help you get data from the different models

  • @abdelhalimkaddourguettaoui4591
    @abdelhalimkaddourguettaoui4591 3 роки тому +1

    This was awesome thank you brother for this video.

  • @supreetrandom651
    @supreetrandom651 3 роки тому +1

    Very very helpful. Thanks a lot

  • @abhinavm.s1410
    @abhinavm.s1410 3 роки тому +1

    Good one👍

  • @dudutlesmono1804
    @dudutlesmono1804 3 роки тому +1

    This is great tutorial. Thanks you. Please make tutorial about actions.client.

    • @OdooMates
      @OdooMates  3 роки тому +2

      sure we will add it to list :)

    • @usmanfarzand4078
      @usmanfarzand4078 3 роки тому +1

      Thank you its solve my prlbm

    • @OdooMates
      @OdooMates  3 роки тому

      @@usmanfarzand4078 welcome brother

  • @syamaas9621
    @syamaas9621 3 роки тому +1

    👍👍👍

  • @obehobeh9984
    @obehobeh9984 3 роки тому +1

    Interesting. What happens if this request is executed by different users with different sales date parameters?

    • @OdooMates
      @OdooMates  3 роки тому

      expected to have same result, as the query doesn't respect the access rights

  • @ahmedhassen8901
    @ahmedhassen8901 Рік тому

    Does this work on odoo 10 ? The tree view is empty in my case

  • @zurabegadze7123
    @zurabegadze7123 2 роки тому +1

    how can I run psql command in windows terminal ?

    • @OdooMates
      @OdooMates  2 роки тому

      www.pgadmin.org/download/pgadmin-4-windows/

    • @OdooMates
      @OdooMates  2 роки тому

      ua-cam.com/video/TWccA-tVa9E/v-deo.html

  • @Leonardo-dd7hj
    @Leonardo-dd7hj 6 місяців тому

    i try this, i run the select * from in postgres, and it return some data, but it doesnt show any data in the odoo view

  • @kaoutherayadi5771
    @kaoutherayadi5771 3 роки тому +2

    thank you good explain but i have AttributeError: module 'odoo.api' has no attribute 'model_cr' i use odoo 13

    • @OdooMates
      @OdooMates  3 роки тому

      you can remove that line if you are using odoo 13 and above

    • @OdooMates
      @OdooMates  3 роки тому

      just remove: @api.model_cr

    • @kaoutherayadi5771
      @kaoutherayadi5771 3 роки тому +1

      ok i remove it and it workes but i have another problem i uninstalled asset module as you do with om_hospital but i have 500 error TypeError: Model 'account.asset.asset' does not exist in registry.

    • @OdooMates
      @OdooMates  3 роки тому

      @@kaoutherayadi5771 why you uninstall asset module ?

    • @kaoutherayadi5771
      @kaoutherayadi5771 3 роки тому

      @@OdooMates because i see my data in terminal but i don't find it in my view

  • @hafizhafizullah2458
    @hafizhafizullah2458 Рік тому +1

    thank you for your video. What if I want to display a binary field from ir_attachment in model view using sql query?

    • @OdooMates
      @OdooMates  Рік тому +1

      you can try as follows, add binary field in model of sql view, fetch the value to this field from the query

    • @hafizhafizullah2458
      @hafizhafizullah2458 Рік тому

      @@OdooMates thank you for your response. Will try the same and will be back accordingly.

    • @hafizhafizullah2458
      @hafizhafizullah2458 Рік тому

      @@OdooMates I have added a binary field but how can I fetch data into it. as binary field is not showing in my model whereas it is showing in ir_attachment as a record with res_id as my my model record ID. but from which field in ir_attachment, I could extract that binary field so that I could get my required file?

    • @OdooMates
      @OdooMates  Рік тому

      @@hafizhafizullah2458

    • @hafizhafizullah2458
      @hafizhafizullah2458 Рік тому

      @@OdooMates can you please upload video for fetching binary field in model view please

  • @HiPh0Plover1
    @HiPh0Plover1 3 роки тому +1

    why would you wanna do that ? is it to save time and code lines by using something already existing in code ?

    • @OdooMates
      @OdooMates  3 роки тому +1

      are you asking about the reasons to create such a view ?

    • @HiPh0Plover1
      @HiPh0Plover1 3 роки тому +1

      @@OdooMates yes i want to know why would a dev do that using query ? is it to actually save a lot of time and not code it from scratch ?

    • @OdooMates
      @OdooMates  3 роки тому +4

      @@HiPh0Plover1 it helps different purpose, like for creating pivot views, graph views, then creating qweb reports, the one who creates the reports can take data from one place rather than here and there. Also we can combine data from multiple models into a single table

  • @DharmeshTechZone
    @DharmeshTechZone 3 роки тому +1

    Sir can you please make video on how to pass contex,withcontext in model use in another method or view

    • @OdooMates
      @OdooMates  2 роки тому +1

      we will add in the upcoming videos brother

  • @umerfarooq4026
    @umerfarooq4026 3 роки тому +1

    Sir have you any lecture on js widget

    • @OdooMates
      @OdooMates  3 роки тому

      not yet brother

    • @umerfarooq4026
      @umerfarooq4026 3 роки тому

      @@OdooMates plz make some material on widget and other Odoo js

  • @malikkamil6596
    @malikkamil6596 2 роки тому

    hello sir i created a discount on invoice after tax how i can create journal entry for that

    • @OdooMates
      @OdooMates  2 роки тому

      there is a module from oca which adds discount in invoice, can you refer that module

  • @hieunguyenngoc1816
    @hieunguyenngoc1816 3 роки тому

    i inherit model crm_lead and query to display result query to pivot view but query does'nt work, can i inherit a model and using query to display pivot view?

    • @OdooMates
      @OdooMates  3 роки тому

      as crm.lead is a normal model, better you add a new model and add the query to show the results

    • @OdooMates
      @OdooMates  3 роки тому

      If you are generating data for the pivot view, ie actually for the model itself, you have to select the data from some tables right ? If you change the crm.lead to a model that comes from query, where will u enter the leads ?

    • @hieunguyenngoc1816
      @hieunguyenngoc1816 3 роки тому +1

      @@OdooMates so it is impossible to inherit a model and query to show result to pivot view?

    • @OdooMates
      @OdooMates  3 роки тому

      its possible, my question is, if you keep the same model, how will you record data into the crm.lead model. Thats why suggested you to create new model

  • @PacoArronaC
    @PacoArronaC 3 роки тому +1

    Thanks for teach, I need extra help ; what would be the where clause if I only want the records that match a field of a model of the actual view. Here is my case; I need to display all the item prices that match the category of the product in the form, so I think I can use this video aproach but I do not know how to call the product.category_id field as filter on the product.prices.item query where clause.

    • @OdooMates
      @OdooMates  3 роки тому

      you can left join to product_category , using the categ_id field in the product template model

    • @PacoArronaC
      @PacoArronaC 3 роки тому +1

      @@OdooMates ok in other words my model is the new: show.prices.product which will take the values from the sql query from product.price.items , now I need to filter just the records that match the categ_id of the form product template, I am not sure that the filed product.categ_id has the right value from the form, and I think it should by in the where clause.

    • @OdooMates
      @OdooMates  3 роки тому

      @@PacoArronaC can you share your query

    • @PacoArronaC
      @PacoArronaC 3 роки тому

      @@OdooMates yes of course an thanks for you attention; My problem is what to put on the last field of the where clause, as I am on the product_template_form , it may be use product.template.categ_id instead of categ_id.id:
      ----
      class pricess(models.Model):
      _name = 'price.xprod'
      _auto = False
      _description = 'Precios_por_producto'
      costo = fields.Float()
      precio = fields.Float()
      porc = fields.Float()
      @api.model_cr
      def init(self):
      tools.drop_view_if_exist(self.cr_,'price_xprod')
      self.cr.excecute("""
      create or replace view price_xprod as(
      select row_numbre() over as id, line.costo as costo, line.precio as precio, line.porc as porc from(
      select p.standard_price, i.price, i.price_discount from product_price_item i left join product.template p
      on (p.categ_id = i.categ_id) where i.categ_id = categ_id.id
      ) line
      ) """ )

    • @OdooMates
      @OdooMates  3 роки тому

      @@PacoArronaC is there any error on running this query ?

  • @sanjanafarial4516
    @sanjanafarial4516 3 роки тому

    Does anybody know how to do it in Odoo 13? "drop_view_if_exists" doesn't seem to be working on odoo 13 (I have _auto set to False).

    • @OdooMates
      @OdooMates  3 роки тому +1

      Hi, it is there in odoo13, if you search inside the odoo source code, you can see a lot of usage of drop_view_if_exists

  • @banothsandhya3367
    @banothsandhya3367 2 роки тому

    How to make tree view with qweb in odoo v12

  • @malikkamil6596
    @malikkamil6596 2 роки тому

    help help help ValueError: Expected singleton: stock.picking(8, 7)
    when one value is selected it works fine but when 2 products selectd in batch-transfer it gives error
    # -*- coding: utf-8 -*-
    from odoo import models, fields, api
    class StockPicking(models.Model):
    _inherit = 'stock.picking'
    def button_validate(self):
    """This function is inherit for effective date change"""
    transfer_date = self.date_done
    res = super(StockPicking, self).button_validate()
    self.date_done = transfer_date
    if self.move_lines:
    self.move_lines.update({'date': self.date_done})
    if self.move_lines.account_move_ids:
    for record in self.move_lines.account_move_ids:
    pick_date = (self.date_done).date()
    record.button_draft()
    record.name = False
    record.update({'date': pick_date})
    record.action_post()
    if self.move_line_ids:
    for line in self.move_line_ids:
    line.date = self.date_done
    return res

    • @OdooMates
      @OdooMates  2 роки тому

      ua-cam.com/video/Rv44nFVn_5U/v-deo.html

  • @xions192
    @xions192 Рік тому +1

    It don't add me new records to the view. Any idea? I'm in Odoo v14.🥲

    • @OdooMates
      @OdooMates  Рік тому

      normally it has to add, did you followed same coding or ?

    • @xions192
      @xions192 Рік тому

      @@OdooMates I already managed to fix it. I had a mistake in the SELECT query. Thank you 😁