跳至内容
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
关于此论坛区
帮助

Internal Server Error {The server encountered an internal error and was unable to complete your request. Either the server is o

订阅

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

此问题已终结
viewon_changesale.order.formsale.order
1 回复
12868 查看
形象
Sam path

Hi all, 

I've made a new view for quotation which is totally seperate from tha normal sale order view.

        my_module.py

class sale_quote(osv.osv):
    _name = 'sale.quote'
    _inherit = ['mail.thread', 'ir.needaction_mixin']
    _description = "Quotation"

    def _get_order(self, cr, uid, ids, context=None):
        result = {}
        for line in self.pool.get('quote.line').browse(cr, uid, ids, context=context):
            result[line.order_id.id] = True
        return result.keys()
    
    _columns = {
        'name': fields.char('Order Reference', size=64, required=True,
            select=True),
        'origin': fields.char('Source Document', size=64, help="Reference of the document that generated this quotation request."),
        'client_order_ref': fields.char('Customer Reference', size=64),
        'date_order': fields.date('Date', required=True, select=True),
        'create_date': fields.datetime('Creation Date', readonly=True, select=True, help="Date on which quotation is created."),
        'user_id': fields.many2one('res.users', 'Salesperson', select=True, track_visibility='onchange'),
        'partner_id': fields.many2one('res.partner', 'Customer', required=True, change_default=True, select=True, track_visibility='always'),
        'partner_invoice_id': fields.many2one('res.partner', 'Invoice Address', required=True, help="Invoice address for current quotation."),
        'partner_shipping_id': fields.many2one('res.partner', 'Delivery Address', required=True, help="Delivery address for current quotation."),
        'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, help="Pricelist for current sales order."),
        'currency_id': fields.related('pricelist_id', 'currency_id', type="many2one", relation="res.currency", string="Currency", readonly=True, required=True),
        'order_line': fields.one2many('quote.line', 'order_id', 'Order Lines'),
        'note': fields.text('Terms and conditions'),
        'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
        'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'),
        'company_id': fields.many2one('res.company',string='Company',store=True,readonly=True)
    }
    _defaults = {
        'date_order': fields.date.context_today,
        'user_id': lambda obj, cr, uid, context: uid,
        'name': lambda obj, cr, uid, context: '/',
        'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'],
        'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'],
    }

    def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None):
        context = context or {}
        if not pricelist_id:
            return {}
        value = {
            'currency_id': self.pool.get('product.pricelist').browse(cr, uid, pricelist_id, context=context).currency_id.id
        }
        if not order_lines:
            return {'value': value}
        warning = {
            'title': _('Pricelist Warning!'),
            'message' : _('If you change the pricelist of this order (and eventually the currency), prices of existing order lines will not be updated.')
        }
        return {'warning': warning, 'value': value}

    def onchange_partner_id(self, cr, uid, ids, part, context=None):
        if not part:
            return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False}}

        part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
        addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
        pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
        payment_term = False
        fiscal_position = False
        dedicated_salesman = part.user_id and part.user_id.id or uid
        val = {
            'partner_invoice_id': addr['invoice'],
            'partner_shipping_id': addr['delivery'],
            'user_id': dedicated_salesman,
        }
        if pricelist:
            val['pricelist_id'] = pricelist
        return {'value': val}

    def action_quotation_send(self, cr, uid, ids, context=None):
        '''
        This function opens a window to compose an email, with the edi sale template message loaded by default
        '''
        assert len(ids) == 1, 'This option should only be used for a single id at a time.'
        ir_model_data = self.pool.get('ir.model.data')
        try:
            template_id = ir_model_data.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1]
        except ValueError:
            template_id = False
        try:
            compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
        except ValueError:
            compose_form_id = False 
        ctx = dict(context)
        ctx.update({
            'default_model': 'sale.order',
            'default_res_id': ids[0],
            'default_use_template': bool(template_id),
            'default_template_id': template_id,
            'default_composition_mode': 'comment',
        })
        return {
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'mail.compose.message',
            'views': [(compose_form_id, 'form')],
            'view_id': compose_form_id,
            'target': 'new',
            'context': ctx,
        }


    def create(self, cr, uid, vals, context=None):
        if vals.get('name','/')=='/':
            vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'sale.quote') or '/'
        return super(sale_quote, self).create(cr, uid, vals, context=context)
