class InvoiceWizard(models.TransientModel):
_name = "pos.order.invoice.wizard"
date_order = fields.Datetime(string='Date Order', readonly=True)
partner_id = fields.Many2one('res.partner', string='Partner')
@api.multi
def to_invoice(self):
pos_order = self.env['pos.order'].search([('id','=',self._context.get('active_id'))])
pos_order.create_invoice()
<record id="pos_order_invoice_done" model="ir.ui.view">
<field name="name">pos.order.wizard.invoice</field>
<field name="model">pos.order.invoice.wizard</field>
<field name="arch" type="xml">
<form string="To Invoice">
<group>
<field name="partner_id"/>
<field name="date_order"/>
</group>
<footer>
<button name="to_invoice"
string="Finished" type="object"
class="btn-primary"/>
<button string="Cancel"
class="btn-default"
special="cancel" />
</footer>
</form>
</field>
</record>
我的目标是通过这两个字段创建来自pos订单的发票,我将在向导中选择该字段。我在这里缺少什么?我需要将数据从这些字段传输到create_invoice()方法。
答案 0 :(得分:1)
partner_id,因此您必须填写create method中的字段,如:
@api.multi
def to_invoice(self):
invoice_obj =self.env['account.invoice']
values = {'partner_id' : self.partner_id,
'date_invoice' : self.date_order
}
invoice_obj.create(values)
注意:确保填写所有必填字段。