OpenERP7.0当确认销售订单时,消息模块生成动态,如何实现

时间:2014-02-20 02:21:29

标签: python-2.7 openerp-7

我想在我们自己的模块中实现类似的功能:当我创建一个记录时,在消息模块中动态生成,而不仅仅是在页面底部

我发现销售模块具有类似的功能,并且购买模块不,研究也发现没有原则,继承了mail.thread不起作用,我是非常沮丧。

相关的* .py代码:

class jp_stock_picking(osv.osv):
   _name = "jp.stock.picking"
   _inherit = ['mail.thread', 'ir.needaction_mixin']
   _description = "Picking List"

   _track = {
    'state': {
        'stock_jiup.mt_wait_prove': lambda self, cr, uid, obj, ctx=None: obj['state'] in ['wait_prove','overrule','wait_check','checked','cancel']
    },
}
def get_employee(self, cr, uid, context={}):
    obj = self.pool.get('hr.employee')
    ids = obj.search(cr, uid, [('user_id','=',uid)])
    res = obj.read(cr, uid, ids, ['id','name'], context)
    return res and res[0]['id'] or 0

_columns = {
    'name': fields.char('Reference',size=20),
    'document_id': fields.char('Document Number',size=16, required=True),
    'supplier_id': fields.many2one('res.partner', 'Supplier', required=True),
    'create_time': fields.datetime('Create Time', required=True),
    'operator': fields.many2one('hr.employee', 'Operator Perosn', required=True),
    'origin': fields.char('Come From',size=50, required=True),
    'state': fields.selection([('draft', 'New'),
       ('wait_handle','Wait Handle'),
       ('wait_prove', 'Wait Prove'),
       ('overrule', 'Overrule'),
       ('wait_check', 'Wait Quality Checking'),
       ('checked', 'Quality Checked'),
       ('cancel', 'Cancel'),
        ], 'Status', readonly=True, select=True, track_visibility='always'
    ),
    'move_lines': fields.one2many('jp.stock.move', 'jp_picking_id', 'Internal Moves', readonly=True, states={'draft': [('readonly', False)],'wait_handle':[('readonly', False)],'overrule':[('readonly', False)]}),
    'remark': fields.text('Remark')
}

这是相关的* _data.xml代码:

<record id="mt_wait_prove" model="mail.message.subtype">
        <field name="name">Picking Prove</field>
        <field name="res_model">jp.stock.picking</field>
        <field name="default" eval="False"/>
        <field name="description">Picking Prove</field>
</record>

1 个答案:

答案 0 :(得分:0)

继承

_inherit = ['mail.thread', 'ir.needaction_mixin']

对于要生成消息的字段,请添加track_visibility ='always'

_columns = {
    'tot_usr_fee': fields.float('Total User Fees', track_visibility='always'),
}

然后在视图文件中添加

    <record id="mt_shipment_statement_invoice" model="mail.message.subtype">
        <field name="name">Custom Statement Invoice Generated</field>
        <field name="res_model">shipment.statements</field>
        <field name="default" eval="False"/>
        <field name="description">Invoice Generated</field>
    </record>
    <record id="mt_shipment_statement_confirmed" model="mail.message.subtype">
        <field name="name">Custom Statement Confirmed</field>
        <field name="res_model">shipment.statements</field>
        <field name="default" eval="False"/>
        <field name="description">Invoice confirmed</field>
    </record>