コンテンツへスキップ
メニュー
この質問にフラグが付けられました

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
11月 24
11475
1
11月 23
6023
3
11月 22
19392
1
7月 22
4732
2
6月 21
4179