1

我在 stock.picking 中添加了新字段,并希望它们作为 Delivery Orders 笔记本中的新页面出现在表单视图中。

我认为我遇到了麻烦,因为交付订单中使用的模型是 stock.picking.out,它继承了 stock.picking。

据我所知,使用的表单视图是stock.view_picking_out_form,它继承了stock.view_picking_form。

我在 OpenERP 7 中尝试了很多东西,但都没有奏效。

在 6.1 版中,它的工作方式是这样的......

.py:

class stock_picking(osv.osv):

    _inherit = "stock.picking"
    _columns = {
        'hash':       fields.char('Assinatura', size=200),
        'hash_control': fields.char('Chave', size=40),
        'system_entry_date':   fields.datetime('Data de confirmação'),
        'write_date':   fields.datetime('Data de alteração'),
        'hashcode': fields.char('Assinatura do Documento', size=5),
        'doc_guia': fields.boolean('Este documento é do tipo Guia?',
                help='Se o documento for do tipo Guia (e.g.: Guia de Transporte, Guia de Remessa, etc) assinale este campo.'),
        'journal_id': fields.many2one('account.journal', 'Tipo de Guia', domain=[('type', '=', 'guia')], readonly=True),
        'guia_number': fields.char('Número da Guia', size=40, readonly=True),
        'at_code': fields.char('Nº Autorização AT', size=200, readonly=True),
        'data_hora_inicio': fields.datetime('Data/Hora Inicio'),
        'data_hora_fim': fields.datetime('Data/Hora Fim'),
        'at_reject': fields.char('Motivo de Rejeição', size=200, readonly=True),
        'tipo_biling': fields.selection([('P', 'Documento criado nesta aplicação'),
                                           ('I', 'Documento criado noutra aplicação e integrada nesta aplicação'),
                                           ('M', 'Documento proveniente de um documento manual')],
                                          "Origem do Documento", readonly=True),
        'nota_breve': fields.char('Referência', size=128),

    }


stock_picking()

xml:

<record model="ir.ui.view" id="stock_picking_saft_inherit">
            <field name="name">stock.picking.saft.inherit</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_out_form"/>
            <field name="arch" type="xml">
                <field name="backorder_id" position="after">
                    <group col="6" fill="1" colspan="6">
                        <separator colspan="6" string="Dados da Guia"/>
                        <newline/>
                        <field name="journal_id" colspan="3"/>
                        <field name="guia_number" colspan="3"/>
                        <field name="data_entrega" colspan="3"/>
                        <field name="matricula_id" colspan="3"/>
                        <field name="local_carga" colspan="3"/>
                        <field name="tipo_biling" colspan="3"/>
                        <field name="doc_guia" invisible="True"/>
                        <field name="nota_breve" colspan="6"/>
                        <newline/>
                        <separator colspan="6" string="Comunicação AT"/>
                        <newline/>
                        <field name="at_code" colspan="6"/>
                        <field name="at_reject" colspan="6"/>
                    </group>
                </field>
                <tree string="Stock Moves" position="inside">
                     <field name="name" />
                </tree>

                <form string="Stock Moves" position="inside" > 
                    <newline/>
                    <separator colspan="8" string="Descrição do Produto"/>
                    <field name="name" />
                </form>
            </field>
        </record>

任何人都可以帮忙吗?

谢谢。

4

5 回答 5

1

Delivery Order是一个对象继承,'stock.picking'现在Delivery Order对象名称是'stock.picking.out'

以下示例在.py file

class stock_picking_out(osv.Model):
    _inherit = 'stock.picking.out'

    _columns = {
        #here declare your field 
    }

现在在.xml file

<record id="view_stock_picking_out_extended_form" model="ir.ui.view">
    <field name="name">stock.picking.out.extended.form</field>
    <field name="model">stock.picking.out</field>
    <field name="inherit_id" ref="stock.view_picking_form"/>
    <field name="arch" type="xml">
            <field name="backorder_id" position="after">
                #place here your customize field
            </field>
    </field>
</record>