sale_quote()

class quote_line(osv.osv):

    _name = 'quote.line'
    _description = 'Quote Line'
    _columns = {
        'order_id': fields.many2one('sale.quote', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=False),
        'name': fields.text('Description', required=True, readonly=False),
        'sequence': fields.char('Sequence', help="Gives the sequence order when displaying a list of sales order lines."),
        'qty_range': fields.char('QTY', size=64),
        'dly_week': fields.char('DLY Weeks', size=64),
        'remark': fields.text('Remarks'),
        'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),
        'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=False),
        'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', store=True, string='Customer'),
        'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', store=True, string='Salesperson'),
        'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
    }

    _defaults = {
        'sequence': 10,
        'price_unit': 0.0,
    }

    def product_id_change(self, cr, uid, ids, pricelist, product, name='', partner_id=False,
            lang=False, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
        context = context or {}
        lang = lang or context.get('lang',False)
        if not  partner_id:
            raise osv.except_osv(_('No Customer Defined!'), _('Before choosing a product,\n select a customer in the sales form.'))
        warning = {}
        partner_obj = self.pool.get('res.partner')
        product_obj = self.pool.get('product.product')
        context = {'lang': lang, 'partner_id': partner_id}
        if partner_id:
            lang = partner_obj.browse(cr, uid, partner_id).lang
        context_partner = {'lang': lang, 'partner_id': partner_id}

        if not date_order:
            date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT)

        result = {}
        warning_msgs = ''
        product_obj = product_obj.browse(cr, uid, product, context=context_partner)
        if not flag:
            result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context_partner)[0][1]
            if product_obj.description_sale:
                result['name'] += '\n'+product_obj.description_sale
        domain = {}
        if not pricelist:
            warn_msg = _('You have to select a pricelist or a customer in the sales form !\n'
                    'Please set one before choosing a product.')
            warning_msgs += _("No Pricelist ! : ") + warn_msg +"\n\n"
        else:
            price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
                    product, partner_id, {
                        'date': date_order,
                        })[pricelist]
            if price is False:
                warn_msg = _("Cannot find a pricelist line matching this product and quantity.\n"
                        "You have to change either the product, the quantity or the pricelist.")

                warning_msgs += _("No valid pricelist line found ! :") + warn_msg +"\n\n"
            else:
                result.update({'price_unit': price})
        if warning_msgs:
            warning = {
                       'title': _('Configuration Error!'),
                       'message' : warning_msgs
                    }
        return {'value': result, 'domain': domain, 'warning': warning}

