Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

How to add fields from res.partner model as dependencies in product.template model for calculation purposes in Odoo v18 Enterprise?

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
productmodelsinventorycustomizationodoo
2 ตอบกลับ
5285 มุมมอง
อวตาร
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
อวตาร
ละทิ้ง
อวตาร
Zuhair
ผู้เขียน คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
อวตาร
Niyas Raphy (Walnut Software Solutions)
คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
what is ordered quantities and deliverd quantities in product type. แก้ไขแล้ว
product inventory odoo
อวตาร
อวตาร
อวตาร
อวตาร
3
เม.ย. 24
5620
update quantity on hand แก้ไขแล้ว
product inventory quantity odoo
อวตาร
อวตาร
อวตาร
4
พ.ค. 25
26827
Product on hand quantity is not equal with product move calculation odoo12
stock product inventory odoo
อวตาร
0
ก.ย. 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
อวตาร
อวตาร
1
ก.ค. 21
4052
Maintenance/Repair - External
product inventory maintenance odoo v17
อวตาร
อวตาร
1
ส.ค. 24
2987
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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