def _create_invoice_for_po(self, purchase_order, date): move_form = Form( self.env['account.move'].with_context(default_type='in_invoice')) move_form.invoice_date = date move_form.partner_id = self.test_partner move_form.currency_id = self.currency_two move_form.purchase_id = purchase_order return move_form.save()
def init_invoice(cls, move_type): move_form = Form(cls.env['account.move'].with_context(default_type=move_type)) move_form.invoice_date = fields.Date.from_string('2019-01-01') move_form.partner_id = cls.partner_a with move_form.invoice_line_ids.new() as line_form: line_form.product_id = cls.product_a with move_form.invoice_line_ids.new() as line_form: line_form.product_id = cls.product_b return move_form.save()