跳至内容
Odoo 菜单
  • 登录
  • 免费试用
  • 应用程序
    财务
    • 会计
    • 发票
    • 费用
    • 电子表格 (BI)
    • 文档
    • 电子签名
    销售
    • 客户关系管理
    • 销售
    • POS 销售点管理-零售
    • POS 销售点管理 - 餐厅
    • 订阅
    • 租赁
    网站
    • 网站设计
    • 电子商务
    • 博客
    • 论坛
    • 在线客服
    • 在线学习
    供应链
    • 库存
    • 制造
    • 产品生命周期
    • 采购
    • 维护保养
    • 品控
    人力资源
    • 员工
    • 招聘
    • 休假
    • 评价
    • 内部推荐
    • 车队
    营销
    • 社媒营销
    • 电邮营销
    • 短信营销
    • 近期活动
    • 营销自动化
    • 网上调查
    服务
    • 项目管理
    • 工时单
    • 现场服务
    • 服务台
    • 排期
    • 预约
    生产力
    • 讨论
    • 批核
    • IoT物联网
    • VoIP
    • 知识库
    • WhatsApp
    第三方应用软件 Odoo 定制 Odoo云端平台
  • 行业
    零售
    • 书店
    • 服装店
    • 家具店
    • 食品杂货店
    • 五金店
    • 玩具店
    餐饮与酒店服务
    • 酒吧及酒馆
    • 餐厅
    • 快餐
    • 民宿
    • 饮品分销商
    • 酒店
    房地产
    • 房地产代理
    • 建筑师事务所
    • 建造业
    • 地产管理
    • 园艺
    • 业主协会
    咨询
    • 会计师事务所
    • Odoo合作伙伴
    • 市场推广公司
    • 律师事务所
    • 人才招聘
    • 审核 & 认证
    制造
    • 纺织
    • 金属
    • 家具
    • 食品
    • 啤酒厂
    • 企业礼品
    保健与健身
    • 体育俱乐部
    • 眼镜店
    • 健身中心
    • 健康从业者
    • 药房
    • 发型屋
    商贸服务
    • 维修人员
    • IT 硬件及支持
    • 太阳能系统
    • 鞋匠
    • 清洁服务
    • 暖通空调服务
    其他
    • 非营利组织
    • 环境机构
    • 广告牌租赁
    • 摄影服务
    • 自行车租赁
    • 软件经销商
    浏览所有行业
  • 社区
    学习
    • 教学视频
    • 文档
    • 认证
    • 培训
    • 博客
    • 播客
    赋能教育
    • 教育计划
    • Scale Up! 商业游戏
    • 参观Odoo
    获取软件
    • 下载
    • 版本对比
    • 发布
    合作
    • Github
    • 论坛
    • 近期活动
    • 翻译
    • 成为合作伙伴
    • 合作伙伴服务
    • 注册您的会计事务所
    获取服务
    • 寻找合作伙伴
    • 查找会计服务
    • 预约顾问咨询
    • 安装及推行服务
    • 客户参考
    • 支持
    • 升级
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    获取演示
  • 定价
  • 技术支持

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

  • 客户关系管理
  • e-Commerce
  • 会计
  • 库存
  • PoS
  • 项目
  • MRP
All apps
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
帮助

how to resolve error "model not found"

订阅

此帖文有活动时,接收通知

此问题已终结
odoo
7 回复
27218 查看
形象
Dhouha

Every time i create a new model error "model not found" shows i don't know What to do any help please 

here is my code 

------------------------------------------------------------------------------------------------------

views.xml 

