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
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • 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 to add fields from res.partner model as dependencies in product.template model for calculation purposes in Odoo v18 Enterprise?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
productmodelsinventorycustomizationodoo
2 Replies
5306 Rodiniai
Portretas
Zuhair

Hello everyone,

I am working on an Odoo v18 Enterprise implementation and have created several custom fields in the res.partner model, including:

  • x_container_fee (type: monetary)
  • x_customs_duty (type: float)
  • x_handling_charge (type: monetary)
  • x_vendor_type (type: selection)


Additionally, I have created a custom field x_total_cost (type: monetary) in the product.template model.


For calculation purposes, I would like to reference the fields I created in the res.partner model when computing values in the product.template model.


Is it possible to include fields from res.partner as dependencies in product.template? If so, How can this be achieved?

Thank you in advance!

0
Portretas
Atmesti
Portretas
Zuhair
Autorius Best Answer

Hello,

I need to calculate the total cost of products based on certain charges related to international vendors. These charges include:

  1. Container Fee (for the space the product occupies in a shipping container),
  2. Customs Duty (a percentage charge on the base price of the product),
  3. Handling Charge (additional fees for handling the product).

I created those fields on the res.partner model for international suppliers. I want to use these values in the product.template model to compute the total cost of the product (without profit margin).

In the res.partner model I have created those fields:

  1. x_container_fee (Type: Monetary): This field stores the container fee per square meter (or unit of space) that an international vendor charges (vary depending on country).
  2. x_customs_duty (Type: Float): This field represents the customs duty rate (as a percentage) that is applied to products from this international vendor.
  3. x_handling_charge (Type: Monetary): This field stores any additional handling charge imposed by the vendor.
  4. x_vendor_type (Type: Selection): This field indicates whether the vendor is local or international. Only for international vendors do the additional charges (customs, container fee, and handling charge) apply.

In the product.template model:

  1. x_container_space (Type: Float): This field represents the space (in square meters) the product occupies in the shipping container.
  2. x_total_cost (Type: Monetary): This field stores the final total cost of the product, which includes the base price and the additional charges from the international vendor (without the profit margin).

Calculation Process:

For each product, I want to compute the total cost as follows:

  1. Base Price: Start with the product's base price (either list price or cost price).
  2. International Supplier Charges: If the vendor is marked as international, I want to apply:
    • Customs Duty: Calculate the customs duty as a percentage.
    • Container Fee: I will insert on the each product base on the area it will occupy in the container.
    • Handling Charge: Add any fixed handling charges from the vendor.
  3. Final Total Cost: Sum up these values to get the total cost of the product without including the profit margin.

Code I have use:

from odoo import api, fields, models

class ProductTemplate(models.Model):
    _inherit = "product.template"

    # Link to the vendor (res.partner) model
    vendor_id = fields.Many2one('res.partner', string='Vendor', help="Reference to the vendor from res.partner.")

    # Related fields from the vendor
    x_container_fee = fields.Monetary(related='vendor_id.x_container_fee', string='Container Fee', readonly=True)
    x_customs_duty = fields.Float(related='vendor_id.x_customs_duty', string='Customs Duty', readonly=True)
    x_handling_charge = fields.Monetary(related='vendor_id.x_handling_charge', string='Handling Charge', readonly=True)

    # Space occupied by the product in the container (in square meters or units)
    x_container_space = fields.Float(string='Container Space (m²)', help="Space occupied by the product in square meters.")

    # Field to store the calculated total cost
    x_total_cost = fields.Monetary(string='Total Cost', compute='_compute_total_cost', store=True, help="Total cost of the product without profit margin.")

    @api.depends('list_price', 'x_container_fee', 'x_customs_duty', 'x_handling_charge', 'x_container_space')
    def _compute_total_cost(self):
        for product in self:
            # Base price paid to the vendor (list_price or cost price)
            base_price = product.list_price

            # Initialize additional charges
            total_customs_duty = 0
            total_container_fee = 0
            total_handling_charge = 0

            # Check if the vendor is assigned and marked as international
            if product.vendor_id and product.vendor_id.x_vendor_type == 'international':
                # Calculate customs duty (percentage of the base price)
                customs_duty_rate = product.x_customs_duty or 0
                total_customs_duty = base_price * customs_duty_rate / 100

                # Calculate container fee based on the space occupied
                container_fee_per_sqft = product.x_container_fee or 0
                space_occupied = product.x_container_space or 1  # Default to 1 if not specified
                total_container_fee = container_fee_per_sqft * space_occupied

                # Add container handling charge
                total_handling_charge = product.x_handling_charge or 0

            # Calculate total cost (without profit margin)
            product.x_total_cost = base_price + total_customs_duty + total_container_fee + total_handling_charge


 When I created the total cost and put the  ​Python code I need to put the ​Dependencies to which I am having the error:
Unknown field “x_container_fee” in dependency “x_container_fee”


0
Portretas
Atmesti
Portretas
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,
First you need a relation between res.partner table and product.template model and you have to finalize on this one. You will introduce a new field to partner inside the product or will you use the seller_ids field ? Could you give some clarity on this.

Thanks

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
what is ordered quantities and deliverd quantities in product type. Solved
product inventory odoo
Portretas
Portretas
Portretas
Portretas
3
bal. 24
5634
update quantity on hand Solved
product inventory quantity odoo
Portretas
Portretas
Portretas
4
geg. 25
26832
Product on hand quantity is not equal with product move calculation odoo12
stock product inventory odoo
Portretas
0
rugs. 21
3027
i need to know how to change the location of a product which was stored in RM to FG stock or vice versa in odoo v8
product inventory odoo odooV8
Portretas
Portretas
1
liep. 21
4057
Maintenance/Repair - External
product inventory maintenance odoo v17
Portretas
Portretas
1
rugp. 24
2994
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