콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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