<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <data>


 <!-- Label Configration Form View -->

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

            <field name="name">label.zpl.form</field>

            <field name="model">label.zpl</field>

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

                <form string="Generate and Print Product Barcode">

               <group name="step1" string="Configuration">

                <field name="state" invisible="1"/>

                <field name="currency_id" invisible="1"/>

                <field name="product_id"/>

                <field name="product_name" attrs="{'readonly': [('state', '=', 'step2')]}"/>

                <field name="pricelist_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>

                <field name="price_uom"/>

                <field name="label_size" attrs="{'readonly': [('state', '=', 'step2')]}"/>

                <field name="nomenclature_id" attrs="{'readonly': [('state', '=', 'step2')]}"/>

                <field name="rule_id"/>

                <field name="barcode_type"/>

                <field name="barcode"/>

                <field name="copies" attrs="{'readonly': [('state', '=', 'step2')]}"/>

               </group>

                   <group string="Enter Quantity" attrs="{'invisible': [('barcode_type', '=', 'product')]}">

                   <div name="qty_uom">

                    <field name="quantity" attrs="{'readonly': [('state', '=', 'step2')]}" class="oe_inline"/>

                    <field name="uom_id" class="oe_inline"/>

                   </div>

               </group>

            <group name="step2" states="step2" string="Label">

                <field name="price"/>

                <field name="zpl_file" filename="zpl_filename" />

                <field name="zpl_filename" invisible="1"/>

                <field name="zpl_printer_id" required="1"/>

            </group>

            <footer>

                <button name="generate" type="object" string="Generate Label" class="btn-primary" states="step1"/>

                <button special="cancel" string="Cancel" class="oe_link" states="step1"/>

                <button name="print_zpl" type="object" string="Print" class="btn-primary" states="step2"/>

                <button name="print_zpl" type="object" string="Print and New" class="btn-primary" context="{'print_and_new': True}" attrs="{'invisible': ['|', ('state', '!=', 'step2'), ('barcode_type', '=', 'product')]}"/>

                <button special="cancel" string="Close" class="oe_link" states="step2"/>

            </footer>

        </form>

               

            </field>

        </record>

  <record id="action_label_zpl_form" model="ir.actions.act_window">

            <field name="name">Label Zpl</field>

            <field name="res_model">label.zpl</field>

            <field name="view_type">form</field>

            <field name="view_mode">form</field>

        </record>


        <menuitem id="menu_config" name="Configuration" parent="base.menu_administration"

            sequence="2" />

        <menuitem id="menu_label_config_view" action="action_label_zpl_form"

            parent="menu_config" />

 </data>
</odoo>

-------------------------------------------------------------------------------------------------
__openerp__.py

# -*- coding: utf-8 -*-

{
    'name': 'Print Product barcode on ZPL',
  
  
    'depends': [
     
              ],
    'data': [
      "views/views.xml"
    ],
    'installable': True,
}

0
形象
丢弃
Dhouha
编写者

Traceback

D\xe9tails de l'erreur :

Mod\xe8le non trouv\xe9 : label.zpl

Contexte de l'erreur :

Vue `label.zpl.form`

[view_id: 849, xml_id: n/a, model: label.zpl, parent_id: n/a]

None" while parsing file:///d:/projet_odoo/odoo 9.0-20180426/server/openerp/addons/test/views/views.xml:6, near

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

<field name="name">label.zpl.form</field>

<field name="model">label.zpl</field>

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

<form string="Generate and Print Product Barcode">

<group name="step1" string="Configuration">

<field name="state" invisible="1"/>

Mohammed Amal N

make sure you have imported the python file declaring "label.zpl", also you need to restart odoo instance to load python file changes.

形象
GiusyG
最佳答案

Hi, add in the _manifest 

'depends': [  'base' ],

let me know...

0
形象
丢弃
Orumpati

yes

形象
Edi Šuc
最佳答案

Have you started the server with the option --dev=all ?

0
形象
丢弃
形象
Ibrahim Boudmir
最佳答案

Can you post your file.py that contains the definition of your object 'label.zpl'? 

0
形象
丢弃
Dhouha
编写者

# -*- coding: utf-8 -*-

from openerp import models, fields, api, _

from openerp.exceptions import UserError

from openerp.tools import float_compare, float_is_zero

import openerp.addons.decimal_precision as dp

import base64

import re

class ProductPrintZplBarcode(models.TransientModel):

_name = 'product.print.zpl.barcode'

_description = 'Generate and print product barcodes in ZPL'

@api.model

def default_get(self, fields_list):

res = super(ProductPrintZplBarcode, self).default_get(fields_list)

assert self._context.get('active_model') == 'product.product',\

'wrong active_model, should be product.product'

product_id = self._context.get('active_id')

product = self.env['product.product'].browse(product_id)

if not product:

raise UserError(_('Missing Product'))

if not product.barcode:

raise UserError(_(

"Product '%s' doesn't have a barcode") % product.display_name)

nomenclature = self.env.ref('barcodes.default_barcode_nomenclature')

company = self.env.user.company_id

posconfig = self.env['pos.config'].sudo().search(

[('company_id', '=', company.id)], limit=1)

if posconfig:

pricelist = posconfig.pricelist_id

else:

pricelist = self.env['product.pricelist'].search([

'|', ('company_id', '=', False),

('company_id', '=', company.id),

], limit=1)

if not pricelist:

raise UserError(_(

"There are no pricelist in company %s ?") % company.name)

printer = self.env['printing.printer'].get_default()

res.update({

'nomenclature_id': nomenclature.id,

'pricelist_id': pricelist.id,

'currency_id': pricelist.currency_id.id,

'barcode': product.barcode,

'product_name': product.name,

'product_id': product_id,

'zpl_printer_id': printer and printer.id or False,

})

return res

product_id = fields.Many2one(

'product.product', string='Product', required=True, readonly=True)

uom_id = fields.Many2one(

related='product_id.uom_id', readonly=True)

# 1 line = un peu moins de 30

product_name = fields.Char('Product Label', required=True, size=56)

