Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

Odoo 8 Select Product and Variant in seperate fields in Sales order

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
productsale.order.linevariantattributeodooV8
2 Trả lời
8217 Lượt xem
Ảnh đại diện
Herman

Hi there fellow developers

in Odoo 8's product.py I see the name_search method concatenates the product name and variant as the product name. I however have hundreds of attributes to my product.

Height: 500mm, 505mm, ... 3000mm

Width: 500mm, 505mm, ... 4000mm

So it makes it impossible to search the desired variant

So i need first select the product, Then the Height attribute, Then the Width attribute

In Theory I need to override the search method

  • remove the variant in product name

  • create a search method to select first attribute

  • create another search method to select second attribute

  • then it needs to return the product name + att1 + att2 to main search method

Can anyone point me in the right direction?

I really need some serious assistance. Speak to me about cash for code if really neccesary :)


My .py


from openerp import models, fields, api

class product_template(models.Model):

      _inherit = 'product.template'

      palepoint = fields.Char("Pale Point", size=20)

      materialoptions_id = fields.Many2one("product.category","Material Options")

class Sale_order(models.Model):

      _inherit = 'sale.order'

      material_id= fields.Many2one("product.template","Material",domain=[('categ_id.name','=','Raw Material')])

class product_product(models.Model):

      _inherit = 'product.product'

     #This search filter the products by selected product category which works fine

      def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):

          if context is None:

              context = {}

          if context.get('material_id'):

              productobj = self.pool.get('product.product').read(cr, uid, context['material_id'],['materialoptions_id'])

              args = [('categ_id','=',productobj['materialoptions_id'][0])] + args

              return super(product_product, self).search(cr, uid, args, offset, limit, order, context=context, count=count)

My view


<openerp>

      <data>

          <record model="ir.ui.view" id="partner_palepoint_form_view">

              <field name="model">product.template</field>

              <field name="inherit_id" ref="product.product_template_only_form_view"/>

              <field name="arch" type="xml">

              <field name="list_price" position="after">

              <field name="materialoptions_id"/>

              </field>

              <notebook position="inside">

                  <page string="Pale Point">

                      <group>

                          <field name="palepoint"/>

                      </group>

                  </page>

                 </notebook>

              </field>

          </record>

          <record model="ir.ui.view" id="sale_view_form_view">

              <field name="model">sale.order</field>

              <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>

              <field name="arch" type="xml">

                  <field name="partner_id" position="after">

                      <field name="material_id"/>

              </field>

              <xpath expr="//field[@name='product_id']" position="attributes">

                  <attribute name="context">{'material_id': parent.material_id}</attribute>

              </xpath>

              </field>

          </record>

      </data>

</openerp>



And good old Odoo 8's product.py nam_search method


def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):

# Only use the product.product heuristics if there is a search term and the domain

# does not specify a match on `product.template` IDs.

if not name or any(term[0] == 'id' for term in (args or [])):

return super(product_template, self).name_search(

cr, user, name=name, args=args, operator=operator, context=context, limit=limit)

product_product = self.pool['product.product']

results = product_product.name_search(

cr, user, name, args, operator=operator, context=context, limit=limit)

product_ids = [p[0] for p in results]

template_ids = [p.product_tmpl_id.id

for p in product_product.browse(

cr, user, product_ids, context=context)]

# re-apply product.template order + name_get

return super(product_template, self).name_search(

cr, user, '', args=[('id', 'in', template_ids)],

operator='ilike', context=context, limit=limit)


0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Herman
Tác giả Câu trả lời hay nhất

So what I think the best "Work Around" would be is if I create 3 custom fields

  • Product Type (All the product names in selected category)

  • Width (attributes linked to product selected in 'Product Type')

  • Height (attributes linked to product selected in 'Product Type')

above the product field. Then by concatenating those 3 values I can pass the context 'name' to the product search method to match. Therefore only displaying one product matching the criteria above

Hope this helps -me-

Why is this the best way? probably shouldve added this. educational value and what not.

Because, whilst debugging you'll see the product and it's attribute shares an id. That is because odoo treats each product variant as a product. There's no "main" product and then it's child variants. It's one in the same.


LOOK HERE===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]
LOOK HERE2===================================================
{'default_code': False, 'id': 33, 'name': u'Palisade Fence (Domestic 110mm) (1800, 3000mm)'}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]
LOOK HERE2===================================================
{'default_code': False, 'id': 34, 'name': u'Palisade Fence (Domestic 110mm) (1800, 3005mm)'}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]
LOOK HERE2===================================================
{'default_code': False, 'id': 35, 'name': u'Palisade Fence (Domestic 110mm) (1805, 3000mm)'}
LOOK HERE3===================================================
{'lang': 'en_US', 'tz': False, 'uid': 1, 'material_id': 19}
[33, 34, 35, 36]

Which is why each variant has it's own Bill of materials (Which is exactly what i need, Thank you brilliant odoo developers) So unless you want to change the structure of odoo, you first need to pass a context to filter the products, not the other way around

Hope this makes sense everyone. I'm VERY new to programming so please tell me if I'm missing the plot.

odoo is INCREDIBLE thanks guys

1
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Product label prints only one variant attribute
product label variant attribute
Ảnh đại diện
Ảnh đại diện
2
thg 3 16
7022
Difficulty creating product variants using API in PHP [12.0]
product api php variant attribute
Ảnh đại diện
2
thg 1 20
5189
What is the easier way to select a product variant in a sale order?
product sale order variant attribute
Ảnh đại diện
Ảnh đại diện
1
thg 7 24
6223
Could we define a multi dimensional « attribute price extra »?
product price variant attribute extra
Ảnh đại diện
0
thg 9 15
5303
How is it added a new field in XML specifying on_change attribute at the same time? Đã xử lý
fields xml sale.order.line attribute odooV8
Ảnh đại diện
Ảnh đại diện
1
thg 7 15
4714
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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