完成此操作后,您将看到Delivery Order并希望看到您想要的输出。

希望这会帮助你。

于 2014-05-16T13:05:58.577 回答
1

试试这个..它有效..我试过了..你Odedra是正确的..u应该从openerp.osv继承stock.picking.out import osv

从 openerp.osv 导入字段

类交付订单(osv.osv):

_inherit = "stock.picking.out"
_columns = {
    'cname': fields.char('CName', size=64),
}

交付订单()

查看文件

<openerp>
<data>
    <record id="view_delivery_order_form" model="ir.ui.view">
        <field name="name">stock.picking.out.form</field>
        <field name="model">stock.picking.out</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="arch" type="xml">
            <xpath expr="//notebook/page[@string='Additional Info']" position="after">
                <page string="New Page">
                    <group colspan="4">
                        <field name="cname"/>
                    </group>
                </page>
            </xpath>
        </field>
    </record>
</data>

希望能帮助到你..

于 2014-05-17T09:38:52.443 回答
1

我经常尝试过,我唯一的解决方案是:继承stock.picking.out和正常stock.picking,两者都有字段。一些非常简单的例子:

选股:

_columns = {
            'yourcolumn':fields. #and so on
           }

stock.picking.out:

_columns = {
            'yourcolumn':fields. #and so on
           }

现在您可以在视图中使用“yourcolumn”字段。

:-)

于 2014-05-19T07:14:14.203 回答
1

您可能希望避免像这样在 stock.picking 和 stock.picking.out 中定义列

from openerp.osv import orm, fields

class StockPicking(orm.Model):
  _inherit = 'stock.picking'

  _columns = {
      'new_field': fields.many2one('other.model', 'New field'),
  }

class StockPickingOut(orm.Model):

  _inherit = 'stock.picking.out'

  def __init__(self, pool, cr):
    super(StockPickingOut, self).__init__(pool, cr)
    self._columns['new_field'] = self.pool['stock.picking']._columns['new_field']

真正有用的是有几个字段要添加

在此处获取 https://bugs.launchpad.net/openobject-addons/+bug/1169998/comments/8中的完整信息

存在另一种解决方案:使用像这里这样的抽象模型:

from openerp.osv import orm, fields

class AbstractStockPicking(orm.AbstractModel):
  _inherit = 'abstract.logistic.flow'
  _name = 'abstract.stock.picking'

  _columns = {
      'new_field': fields.many2one('other.model', 'New field'),
  }

class StockPicking(orm.Model):
  _inherit = ['stock.picking', 'abstract.stock.picking']
  _name = 'stock.picking'

  def __init__(self, pool, cr):
    super(StockPicking, self).__init__(pool, cr)
    self._columns['new_field'] = \
        self.pool['abstract.stock.picking']._columns[new_field]


class StockPickingOut(orm.Model):
  _inherit = ['stock.picking.out', 'abstract.stock.picking']
  _name = 'stock.picking.out'

  def __init__(self, pool, cr):
    super(StockPickingOut, self).__init__(pool, cr)
    self._columns['new_field'] = \
        self.pool['abstract.stock.picking']._columns[new_field]

这里的真实例子:

http://bazaar.launchpad.net/~akretion-team/+junk/logistic-center/view/head:/connector_logistic_center/stock.py#L65

这里的视图是一个例子:

<record id="view_picking_form_logis_out" model="ir.ui.view">
  <field name="model">stock.picking.out</field>
  <field name="inherit_id" ref="stock.view_picking_form"/>
  <field name="arch" type="xml">
    <field name="stock_journal_id" position="after">
        <field name="logistic_center"/>
    </field>
  </field>
</record>

详情在这里:

http://bazaar.launchpad.net/~akretion-team/+junk/logistic-center/view/head:/connector_logistic_center/stock_view.xml#L62

于 2014-05-20T21:08:57.787 回答
0

Nothing I've tried helped, including the solutions provided here. So, I ended up creating a new view for the delivery orders. Thank you for help, anyway.

于 2014-06-05T17:03:24.230 回答