我试图通过python代码创建一个发票和发票行。
def createInvoice(self, date_ref):
// Skipped some code here
invoice_values = contract._prepare_invoice(date_ref)
for line in contract_lines:
invoice_values.setdefault('invoice_line_ids', [])
invoice_line_values = line._prepare_invoice_line(
invoice_id=False
)
if invoice_line_values:
invoice_values['invoice_line_ids'].append(
(0, 0, invoice_line_values)
)
invoices_values.append(invoice_values)
价值观
invoice_values = {'type': 'in_invoice', 'journal_id': 2, 'company_id': 1, 'line_ids': [(6, 0, [])],
'partner_id': 42, 'commercial_partner_id': 42, 'fiscal_position_id': False,
'invoice_payment_term_id': False, 'invoice_line_ids': [(6, 0, [])],
'invoice_partner_bank_id': False, 'invoice_cash_rounding_id': False,
'bank_partner_id': 42, 'currency_id': 130, 'invoice_date': datetime.date(2020, 11, 11),
'invoice_origin': 'Vendor COntract #1', 'user_id': 2, 'old_contract_id': 6}
invoice_line_values = {'move_id': False, 'journal_id': False, 'company_id': False,
'account_id': False, 'name': '[E-COM07] Large Cabinet', 'quantity': 1.0,
'price_unit': 1444.01, 'discount': 0.0, 'partner_id': False,
'product_uom_id': 1, 'product_id': 17, 'payment_id': False,
'tax_ids': [(6, 0, [])], 'analytic_line_ids': [(6, 0, [])],
'display_type': False, 'contract_line_id': 7, 'asset_id': False,
'analytic_account_id': False}
在账户移动的创建功能中
vals = {'date': datetime.date(2020, 2, 11), 'type': 'in_invoice', 'journal_id': 2,
'company_id': 1, 'currency_id': 130, 'line_ids': [(6, 0, [])], 'partner_id': 42,
'commercial_partner_id': 42, 'fiscal_position_id': False, 'user_id': 2,
'invoice_date': datetime.date(2020, 12, 11), 'invoice_origin': 'Vendor COntract #1',
'invoice_payment_term_id': False,
'invoice_line_ids': [(6, 0, []), (0, 0, {'journal_id': False, 'company_id': False,
'account_id': 109, 'name': '[E-COM07] Large Cabinet', 'quantity': 1.0, 'price_unit': 1444.01,
'discount': 0.0, 'partner_id': False, 'product_uom_id': 1, 'product_id': 17,
'payment_id': False, 'tax_ids': [(6, 0, [19])], 'analytic_line_ids': [(6, 0, [])],
'analytic_account_id': False, 'display_type': False, 'exclude_from_invoice_tab': False,
'contract_line_id': 7, 'asset_id': False}), (0, 0, {'journal_id': False,
'company_id': False, 'account_id': 109, 'name': '[E-COM09] Large Desk', 'quantity': 1.0,
'price_unit': 8118.04, 'discount': 0.0, 'partner_id': False, 'product_uom_id': 1,
'product_id': 19, 'payment_id': False, 'tax_ids': [(6, 0, [19])],
'analytic_line_ids': [(6, 0, [])], 'analytic_account_id': False, 'display_type': False,
'exclude_from_invoice_tab': False, 'contract_line_id': 8, 'asset_id': False})],
'invoice_partner_bank_id': False, 'invoice_cash_rounding_id': False, 'bank_partner_id': 42,
'old_contract_id': 6}
我错过了什么?