nomenclature_id = fields.Many2one(

'barcode.nomenclature', 'Barcode Nomenclature', required=True)

rule_id = fields.Many2one(

'barcode.rule', string='Barcode Rule', readonly=True,

compute='_compute_rule_id')

barcode_type = fields.Selection(

related='rule_id.type', readonly=True, string="Barcode Type")

label_size = fields.Selection([

('38x25', '38x25 mm'),

], required=True, default='38x25', string='Label Size')

pricelist_id = fields.Many2one(

'product.pricelist', string='Pricelist', required=True)

currency_id = fields.Many2one(

related='pricelist_id.currency_id', readonly=True)

# TODO: for the moment, we only support weight, but...

quantity = fields.Float(digits=dp.get_precision('Stock Weight'))

price_uom = fields.Monetary(

readonly=True, string="Price per Unit of Measure",

compute='_compute_price') # given by pricelist

price = fields.Monetary(compute='_compute_price', readonly=True)

currency_id = fields.Many2one('res.currency', string='Currency')

state = fields.Selection([

('step1', 'Step1'),

('step2', 'Step2'),

], default='step1', readonly=True)

zpl_file = fields.Binary(string='ZPL File', readonly=True)

zpl_filename = fields.Char('ZPL Filename')

barcode = fields.Char(readonly=True)

copies = fields.Integer(

string='Number of Labels', default=1, required=True)

zpl_printer_id = fields.Many2one(

'printing.printer', string='ZPL Printer')

@api.depends('pricelist_id', 'quantity', 'product_id')

def _compute_price(self):

# for regular barcodes

for wiz in self:

if wiz.pricelist_id and wiz.product_id:

price_uom = wiz.pricelist_id.get_product_price(

wiz.product_id, 1, False)

wiz.price_uom = price_uom

wiz.price = price_uom * wiz.quantity

@api.one

@api.depends('nomenclature_id')

def _compute_rule_id(self):

match_rule = False

if self.nomenclature_id and self.barcode:

for rule in self.nomenclature_id.rule_ids:

match = self.nomenclature_id.match_pattern(

self.barcode, rule.pattern)

if match.get('match'):

match_rule = rule.id

break

self.rule_id = match_rule

def _prepare_price_weight_barcode_type(self):

dpo = self.env['decimal.precision']

bno = self.env['barcode.nomenclature']

prec = dpo.precision_get('Stock Weight')

value = self.quantity

pbarcode = self.barcode

if float_is_zero(value, precision_digits=prec):

raise UserError(_(

"The quantity (%s) must be positive !") % value)

# check prefix

pattern = self.rule_id.pattern

if '{' not in pattern:

raise UserError(_(

"The barcode rule '%s' has a pattern '%s' which doesn't "

"contain a integer and decimal part between '{}'.")

% (self.rule_id.name, pattern))

prefix = pattern.split('{')[0]

assert len(prefix) >= 1

if len(prefix) > len(pbarcode):

raise UserError(_(

"The barcode of the product (%s) has %d characters, "

"which is smaller than the %d characters of the prefix "

"of the barcode pattern (%s).")

% (pbarcode, len(pbarcode), len(prefix), prefix))

barcode = pbarcode[0:len(prefix)]

# print "barcode=", barcode

# print "pattern=", pattern

m = re.search('\{N+D+\}', pattern)

# print "m=", m

assert m

pattern_val = m.group(0)

pattern_val = pattern_val[1:-1]

# print "pattern_val=", pattern_val

max_value = 10**pattern_val.count('N')

if float_compare(value, max_value, precision_digits=prec) != -1:

raise UserError(_(

"The value to encode in the barcode (%s) is superior "

"to the maximum value allowed by the barcode pattern (%s).")

% (value, max_value))

value_u = unicode(value)

value_u_split = value_u.split('.')

assert len(value_u_split) == 2

value_n = value_u_split[0]

value_d = value_u_split[1]

assert len(value_n) <= pattern_val.count('N')

barcode += value_n.zfill(pattern_val.count('N'))

# end fill doesn't exists... so:

# 1) make sure we have enough 0 after

value_d_ext = value_d + '0' * pattern_val.count('D')

# 2) cut at the right size

barcode += value_d_ext[0:pattern_val.count('D')]

# print "barcode=", barcode

# Add checksum

if self.rule_id.encoding == 'ean13':

barcode = bno.sanitize_ean(barcode)

# print "barcode FINAL=", barcode

zpl_unicode = self._price_weight_barcode_type_zpl() % {

'product_name': self.product_name,

'ean13_no_checksum': barcode[:12],

'price_uom': self.price_uom,

'price': self.price,

'currency_symbol': self.currency_id.symbol,

'copies': self.copies,

'quantity': value,

'uom_name': self.uom_id.name,

}

