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

Hi All,

I am using odoo 15 enterprise version. For one of my clients projects, I want to import sales orders through an excel file with the sections in the same file. 

Please Help me with how to do it. Which field name do I need to match for that section name?

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

Yes it is possible


Name Customer Order Lines/Sequence Order Lines/Display Type Order Lines/Description Order Lines/Product
S00090 Anita Oliver 1 Section Section 1  
    2   Burger Menu Combo Burger Menu Combo
    3   Bricks Bricks
    4 Section Section 2  
    5   Bacon Burger Bacon Burger

I tested in V16 EE

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

Hi, you can follow this:


Hope it helps, thanks

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

Hi  Imantha,

I think this video can help you: https://www.youtube.com/watch?v=etMYrOJyaiU&list=PLSKcWRTtEl5qzvRaI-VTGavfReiHS_EEb&index=2 (starting at minute 55 in this video)

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

Hi

You can try this code
wizard python file

from odoo import models, fields
from io import BytesIO
import base64
import openpyxl
import re


class ImportLines(models.Model):
_name =
'import.lines'

xls_file = fields.Binary(
'File')

def import_xls(self):
   
"""  Import xlsx report to saleOrder line """
    wb = openpyxl.load_workbook(
        filename=BytesIO(base64.b64decode(self.xls_file)),
        read_only=
True
    )
    ws = wb.active
   
for record in ws.iter_rows(min_row=2, max_row=None, min_col=None,
                              max_col=
None, values_only=True):
        active_id = self.env.context.get(
'active_id')
        product = record[
2]
       
if product:
            val = product.split()
            string = re.sub(
"[\([{})\]]", "", val[0])
            new = self.env[
'sale.order.line'].create({
               
'order_id': active_id,
               
'display_type': False,
               
'product_id':  self.env['product.product'].search([
                            (
'default_code', '=', string)]).id,
               
'name': record[0],
               
'product_uom_qty': record[1],
               
'price_unit': record[3],
               
'product_uom':  self.env['uom.uom'].search([
                            (
'name', '=', record[4])]).id
            })

   
return new

XML:

<record id="import_lines_form" model="ir.ui.view">
 
      <field name="name">import.lines.form</field>
 
      <field name="model">import.lines</field>
        <field name="arch" type="xml">
            <form string="Import Lines">
                <group name="main">
                    <field name="xls_file"/>
                </group>
                <footer>
                    <button name="import_xls" type="object" string="Import" class="oe_highlight"/>
                    <button special="cancel" string="Cancel"/>
                </footer>
            </form>
        </field>
    </record>
        
    <record id="import_lines_action" model="ir.actions.act_window">
        <field name="name">Import Lines</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">import.lines</field>
        <field name="view_mode">form</field>

Hope it helps

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
4
نوفمبر 24
11465
1
نوفمبر 23
6021
3
نوفمبر 22
19387
1
يوليو 22
4730
2
يونيو 21
4174