From 99d5b5afcef5fd47e774798d771c811830e2a794 Mon Sep 17 00:00:00 2001 From: Dhaval Panchal Date: Wed, 24 Feb 2016 11:02:58 +0530 Subject: [PATCH] [IMP] sale: set default terms and condition for invoice Purpose: Sales general terms should be printed on the invoices when creating an invoice from scratch. For the moment, the Terms and conditions are linked to the SO. Moreover, Terms and Conditions are not copied for Down Payments invoices Specification: - If the source document is an SO, it should take the Terms and conditions of the SO (in all cases, also with down payments) - If created from scratch, it should take the default Terms and conditions set on the company. --- addons/sale/sale.py | 6 ++++++ addons/sale/wizard/sale_make_invoice_advance.py | 1 + 2 files changed, 7 insertions(+) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index e4a75ac3e02..82613459534 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -905,7 +905,13 @@ class AccountInvoice(models.Model): def _get_default_team(self): return self.env['crm.team']._get_default_team_id() + def _default_comment(self): + invoice_type = self.env.context.get('type', 'out_invoice') + if invoice_type == 'out_invoice': + return self.env.user.company_id.sale_note + team_id = fields.Many2one('crm.team', string='Sales Team', default=_get_default_team, oldname='section_id') + comment = fields.Text(default=_default_comment) @api.multi def confirm_paid(self): diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 425925e462f..54d8df384c7 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -93,6 +93,7 @@ class SaleAdvancePaymentInv(models.TransientModel): 'payment_term_id': order.payment_term_id.id, 'fiscal_position_id': order.fiscal_position_id.id or order.partner_id.property_account_position_id.id, 'team_id': order.team_id.id, + 'comment': order.note, }) invoice.compute_taxes() invoice.message_post_with_view('mail.message_origin_link',