zpl_encoded = zpl_unicode.encode('utf-8')

vals = {

'zpl_file': zpl_encoded.encode('base64'),

'barcode': barcode,

}

return vals

@api.model

def _price_weight_barcode_type_zpl(self):

label = u"""

^XA

^CI28

^PW304

^LL200

^LH0,20

^CF0,30

^FO15,0^FB270,1,0,C^FD%(price).2f %(currency_symbol)s^FS

^CF0,20

^FO15,30^FB270,3,0,C^FD%(product_name)s^FS

^CF0,25

^FO15,75^FB270,1,0,C^FD%(quantity).3f %(uom_name)s %(price_uom).2f %(currency_symbol)s/%(uom_name)s^FS

^FO60,110^BEN,50^FD%(ean13_no_checksum)s^FS

^PQ%(copies)s

^XZ

"""

return label

@api.model

def _product_barcode_type_zpl(self):

label = u"""

^XA

^CI28

^PW304

^LL200

^LH0,20

^CF0,30

^FO15,0^FB270,1,0,C^FD%(price_uom).2f %(currency_symbol)s^FS

^CF0,20

^FO15,30^FB270,3,0,C^FD%(product_name)s^FS

^FO60,100^BEN,60^FD%(ean13_no_checksum)s^FS

^PQ%(copies)s

^XZ

"""

return label

def _prepare_product_barcode_type(self):

zpl_unicode = self._product_barcode_type_zpl() % {

'product_name': self.product_name,

'ean13_no_checksum': self.barcode[:12],

'price_uom': self.price_uom,

'currency_symbol': self.currency_id.symbol, # symbol is a required field

'copies': self.copies,

}

zpl_encoded = zpl_unicode.encode('utf-8')

vals = {

'zpl_file': zpl_encoded.encode('base64'),

'barcode': self.barcode, # unchanged

}

return vals

def generate(self):

assert self.barcode

if len(self.barcode) != 13:

raise UserError(_(

"This wizard only supports EAN13 for the moment. Barcode '%s' "

"has %d digits instead of 13") % (

self.barcode,

len(self.barcode)))

if not self.copies:

raise UserError(_("The number of copies cannot be 0"))

if self.barcode_type in ('price', 'weight'):

vals = self._prepare_price_weight_barcode_type()

elif self.barcode_type == 'product':

vals = self._prepare_product_barcode_type()

else:

raise UserError(_(

"Barcode Type %s is not supported for the moment")

% self.barcode_type)

vals.update({

'state': 'step2',

'zpl_filename': 'barcode_%s.zpl' % vals['barcode'],

})

self.write(vals)

action = self.env['ir.actions.act_window'].for_xml_id(

'product_print_zpl_barcode',

'product_print_zpl_barcode_action')

action.update({

'res_id': self.id,

'context': self._context,

'views': False})

return action

def print_zpl(self):

if not self.zpl_printer_id:

raise UserError(_(

"You must select a ZPL Printer."))

self.zpl_printer_id.print_document(

self.zpl_filename, base64.decodestring(self.zpl_file), 'raw')

action = True

if self._context.get('print_and_new'):

action = self.env['ir.actions.act_window'].for_xml_id(

'product_print_zpl_barcode',

'product_print_zpl_barcode_action')

action.update({

'views': False,

'context': self._context,

})

return action

Dhouha
编写者

_name='label.zpl' i have a mistake when i copy the file in the comment

喜欢讨论吗?不要只阅读,加入进来!

立即创建账户,享受专属功能,与我们的精彩社区互动!

注册
相关帖文 回复 查看 活动
Odoo installatie
odoo
形象
0
12月 25
49
How Odoo Help Businesses??
odoo
形象
0
12月 25
207
Odoo Studio Many2one field not appearing in automations
odoo
形象
形象
1
12月 25
381
SOC 1 Report
odoo
形象
形象
2
11月 25
468
邮箱无法正常使用
odoo
形象
形象
1
11月 25
2379
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • Github
  • Runbot
  • 翻译
服务
  • Odoo.sh 托管
  • 支持
  • 升级
  • 自定义开发服务
  • 教育
  • 查找会计服务
  • 寻找合作伙伴
  • 成为合作伙伴
关于我们
  • 我们的公司
  • 品牌资产
  • 联系我们
  • 招聘
  • 近期活动
  • 播客
  • 博客
  • 客户
  • 法律 • 隐私
  • 安全
الْعَرَبيّة 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致力于为企业管理提供高效智能的开源解决方案,是全球业内高速成长的软件服务商之一,逾七百五十万用户选择Odoo进行数字化升级。通过一系列全业务链覆盖、高度集成、简单易用的商业应用,助力企业实现信息化改革、降本增效并释放公司增长潜力。

Odoo独特的价值在于是一款非常容易使用又完全集成的应用。

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