تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
953 أدوات العرض

Dear Odoo forum,


I want to be able to create custom fields for my product

But the custom fields I want need to be on the serial number level

with this I mean I want to be able to input several custom fields, for every serial number, and those would have different values

I will give you an example:

Fields:

Serial Number, PIN (custom field), PUK (custom field), Phone number (custom field)

So, for example:

SN: 00001, PIN: 1234, PUK: 879456, Phone number: 778945125

SN: 00002, PIN: 4567, PUK: 136547, Phone number: 787456876

10:35

I could not find a way to do this in odoo community.


I am using a self-hosted odoo16 community. I know this can be done because I have seen it with odoo studio for the odoo enterprise version.


Any help on this issue would be greatly appreciated.

الصورة الرمزية
إهمال
أفضل إجابة

In Odoo 16 Community, it is possible to achieve custom fields at the serial number level (lot/serial number) by customizing the stock.production.lot model, which is responsible for tracking lots and serial numbers. Although Odoo Studio is not available in the Community version, you can achieve this functionality through custom development. Here's a step-by-step guide:

1. Understand the Model

  • Serial Numbers in Odoo:
    • Serial numbers are stored in the stock.production.lot model.
    • Each serial number is linked to a product.

To add custom fields like PIN, PUK, and Phone Number, you need to extend this model.

2. Extend the Model with Custom Fields

You can create a custom module to add fields to the stock.production.lot model. Here's an example:

Custom Module Code

  1. Create a Module Structure:
    • Navigate to your Odoo addons directory and create a new folder for the custom module, e.g., custom_lot_fields.
    • Add the required __init__.py, __manifest__.py, and models folder.
  2. Define the Custom Fields: In models/stock_production_lot.py:
    from odoo import models, fields
    
    class StockProductionLot(models.Model):
        _inherit = 'stock.production.lot'
    
        pin = fields.Char(string="PIN")
        puk = fields.Char(string="PUK")
        phone_number = fields.Char(string="Phone Number")
    
  3. Add Metadata: In __manifest__.py:
    {
        'name': 'Custom Lot Fields',
        'version': '16.0.1.0',
        'summary': 'Add custom fields for serial numbers',
        'author': 'Your Name',
        'category': 'Inventory',
        'depends': ['stock'],
        'data': [
            'views/stock_production_lot_views.xml',
        ],
        'installable': True,
        'application': False,
        'auto_install': False,
    }
    
  4. Add Custom Fields to the Serial Number Form View: In views/stock_production_lot_views.xml:
    <odoo>
        <record id="view_stock_production_lot_form_inherit" model="ir.ui.view">
            <field name="name">stock.production.lot.form.inherit</field>
            <field name="model">stock.production.lot</field>
            <field name="inherit_id" ref="stock.view_production_lot_form"/>
            <field name="arch" type="xml">
                <xpath expr="//form/sheet" position="inside">
                    <group>
                        <field name="pin"/>
                        <field name="puk"/>
                        <field name="phone_number"/>
                    </group>
                </xpath>
            </field>
        </record>
    </odoo>
    
  5. Install the Module:
    • Restart your Odoo server.
    • Navigate to Apps, search for Custom Lot Fields, and install the module.

3. How to Use

  1. Navigate to Inventory > Products > Lots/Serial Numbers.
  2. Open or create a new serial number.
  3. You will see the new fields PIN, PUK, and Phone Number on the form view.
  4. Input unique values for each serial number.

4. Alternative Approaches

If you're not comfortable with module development:

  • Use Odoo Studio (Enterprise Only): For Enterprise users, you can directly add fields to the stock.production.lot model using Studio.
  • Use the CSV Import/Export:
    • Export serial numbers to a CSV.
    • Add custom fields (e.g., PIN, PUK, Phone Number) to the CSV.
    • Import the updated CSV back into Odoo.

5. Testing and Debugging

  • Test the Fields:
    • Ensure that each serial number can have different values for the custom fields.
    • Verify that the fields are displayed in the desired locations.
  • Debug Errors:
    • Check server logs for errors during development.
    • Use Odoo's Developer Mode to inspect the form view and ensure proper field rendering.

Outcome

By following these steps, you can create custom fields for serial numbers in Odoo Community. These fields will allow you to input values like PIN, PUK, and Phone Number for each serial number.

If you need further help with development or installation, let me know!

الصورة الرمزية
إهمال
أفضل إجابة

Hey, 


I am not sure if you are still looking for it, but Odoo 18 provides this in native. Please consult : 

https://www.odoo.com/fr_FR/event/odoo-experience-2024-4662/track/traceability-enhanced-master-the-use-of-properties-on-lots-and-serial-numbers-for-unmatched-accuracy-6653

Cheers

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أبريل 25
24
2
يناير 25
1503
0
سبتمبر 24
675
0
يونيو 24
668
0
نوفمبر 23
584