quote_line()

        my_module.xml

        <record id="view_quote_name_form" model="ir.ui.view">
            <field name="name">view.quote.name.form</field>
            <field name="model">sale.quote</field>
            <field name="arch" type="xml">
                <form string="Quote" version="7.0">
                    <header>
                        <button name="action_quotation_send" string="Send by Email" type="object" class="oe_highlight"/>
                    </header>
                    <sheet>
                        <h1>
                            <label string="Quotation "/>
                            <field name="name" class="oe_inline" readonly="1"/>
                        </h1>
                        <group>
                            <group>
                                <field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
                                <field name="partner_invoice_id" context="{'default_type':'invoice'}"/>
                                <field name="partner_shipping_id" context="{'default_type':'delivery'}"/>
                            </group>
                            <group>
                                <field name="date_order"/>
                                <field name="client_order_ref"/>
                                <field domain="[('type','=','sale')]" name="pricelist_id" on_change="onchange_pricelist_id(pricelist_id,order_line)"/>
                                <field name="currency_id"/>
                            </group>
                        </group>
                        <notebook>
                            <page string="Quotation Lines">
                                <field name="order_line">
                                    <form string="Quotation Lines" version="7.0">
                                        <group>
                                            <group>
                                                <field name="sequence"/>
                                                <field name="product_id"
                                                    context="{'partner_id':parent.partner_id, 'pricelist':parent.pricelist_id}"/>
                                                <field name="name"/>
                                                <field name="qty_range"/>
                                                <field name="price_unit"/>
                                                <field name="dly_week"/>
                                                <field name="remark"/>
                                            </group>
                                        </group>
                                    </form>
                                    <tree string="Quote Lines" editable="bottom">
                                        <field name="sequence"/>
                                        <field name="product_id"
                                            context="{'partner_id':parent.partner_id, 'pricelist':parent.pricelist_id}"/>
                                        <field name="name"/>
                                        <field name="qty_range"/>
                                        <field name="price_unit"/>
                                        <field name="dly_week"/>
                                        <field name="remark"/>
                                    </tree>
                                </field>
                                <div class="oe_clear"/>
                                <field name="note" class="oe_inline" placeholder="Terms and conditions..."/>
                            </page>
                            <page string="Other Information">
                                <group>
                                    <group name="sales_person">
                                        <field name="user_id"/>
                                        <field name="origin"/>
                                    </group>
                                    <group name="sale_pay">
                                        <field name="payment_term" widget="selection"/>
                                        <field name="fiscal_position" widget="selection"/>
                                        <field name="company_id" widget="selection"/>
                                    </group>
                                </group>
                            </page>
                        </notebook>
                    </sheet>
                    <div class="oe_chatter">
                        <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
                        <field name="message_ids" widget="mail_thread"/>
                    </div>
                    </form>
                </field>
        </record>
        
        <record id="view_quote_name_tree" model="ir.ui.view">
            <field name="name">view.quote.name.tree</field>
            <field name="model">sale.quote</field>
            <field name="arch" type="xml">
                <tree string="Quotations" version="7.0">
                    <field name="name" string="Quote Number"/>
                    <field name="date_order"/>
                    <field name="partner_id"/>
                    <field name="user_id"/>
                </tree>
            </field>
        </record>
       
        <record id="action_quote_name" model="ir.actions.act_window">
            <field name="name">Quotations</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.quote</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_quote_name_tree"/>
        </record>

        <menuitem id="menu_tc_name_config" action="action_quote_name" name="Quotes" parent="base.menu_sales" sequence="3"/>

this is my code and I've called the quote list in normal sale order view

sale.py

        'quote_no': fields.many2one('sale.quote','Quote No.',required=True),

and I wrote an on change method to pull the customer and the pricelist from the new view

def onchange_quoteno(self, cr, uid, ids, quote, context=None):
        value = {}
        if quote:
            quot = self.pool.get('sale.quote').browse(cr, uid, quote, context=context)
            value = {
                'partner_id': quot.partner_id,
                'pricelist_id': quot.pricelist_id.id,
                }
        return {'value': value}

sale_view.xml

<field name="quote_no" string="Quote No." on_change="onchange_quoteno(quote_no)"/>

I'm getting the drop down list of new quote form but when i select any of them I get this Error

XmlHttpRequestError INTERNAL SERVER ERROR

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>500 Internal Server Error</title> <h1>Internal Server Error</h1> <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>

I don't know wer I'm going wrong. Can anyone help me out..?

0
形象
丢弃
形象
Senthilnathan
最佳答案

 'partner_id': quot.partner_id.id 

1
形象
丢弃
喜欢讨论吗?不要只阅读,加入进来!

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

注册
相关帖文 回复 查看 活动
amount_untaxed not found by xpath in sale.view_order_form 已解决
view sale.order.form sale.order odooV8
形象
形象
1
2月 16
5971
How to turn the left chat menu into a drawer the sale order quotation screen? Odoo v16.3 master milk
view sale.order.form
形象
0
10月 23
1843
how to modify on change sale order?
view sale.order
形象
形象
2
3月 15
10345
Modificación Lista de Productos en una Orden de Venta 已解决
sale.order.line sale.order.form sale.order
形象
形象
2
4月 25
1527
Invoice_ids field in the view of Sale Order
view sale.order invoice.ids
形象
1
2月 16
4874
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • 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